Login Flows
Login Flows
This section illustrates the major authentication paths supported by Openlane.
Credential Login
The credential handler is implemented in internal/httpserve/handlers/login.go:
LoginHandlerparses aLoginRequestand callsgetUserByEmailto fetch the account.- If the account does not exist,
RegisterHandlercreates the user andsendVerificationEmaildispatches the confirmation email. ssoOrgForUserdetermines if the organization enforces SSO for the email and redirects non-owner users toSSOLoginHandlerwhen required.- Unverified users can request a new token via
ResendEmail, which invokesstoreAndSendEmailVerificationToken. - When the password is validated with
passwd.VerifyDerivedKey,AuthManager.GenerateUserAuthSessionissues the access and refresh tokens andupdateUserLastSeenrecords the login.
OAuth / Social Login
The OAuth handlers are defined in internal/httpserve/handlers/oauth_login.go and
oauth_register.go:
GetGoogleLoginHandlersandGetGitHubLoginHandlersredirect users to the provider.- After the provider callback,
issueGoogleSessionorissueGitHubSessioncallCheckAndCreateUserto create or update the user record. ssoOrgForUserchecks the email's organization and redirects toSSOLoginHandlerwhen SSO is enforced for non-owner members.- New accounts are verified by
sendVerificationEmailinsidestoreAndSendEmailVerificationToken. - A session is created via
AuthManager.GenerateOauthAuthSessionand the last login is stored withupdateUserLastSeen.
Passkey Login
Passkey operations live in internal/httpserve/handlers/webauthn.go:
BeginWebauthnLoginissues a challenge withWebAuthn.BeginDiscoverableLoginand stores it in the session.FinishWebauthnLoginparses the response usingprotocol.ParseCredentialRequestResponseBodyand validates it withWebAuthn.ValidateDiscoverableLogin.- The user is loaded with
getUserByID, thenAuthManager.GenerateUserAuthSessioncreates the token pair. updateUserLastSeenrecords that the login was via a passkey.
Organization-Enforced SSO
Single sign-on logic is implemented in internal/httpserve/handlers/sso.go:
SSOLoginHandlerchecks the organization policy viafetchSSOStatusand redirects to the configured IdP.- On return,
SSOCallbackHandlerexchanges the authorization code withrp.CodeExchangeand retrieves the user data. - The account is ensured using
CheckAndCreateUser; new users receive a verification email viasendVerificationEmail. AuthManager.GenerateOauthAuthSessionissues the session and the login time is recorded withupdateUserLastSeen.
WebFinger Endpoint
WebFinger is an HTTP discovery protocol defined by RFC 7033. It allows a client to look up information about a resource, typically identified by a URI such as an email address.
Openlane exposes a WebFinger endpoint at /.well-known/webfinger. The login page queries this endpoint to determine whether an organization requires SSO authentication and which identity provider should be used.
Querying the Endpoint
Send a GET request to /.well-known/webfinger with a resource parameter.
/.well-known/webfinger?resource=acct:alice@example.com
/.well-known/webfinger?resource=org:01HAC1M7J3A2YHC4ZK6B2QWJNT
The endpoint returns an SSOStatusReply structure:
{
"success": true,
"enforced": true,
"provider": "OKTA",
"discovery_url": "https://id.example.com/.well-known/openid-configuration",
"organization_id": "01HAC1M7J3A2YHC4ZK6B2QWJNT"
}
Why WebFinger?
Using WebFinger provides a lightweight way for the UI to discover if SSO is enforced before the user authenticates. When the email entered on the login form maps to an organization that enforces SSO, the browser can immediately redirect to the configured identity provider without any additional API calls or user interaction.