Skip to content

gelify should handle redirects and create a signout endpoint #874

@anbuzin

Description

@anbuzin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions