{% extends "base.html" %} {% block title %}Cross-Auth FastAPI Hybrid Example{% endblock %} {% block content %}
FastAPI Hybrid Demo

Session and auth-server flows on one backend

This backend demonstrates all three Cross-Auth configurations at once: a same-origin session app, a standalone auth-server flow for a separate SPA, and the hybrid case where one backend supports both. The local login form and GitHub session button end in a browser cookie, while the separate SPA uses the generic auth-code + /auth/token flow.

{% if error_message %}
{{ error_message }}
{% endif %}

Session App

{% if user %}

Signed in as {{ user.email }}

User ID {{ user.id }}

session active same-origin web app
Profile /api/me
{% else %}

Sign in locally or use GitHub to create a browser session.

{% endif %}

Separate SPA Client

A second app in examples/spa can authenticate against this backend as if Cross-Auth were a standalone authentication server.

The SPA generates PKCE in the browser, redirects to /auth/github/authorize, receives a local auth code at its own callback URL, exchanges it at /auth/token, and then calls /api/me with a bearer token.

Demo Accounts

The backend seeds one in-memory password user at startup.

The GitHub button uses a public mock GitHub OAuth server. Enter {{ demo_email }} there to link the seeded demo user, or any other email to create a new in-memory local user.

Emails starting with unverified are treated as unverified by the mock.

How The Flow Is Chosen

Hook Activity

This example registers hooks for password authentication, session login/logout, OAuth callbacks, and token exchange.

{% if hook_events %} {% else %} no hook events yet {% endif %}

Flow Summary

{% endblock %}