idp

package
v3.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: GPL-3.0 Imports: 72 Imported by: 0

Documentation

Overview

Package idp contains frontend handlers for IDP browser flows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasePageData

func BasePageData(ctx *gin.Context, cfg config.File, langManager corelang.Manager) gin.H

BasePageData returns the common data for all IDP frontend pages.

func CleanupIDPFlowState

func CleanupIDPFlowState(mgr cookie.Manager)

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

func CleanupMFAState(mgr cookie.Manager)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址