edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

gelify should handle redirects and create a signout endpoint

Open anbuzin opened this issue 4 months ago • 0 comments

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

    @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)
    @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.

anbuzin avatar Aug 27 '25 05:08 anbuzin