SolveIt Auth

Google Sign-In for apps hosted on SolveIt

This module wraps the SolveIt auth service so your FastHTML app can add Google Sign-In with just two function calls: setup_solve_signin to add the sign-in route, and sub_from_signin to validate the reply and get the user’s Google sub ID.


source

SolveSigninError


def SolveSigninError(
    args:VAR_POSITIONAL, kwargs:VAR_KEYWORD
):

Common base class for all non-exit exceptions.

SolveSigninError is raised when authentication fails — either from an invalid JWT or an error returned by the auth service. Catch this in your signin_completed route to handle auth failures gracefully.


source

setup_solve_signin


def setup_solve_signin(
    app, port:int=8000, callback_rt:str='/signin_completed', email_re:NoneType=None, hd_re:NoneType=None
):

Add /solve_signin route to app that redirects to Google via SolveIt auth

setup_solve_signin adds a /solve_signin route to your FastHTML app. When a user visits this route, they’re redirected to Google Sign-In via the SolveIt auth service. After authentication, Google redirects back to your callback_rt (defaults to /signin_completed) with a signin_reply query parameter.

The solve_signin_rt variable is exported so you can reference it in links: A('Sign In', href=solve_signin_rt).


source

sub_from_signin


def sub_from_signin(
    session, signin_reply
):

Decode signin JWT, validate, and return Google sub ID. Raises SolveSigninError on failure.

sub_from_signin is the function your app calls in the signin completion route. It decodes the JWT reply from SolveIt’s auth service, checks for errors, and returns the user’s Google sub ID as a string. Raises SolveSigninError on any failure.