Documentation
¶
Overview ¶
Package idp contains frontend handlers for IDP browser flows.
Index ¶
- func BasePageData(ctx *gin.Context, cfg config.File, langManager corelang.Manager) gin.H
- func CleanupIDPFlowState(mgr cookie.Manager)
- func CleanupMFAState(mgr cookie.Manager)
- type FrontendHandler
- func (h *FrontendHandler) AuthMiddleware() gin.HandlerFunc
- func (h *FrontendHandler) CancelRequiredMFARegistration(ctx *gin.Context)
- func (h *FrontendHandler) ContinueMFASelfServiceStepUp(ctx *gin.Context)
- func (h *FrontendHandler) ContinueRequiredMFARegistration(ctx *gin.Context)
- func (h *FrontendHandler) DeleteTOTP(ctx *gin.Context)
- func (h *FrontendHandler) DeleteWebAuthn(ctx *gin.Context)
- func (h *FrontendHandler) DeleteWebAuthnDevice(ctx *gin.Context)
- func (h *FrontendHandler) GetUserBackendData(ctx *gin.Context) (*UserBackendData, error)
- func (h *FrontendHandler) LoggedOut(ctx *gin.Context)
- func (h *FrontendHandler) Login(ctx *gin.Context)
- func (h *FrontendHandler) LoginMFASelect(ctx *gin.Context)
- func (h *FrontendHandler) LoginRecovery(ctx *gin.Context)
- func (h *FrontendHandler) LoginTOTP(ctx *gin.Context)
- func (h *FrontendHandler) LoginWebAuthn(ctx *gin.Context)
- func (h *FrontendHandler) PostGenerateRecoveryCodes(ctx *gin.Context)
- func (h *FrontendHandler) PostLogin(ctx *gin.Context)
- func (h *FrontendHandler) PostLoginRecovery(ctx *gin.Context)
- func (h *FrontendHandler) PostLoginTOTP(ctx *gin.Context)
- func (h *FrontendHandler) PostLoginWebAuthnFinish(ctx *gin.Context)
- func (h *FrontendHandler) PostRegisterRecoveryCodes(ctx *gin.Context)
- func (h *FrontendHandler) PostRegisterTOTP(ctx *gin.Context)
- func (h *FrontendHandler) Register(router gin.IRouter)
- func (h *FrontendHandler) RegisterRecoveryCodes(ctx *gin.Context)
- func (h *FrontendHandler) RegisterTOTP(ctx *gin.Context)
- func (h *FrontendHandler) RegisterWebAuthn(ctx *gin.Context)
- func (h *FrontendHandler) SaveRecoveryCodes(ctx *gin.Context)
- func (h *FrontendHandler) TwoFAHome(ctx *gin.Context)
- func (h *FrontendHandler) UpdateWebAuthnDeviceName(ctx *gin.Context)
- func (h *FrontendHandler) WebAuthnDevices(ctx *gin.Context)
- type OIDCHandler
- func (h *OIDCHandler) Authorize(ctx *gin.Context)
- func (h *OIDCHandler) ConsentGET(ctx *gin.Context)
- func (h *OIDCHandler) ConsentPOST(ctx *gin.Context)
- func (h *OIDCHandler) DeviceAuthorization(ctx *gin.Context)
- func (h *OIDCHandler) DeviceConsentGET(ctx *gin.Context)
- func (h *OIDCHandler) DeviceConsentPOST(ctx *gin.Context)
- func (h *OIDCHandler) DeviceVerify(ctx *gin.Context)
- func (h *OIDCHandler) DeviceVerifyFailedPage(ctx *gin.Context)
- func (h *OIDCHandler) DeviceVerifyPage(ctx *gin.Context)
- func (h *OIDCHandler) Discovery(ctx *gin.Context)
- func (h *OIDCHandler) Introspect(ctx *gin.Context)
- func (h *OIDCHandler) JWKS(ctx *gin.Context)
- func (h *OIDCHandler) Logout(ctx *gin.Context)
- func (h *OIDCHandler) Register(router gin.IRouter)
- func (h *OIDCHandler) Token(ctx *gin.Context)
- func (h *OIDCHandler) UserInfo(ctx *gin.Context)
- type SAMLHandler
- func (h *SAMLHandler) GetServiceProvider(_ *http.Request, serviceProviderID string) (*saml.EntityDescriptor, error)
- func (h *SAMLHandler) Metadata(ctx *gin.Context)
- func (h *SAMLHandler) Register(router gin.IRouter)
- func (h *SAMLHandler) SLO(ctx *gin.Context)
- func (h *SAMLHandler) SSO(ctx *gin.Context)
- type UserBackendData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasePageData ¶
BasePageData returns the common data for all IDP frontend pages.
func CleanupIDPFlowState ¶
CleanupIDPFlowState removes all temporary IDP flow state keys from the cookie. These keys are only needed during the login redirect cycle (e.g. /oidc/authorize → /login → /oidc/authorize or /saml/sso → /login → /saml/sso) and should be cleaned up after the flow completes successfully. This covers OIDC (authorization code, device code) and SAML flows.
func CleanupMFAState ¶
CleanupMFAState removes all temporary MFA flow keys from the cookie. These keys are only needed during MFA verification and should be cleaned up after the MFA flow completes successfully (in finalizeMFALogin).
Types ¶
type FrontendHandler ¶
type FrontendHandler struct {
// contains filtered or unexported fields
}
FrontendHandler handles general IDP frontend pages like login and consent.
func NewFrontendHandler ¶
func NewFrontendHandler(d *deps.Deps) *FrontendHandler
NewFrontendHandler creates a new FrontendHandler.
func (*FrontendHandler) AuthMiddleware ¶
func (h *FrontendHandler) AuthMiddleware() gin.HandlerFunc
AuthMiddleware ensures the user is logged in for protected pages like 2FA Self-Service. Users must already have a valid session from a completed IDP flow. Direct access without a prior login redirects to an error page.
func (*FrontendHandler) CancelRequiredMFARegistration ¶
func (h *FrontendHandler) CancelRequiredMFARegistration(ctx *gin.Context)
CancelRequiredMFARegistration is the GET handler for /mfa/register/cancel. The user declined to register a required MFA method, so the entire session is invalidated: the forced-registration state is removed, the IDP flow state is cleaned up, and the user is logged out before being sent to /logged_out.
func (*FrontendHandler) ContinueMFASelfServiceStepUp ¶
func (h *FrontendHandler) ContinueMFASelfServiceStepUp(ctx *gin.Context)
ContinueMFASelfServiceStepUp executes a one-time mutation after the completed MFA response has established the fresh authenticated browser session.
func (*FrontendHandler) ContinueRequiredMFARegistration ¶
func (h *FrontendHandler) ContinueRequiredMFARegistration(ctx *gin.Context)
ContinueRequiredMFARegistration is the GET handler for /mfa/register/continue. It is called after each individual MFA registration step in a forced-registration flow to decide whether another method still needs to be registered or whether the original IDP flow can be resumed.
func (*FrontendHandler) DeleteTOTP ¶
func (h *FrontendHandler) DeleteTOTP(ctx *gin.Context)
DeleteTOTP removes TOTP for the user.
func (*FrontendHandler) DeleteWebAuthn ¶
func (h *FrontendHandler) DeleteWebAuthn(ctx *gin.Context)
DeleteWebAuthn removes WebAuthn credentials for the user.
func (*FrontendHandler) DeleteWebAuthnDevice ¶
func (h *FrontendHandler) DeleteWebAuthnDevice(ctx *gin.Context)
DeleteWebAuthnDevice removes a specific WebAuthn credential for the user.
func (*FrontendHandler) GetUserBackendData ¶
func (h *FrontendHandler) GetUserBackendData(ctx *gin.Context) (*UserBackendData, error)
GetUserBackendData performs backend lookups and returns encapsulated user data.
func (*FrontendHandler) LoggedOut ¶
func (h *FrontendHandler) LoggedOut(ctx *gin.Context)
LoggedOut renders the logout confirmation page.
func (*FrontendHandler) Login ¶
func (h *FrontendHandler) Login(ctx *gin.Context)
Login renders the modern login page. This endpoint is ONLY for IDP flows (OIDC/SAML2). Direct access without a proper flow is rejected. All flow state is read from the secure encrypted cookie - no URL parameters are used.
func (*FrontendHandler) LoginMFASelect ¶
func (h *FrontendHandler) LoginMFASelect(ctx *gin.Context)
LoginMFASelect renders the MFA selection page. All flow state is read from the encrypted cookie - no URL parameters are used.
func (*FrontendHandler) LoginRecovery ¶
func (h *FrontendHandler) LoginRecovery(ctx *gin.Context)
LoginRecovery renders the recovery code verification page during login. All flow state is read from the encrypted cookie - no URL parameters are used.
func (*FrontendHandler) LoginTOTP ¶
func (h *FrontendHandler) LoginTOTP(ctx *gin.Context)
LoginTOTP renders the TOTP verification page during login. All flow state is read from the encrypted cookie - no URL parameters are used.
func (*FrontendHandler) LoginWebAuthn ¶
func (h *FrontendHandler) LoginWebAuthn(ctx *gin.Context)
LoginWebAuthn renders the WebAuthn verification page during login. All flow state is read from the encrypted cookie - no URL parameters are used.
func (*FrontendHandler) PostGenerateRecoveryCodes ¶
func (h *FrontendHandler) PostGenerateRecoveryCodes(ctx *gin.Context)
PostGenerateRecoveryCodes handles generating new recovery codes.
func (*FrontendHandler) PostLogin ¶
func (h *FrontendHandler) PostLogin(ctx *gin.Context)
PostLogin handles the login submission. This endpoint is ONLY for IDP flows (OIDC/SAML2). Direct access without a proper flow is rejected. All flow state is read from the secure encrypted cookie - no form parameters for flow state.
func (*FrontendHandler) PostLoginRecovery ¶
func (h *FrontendHandler) PostLoginRecovery(ctx *gin.Context)
PostLoginRecovery handles the recovery code verification during login. All flow state is read from the encrypted cookie - no form parameters for flow state.
func (*FrontendHandler) PostLoginTOTP ¶
func (h *FrontendHandler) PostLoginTOTP(ctx *gin.Context)
PostLoginTOTP handles the TOTP verification during login. All flow state is read from the encrypted cookie - no form parameters for flow state.
func (*FrontendHandler) PostLoginWebAuthnFinish ¶
func (h *FrontendHandler) PostLoginWebAuthnFinish(ctx *gin.Context)
PostLoginWebAuthnFinish completes WebAuthn MFA and returns the server-derived continuation target for the surrounding IDP flow.
func (*FrontendHandler) PostRegisterRecoveryCodes ¶
func (h *FrontendHandler) PostRegisterRecoveryCodes(ctx *gin.Context)
PostRegisterRecoveryCodes handles the continue action after recovery codes are saved.
func (*FrontendHandler) PostRegisterTOTP ¶
func (h *FrontendHandler) PostRegisterTOTP(ctx *gin.Context)
PostRegisterTOTP handles the TOTP registration submission.
func (*FrontendHandler) Register ¶
func (h *FrontendHandler) Register(router gin.IRouter)
Register adds frontend routes to the router.
func (*FrontendHandler) RegisterRecoveryCodes ¶
func (h *FrontendHandler) RegisterRecoveryCodes(ctx *gin.Context)
RegisterRecoveryCodes renders the recovery codes registration page.
func (*FrontendHandler) RegisterTOTP ¶
func (h *FrontendHandler) RegisterTOTP(ctx *gin.Context)
RegisterTOTP renders the TOTP registration page.
func (*FrontendHandler) RegisterWebAuthn ¶
func (h *FrontendHandler) RegisterWebAuthn(ctx *gin.Context)
RegisterWebAuthn renders the WebAuthn registration page.
func (*FrontendHandler) SaveRecoveryCodes ¶
func (h *FrontendHandler) SaveRecoveryCodes(ctx *gin.Context)
SaveRecoveryCodes persists the recovery codes once the user downloaded them.
func (*FrontendHandler) TwoFAHome ¶
func (h *FrontendHandler) TwoFAHome(ctx *gin.Context)
TwoFAHome renders the 2FA management overview.
func (*FrontendHandler) UpdateWebAuthnDeviceName ¶
func (h *FrontendHandler) UpdateWebAuthnDeviceName(ctx *gin.Context)
UpdateWebAuthnDeviceName renames a specific WebAuthn credential for the user.
func (*FrontendHandler) WebAuthnDevices ¶
func (h *FrontendHandler) WebAuthnDevices(ctx *gin.Context)
WebAuthnDevices renders the WebAuthn devices overview page.
type OIDCHandler ¶
type OIDCHandler struct {
// contains filtered or unexported fields
}
OIDCHandler handles OIDC protocol requests.
func NewOIDCHandler ¶
func NewOIDCHandler(d *deps.Deps, idpInstance *idp.NauthilusIDP, frontendHandler *FrontendHandler) *OIDCHandler
NewOIDCHandler creates a new OIDCHandler.
func (*OIDCHandler) Authorize ¶
func (h *OIDCHandler) Authorize(ctx *gin.Context)
Authorize handles the OIDC authorization request.
func (*OIDCHandler) ConsentGET ¶
func (h *OIDCHandler) ConsentGET(ctx *gin.Context)
ConsentGET handles the OIDC consent request.
func (*OIDCHandler) ConsentPOST ¶
func (h *OIDCHandler) ConsentPOST(ctx *gin.Context)
ConsentPOST handles the OIDC consent submission.
func (*OIDCHandler) DeviceAuthorization ¶
func (h *OIDCHandler) DeviceAuthorization(ctx *gin.Context)
DeviceAuthorization handles the device authorization request (RFC 8628 §3.1). The client requests a device code and user code for the user to authorize.
func (*OIDCHandler) DeviceConsentGET ¶
func (h *OIDCHandler) DeviceConsentGET(ctx *gin.Context)
DeviceConsentGET renders the consent page for the device code flow (RFC 8628 §3.3). The user is shown which application requests access and which scopes are requested, and can approve or deny the authorization.
func (*OIDCHandler) DeviceConsentPOST ¶
func (h *OIDCHandler) DeviceConsentPOST(ctx *gin.Context)
DeviceConsentPOST handles the user's consent decision for the device code flow. On approval, the device code is authorized and the success page is shown. On denial, the device code is denied and an error page is shown.
func (*OIDCHandler) DeviceVerify ¶
func (h *OIDCHandler) DeviceVerify(ctx *gin.Context)
DeviceVerify handles the user verification of a device code (RFC 8628 §3.3). The user submits the user code along with their credentials to authorize or deny the device.
func (*OIDCHandler) DeviceVerifyFailedPage ¶
func (h *OIDCHandler) DeviceVerifyFailedPage(ctx *gin.Context)
DeviceVerifyFailedPage renders a terminal failure page for processed device codes.
func (*OIDCHandler) DeviceVerifyPage ¶
func (h *OIDCHandler) DeviceVerifyPage(ctx *gin.Context)
DeviceVerifyPage renders the device code verification page (RFC 8628 §3.3). The user visits this page to enter the user code and authenticate.
func (*OIDCHandler) Discovery ¶
func (h *OIDCHandler) Discovery(ctx *gin.Context)
Discovery returns the OIDC discovery document.
func (*OIDCHandler) Introspect ¶
func (h *OIDCHandler) Introspect(ctx *gin.Context)
Introspect handles the OIDC token introspection request.
func (*OIDCHandler) JWKS ¶
func (h *OIDCHandler) JWKS(ctx *gin.Context)
JWKS handles the OIDC JWKS request.
func (*OIDCHandler) Logout ¶
func (h *OIDCHandler) Logout(ctx *gin.Context)
Logout handles the OIDC logout request.
func (*OIDCHandler) Register ¶
func (h *OIDCHandler) Register(router gin.IRouter)
Register registers the OIDC routes.
func (*OIDCHandler) Token ¶
func (h *OIDCHandler) Token(ctx *gin.Context)
Token handles the OIDC token request.
func (*OIDCHandler) UserInfo ¶
func (h *OIDCHandler) UserInfo(ctx *gin.Context)
UserInfo handles the OIDC userinfo request.
type SAMLHandler ¶
type SAMLHandler struct {
// contains filtered or unexported fields
}
SAMLHandler handles SAML 2.0 protocol requests.
func NewSAMLHandler ¶
func NewSAMLHandler(d *deps.Deps, provider samlIdentityProvider) *SAMLHandler
NewSAMLHandler creates a new SAMLHandler.
func (*SAMLHandler) GetServiceProvider ¶
func (h *SAMLHandler) GetServiceProvider(_ *http.Request, serviceProviderID string) (*saml.EntityDescriptor, error)
GetServiceProvider returns the Service Provider metadata for the given entity ID.
func (*SAMLHandler) Metadata ¶
func (h *SAMLHandler) Metadata(ctx *gin.Context)
Metadata returns the SAML IDP metadata.
func (*SAMLHandler) Register ¶
func (h *SAMLHandler) Register(router gin.IRouter)
Register adds SAML routes to the router.
func (*SAMLHandler) SLO ¶
func (h *SAMLHandler) SLO(ctx *gin.Context)
SLO handles the SAML Single Logout request.
func (*SAMLHandler) SSO ¶
func (h *SAMLHandler) SSO(ctx *gin.Context)
SSO handles the SAML Single Sign-On request (Redirect Binding).
type UserBackendData ¶
type UserBackendData struct {
Username string
DisplayName string
UniqueUserID string
HaveTOTP bool
NumRecoveryCodes int
HaveWebAuthn bool
WebAuthnUser *backend.User
AuthState *core.AuthState
}
UserBackendData encapsulates information about a user's MFA status and backend data.
func (*UserBackendData) UsesRemoteWebAuthnAuthority ¶
func (d *UserBackendData) UsesRemoteWebAuthnAuthority() bool
UsesRemoteWebAuthnAuthority reports whether WebAuthn writes must stay authority-owned.
Source Files
¶
- auth_status_bridge.go
- backend_data.go
- flow_controller_factory.go
- flow_notice.go
- frontend.go
- oidc.go
- oidc_authorization_code.go
- oidc_client_credentials.go
- oidc_consent_plan.go
- oidc_consent_scopes.go
- oidc_consent_ttl.go
- oidc_device_code.go
- oidc_flow_context.go
- require_mfa.go
- saml.go
- saml_authn_signature.go
- saml_flow_context.go
- saml_slo_fanout.go
- saml_slo_fanout_state.go
- saml_slo_observability.go
- saml_slo_protocol.go
- saml_slo_response.go
- saml_slo_signature.go