Authentication
Authentication Flow Explanation
The authentication system supports multiple methods: direct credential login (username/password), OAuth, SAML, and potentially Single Sign-On (SSO) inferred from existing sessions.
Authentication Breakdown
- Main Entry Point: The process starts with the
login(credentials?)
function insrc/authentification/core.ts
. - Credential Login: If credentials are provided, it calls
getJWToken
to authenticate against the/security.webtoken
endpoint and stores the returnedcsrfToken
in the session storage and the user is considered authenticated. - Automatic Flow (No Credentials):
- It first tries to get a
csrfToken
viagetCsrfToken
(calling/challenge
). - Failure: If no token is found (no active session), it checks configuration for
autoOAuthProvider
orautoSAMLProvider
.- If configured, it calls
tryOAuthAuthentication
ortrySAMLAuthentication
, which get redirect URLs from/security.oauth
or/security.saml
respectively, and redirect the user to the corresponding provider. - If not configured, it prepares for UI-driven login.
- If configured, it calls
- Success: If a token is found, the user is considered authenticated (existing session).
- It first tries to get a
- SSO Check: In scenarios where neither credentials nor auto-redirects occurred initially, the system might try to fetch the current user's principal information
fetchPrincipal
to confirm an existing SSO session if other methods haven't already confirmed authentication. - Existing Token Check: It checks
sessionStorage
andlocalStorage
for an existing token viagetToken()
. - Logout:
logout
clears tokens from storage and callsdeleteWebTokenCookie
if applicable. - State Notification: An
authenticated
custom browser event is dispatched (emitAuthenticatedEvent
) to signal login status changes.