geldata / geldata/gel-python

gelify should handle redirects and create a signout endpoint

Open
#874 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
415
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Here's some custom code that could be a part of the auth integration:

```python
@router.get("/auth/signin")
async def auth_signin(response: fastapi.Response, redirect_to: str | None = None) -> str:
"""Start sign in process - generates auth URL and sets verifier cookie."""
result = g.auth.builtin_ui.core.start_sign_in()
g.auth.set_verifier_cookie(result.verifier, response)
if redirect_to:
response.set_cookie("signin-redirect", redirect_to, httponly=True, secure=True)
return str(result.redirect_url)
```

```python
@router.get("/auth/signout")
async def signout():
"""Sign out - clears auth cookies."""
response = RedirectResponse(settings.ui_origin, status_code=302)
response.delete_cookie(
g.auth.auth_cookie_name.value,
httponly=True,
secure=g.auth.secure_cookie.value,
)
return response
```

That would then simplify a standard auth setup to just defining the `on_new_identity` function.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.