Documentation Index Fetch the complete documentation index at: https://docs.pysquirrels.com/llms.txt
Use this file to discover all available pages before exploring further.
Class representing a user that must be authenticated by logging in.
This is often used to define the user returned by the get_user function of the ProviderConfigs class.
This class can be imported from the squirrels.auth or the squirrels module.
Constructor
Creates a RegisteredUser object.
def __init__ (
self , * , username : str , access_level : Literal[ 'admin' , 'member' ],
custom_fields : CustomUserFields
) -> None :
The unique username of the user
access_level
Literal['admin', 'member']
The access level of the user
Custom fields associated with the user
Example
from squirrels import auth, arguments as args
@auth.provider (
name = "google" , label = "Google" ,
icon = "https://www.google.com/favicon.ico"
)
def google_auth_provider ( sqrl : args.AuthProviderArgs) -> auth.ProviderConfigs:
def get_sqrl_user ( claims : dict ) -> auth.RegisteredUser:
custom_fields = auth.CustomUserFields() # or the derived class
return auth.RegisteredUser(
username = claims[ "email" ],
access_level = "member" ,
custom_fields = custom_fields
)
provider_configs = auth.ProviderConfigs(
client_id = sqrl.env_vars[ "GOOGLE_CLIENT_ID" ],
client_secret = sqrl.env_vars[ "GOOGLE_CLIENT_SECRET" ],
server_url = "https://accounts.google.com" ,
client_kwargs = { "scope" : "openid email profile" },
get_user = get_sqrl_user
)
return provider_configs