Documentation
¶
Index ¶
- Constants
- Variables
- func AllowedDomains() string
- func BaseURL(ctx *fiber.Ctx) string
- func BreakNewlines(s string) template.HTML
- func ConfigValueBool(key string) bool
- func ConfigValueString(key string) string
- func ConfigValueStringSlice(key string) []string
- func GenerateSecret(n int) (string, error)
- func GenerateSecretString(n int) (string, error)
- func HTTPErrorHandler(c *fiber.Ctx, err error) error
- func LimitReachedHandler(c *fiber.Ctx) error
- func LoadTranslations() error
- func MarkTokenUsed(token, prefix string, claims *Token, storage fiber.Storage)
- func NewToken(username, email, prefix string, storage fiber.Storage) (string, error)
- func NotFoundHandler(c *fiber.Ctx) error
- func PhoneCode(stored string) string
- func PhoneFlag(code string) string
- func PhoneNumber(stored string) string
- func QRCode(otptoken *ipa.OTPToken, realm string) (string, error)
- func RemoteIP(c *fiber.Ctx) string
- func SecureHeaders(c *fiber.Ctx) error
- func SetDefaults()
- func SplitSSHFP(fp string) []string
- func T(key string) string
- func TimeAgo(t time.Time) string
- type AuditEvent
- type AuditHook
- type Emailer
- func (e *Emailer) SendAccountVerifyEmail(user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendEmailChangeConfirmEmail(user *ipa.User, newEmail string, ctx *fiber.Ctx) error
- func (e *Emailer) SendEmailChangedNotification(oldEmail string, user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendGroupDecisionEmail(user *ipa.User, group string, approved bool, reqType string) error
- func (e *Emailer) SendGroupRemovedEmail(user *ipa.User, group string) error
- func (e *Emailer) SendGroupRequestEmail(manager *ipa.User, requester, group, reqType string) error
- func (e *Emailer) SendInviteEmail(email string, ctx *fiber.Ctx) error
- func (e *Emailer) SendMFAChangedEmail(enabled bool, user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendNewLoginEmail(user *ipa.User, browser, os, ip string) error
- func (e *Emailer) SendOTPRecoveryConfirmEmail(user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendOTPRecoveryDecisionEmail(user *ipa.User, approved bool) error
- func (e *Emailer) SendOTPTokenUpdatedEmail(added bool, user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendPasskeyUpdatedEmail(added bool, user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendPasswordChangedEmail(user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendPasswordExpiryReminderEmail(user *ipa.User, days int) error
- func (e *Emailer) SendPasswordResetEmail(user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendSSHKeyUpdatedEmail(added bool, user *ipa.User, ctx *fiber.Ctx) error
- func (e *Emailer) SendUsernameReminderEmail(email string, usernames []string, ctx *fiber.Ctx) error
- func (e *Emailer) SendWelcomeEmail(user *ipa.User, ctx *fiber.Ctx) error
- type FakeTLSTransport
- type GroupRequest
- type Metrics
- type OTPRecoveryRequest
- type PhoneCountry
- type PwPolicy
- type Router
- func (r *Router) AccessTest(c *fiber.Ctx) error
- func (r *Router) AccountCreate(c *fiber.Ctx) error
- func (r *Router) AccountSettings(c *fiber.Ctx) error
- func (r *Router) AccountVerify(c *fiber.Ctx) error
- func (r *Router) AccountVerifyResend(c *fiber.Ctx) error
- func (r *Router) AdminAuditList(c *fiber.Ctx) error
- func (r *Router) AdminOTPRecoveryList(c *fiber.Ctx) error
- func (r *Router) AdminPendingList(c *fiber.Ctx) error
- func (r *Router) AdminUserAction(c *fiber.Ctx) error
- func (r *Router) AdminUserList(c *fiber.Ctx) error
- func (r *Router) AppRevoke(c *fiber.Ctx) error
- func (r *Router) Authenticate(c *fiber.Ctx) error
- func (r *Router) CSRF(c *fiber.Ctx) error
- func (r *Router) Captcha(c *fiber.Ctx) error
- func (r *Router) CheckUser(c *fiber.Ctx) error
- func (r *Router) ConsentGet(c *fiber.Ctx) error
- func (r *Router) EmailChangeConfirm(c *fiber.Ctx) error
- func (r *Router) GroupApprove(c *fiber.Ctx) error
- func (r *Router) GroupDeny(c *fiber.Ctx) error
- func (r *Router) GroupRemoveMember(c *fiber.Ctx) error
- func (r *Router) GroupRequestJoin(c *fiber.Ctx) error
- func (r *Router) GroupRequestLeave(c *fiber.Ctx) error
- func (r *Router) Healthz(c *fiber.Ctx) error
- func (r *Router) HydraError(c *fiber.Ctx) error
- func (r *Router) HydraLogout(c *fiber.Ctx) error
- func (r *Router) Index(c *fiber.Ctx) error
- func (r *Router) InviteAccept(c *fiber.Ctx) error
- func (r *Router) InviteSend(c *fiber.Ctx) error
- func (r *Router) Login(c *fiber.Ctx) error
- func (r *Router) LoginOAuthGet(c *fiber.Ctx) error
- func (r *Router) LoginOAuthPost(username, challenge string, c *fiber.Ctx) error
- func (r *Router) Logo(c *fiber.Ctx) error
- func (r *Router) Logout(c *fiber.Ctx) error
- func (r *Router) Metrics(c *fiber.Ctx) error
- func (r *Router) OTPRecoveryConfirm(c *fiber.Ctx) error
- func (r *Router) OTPRecoveryRequest(c *fiber.Ctx) error
- func (r *Router) OTPTokenAdd(c *fiber.Ctx) error
- func (r *Router) OTPTokenDisable(c *fiber.Ctx) error
- func (r *Router) OTPTokenEnable(c *fiber.Ctx) error
- func (r *Router) OTPTokenList(c *fiber.Ctx) error
- func (r *Router) OTPTokenModal(c *fiber.Ctx) error
- func (r *Router) OTPTokenRemove(c *fiber.Ctx) error
- func (r *Router) OTPTokenVerify(c *fiber.Ctx) error
- func (r *Router) PasskeyBegin(c *fiber.Ctx) error
- func (r *Router) PasskeyFinish(c *fiber.Ctx) error
- func (r *Router) PasskeyRemove(c *fiber.Ctx) error
- func (r *Router) PasswordChange(c *fiber.Ctx) error
- func (r *Router) PasswordExpired(c *fiber.Ctx) error
- func (r *Router) PasswordForgot(c *fiber.Ctx) error
- func (r *Router) PasswordReset(c *fiber.Ctx) error
- func (r *Router) RequireAdmin(c *fiber.Ctx) error
- func (r *Router) RequireHTMX(c *fiber.Ctx) error
- func (r *Router) RequireLogin(c *fiber.Ctx) error
- func (r *Router) RequireMFA(c *fiber.Ctx) error
- func (r *Router) RequireNoLogin(c *fiber.Ctx) error
- func (r *Router) RequireOTPSelfService(c *fiber.Ctx) error
- func (r *Router) SSHKeyAdd(c *fiber.Ctx) error
- func (r *Router) SSHKeyList(c *fiber.Ctx) error
- func (r *Router) SSHKeyModal(c *fiber.Ctx) error
- func (r *Router) SSHKeyRemove(c *fiber.Ctx) error
- func (r *Router) SecurityList(c *fiber.Ctx) error
- func (r *Router) SessionRevoke(c *fiber.Ctx) error
- func (r *Router) SessionRevokeOthers(c *fiber.Ctx) error
- func (r *Router) SetupRoutes(app *fiber.App)
- func (r *Router) StartExpiryReminders()
- func (r *Router) Styles(c *fiber.Ctx) error
- func (r *Router) SubidGenerate(c *fiber.Ctx) error
- func (r *Router) TwoFactorDisable(c *fiber.Ctx) error
- func (r *Router) TwoFactorEnable(c *fiber.Ctx) error
- func (r *Router) UsernameForgot(c *fiber.Ctx) error
- type Server
- type SlackNotifier
- type TemplateRenderer
- type Token
- type UserSession
Constants ¶
const ( SessionKeyAuthenticated = "authenticated" SessionKeySID = "sid" SessionKeyUsername = "user" SessionKeyCSRF = "csrf" ContextKeyUser = "user" ContextKeyUsername = "username" ContextKeyIPAClient = "ipa" UserCategoryUnverified = "mokey-user-unverified" UserCategoryPending = "mokey-user-pending" TokenAccountVerify = "verify" TokenPasswordReset = "reset" TokenEmailChange = "emailchange" TokenInvite = "invite" TokenOTPRecovery = "otprecovery" TokenUsedPrefix = "used-" TokenIssuedPrefix = "issued-" SessionKeyLoginTime = "login_time" PasswordChangedPrefix = "pwchanged-" )
const (
DefaultPort = 80
)
const SessionKeyWebAuthn = "webauthn_registration"
Variables ¶
var ( ErrDomainNotAllowed = errors.New("Email domain not allowed") ErrInvalidUsername = errors.New("Username is invalid. May only include letters, numbers, _, -, .") )
var Version = "dev"
Functions ¶
func AllowedDomains ¶
func AllowedDomains() string
func BreakNewlines ¶
func ConfigValueBool ¶
func ConfigValueString ¶
func ConfigValueStringSlice ¶
func GenerateSecret ¶
func GenerateSecretString ¶
func LimitReachedHandler ¶
func LoadTranslations ¶
func LoadTranslations() error
LoadTranslations loads the embedded translation files and any additional .toml files from site.translations_dir. A file named <lang>.toml defines (or fully replaces) the language <lang>.
func MarkTokenUsed ¶
MarkTokenUsed runs after the token's action has taken effect, so a storage failure cannot be rolled back: it is logged, and the token stays valid until it expires
func NotFoundHandler ¶
func PhoneCode ¶
PhoneCode and PhoneNumber feed the two halves of the phone fields back into the form on render
func PhoneNumber ¶
func RemoteIP ¶
RemoteIP returns the client address used for rate limiting and audit logging. X-Forwarded-For is only consulted when the direct peer is a configured trusted proxy (server.trusted_proxies), and entries are walked right to left skipping further trusted proxies — the leftmost values are client-supplied and forgeable.
func SecureHeaders ¶
func SetDefaults ¶
func SetDefaults()
func SplitSSHFP ¶
Types ¶
type AuditEvent ¶
type AuditHook ¶
type AuditHook struct {
// contains filtered or unexported fields
}
func NewAuditHook ¶
type Emailer ¶
type Emailer struct {
// contains filtered or unexported fields
}
func (*Emailer) SendAccountVerifyEmail ¶
func (*Emailer) SendEmailChangeConfirmEmail ¶
func (e *Emailer) SendEmailChangeConfirmEmail(user *ipa.User, newEmail string, ctx *fiber.Ctx) error
SendEmailChangeConfirmEmail sends a confirmation link to the NEW email address. The change is only applied after the link is visited.
func (*Emailer) SendEmailChangedNotification ¶
func (e *Emailer) SendEmailChangedNotification(oldEmail string, user *ipa.User, ctx *fiber.Ctx) error
SendEmailChangedNotification notifies the OLD address that the account email was changed.
func (*Emailer) SendGroupDecisionEmail ¶
func (e *Emailer) SendGroupDecisionEmail(user *ipa.User, group string, approved bool, reqType string) error
SendGroupDecisionEmail notifies the requester that a sponsor approved or denied their join or leave request. Called synchronously from GroupApprove/GroupDeny in the request path with a nil ctx, so the base URL comes from config rather than the request — mirrors SendNewLoginEmail's nil-ctx mechanism.
func (*Emailer) SendGroupRemovedEmail ¶
SendGroupRemovedEmail notifies a member that a sponsor removed them from a group directly (not via a leave request they initiated).
func (*Emailer) SendGroupRequestEmail ¶
SendGroupRequestEmail notifies a group sponsor about a pending join or leave request. Called from a goroutine after the handler returns — no request context, mirrors SendNewLoginEmail.
func (*Emailer) SendInviteEmail ¶
SendInviteEmail sends an account invitation to an email address. The recipient completes their profile via the /auth/invite/:token link.
func (*Emailer) SendMFAChangedEmail ¶
func (*Emailer) SendNewLoginEmail ¶
SendNewLoginEmail notifies about a fresh sign-in. Called from a goroutine after the login response — no request context.
func (*Emailer) SendOTPRecoveryConfirmEmail ¶
SendOTPRecoveryConfirmEmail sends the confirm-before-queue link for an OTP lockout recovery request
func (*Emailer) SendOTPRecoveryDecisionEmail ¶
SendOTPRecoveryDecisionEmail notifies the requester that an admin approved or denied their OTP recovery request. Called synchronously from AdminUserAction in the request path with a nil ctx, so the base URL comes from config rather than the request — mirrors SendGroupDecisionEmail.
func (*Emailer) SendOTPTokenUpdatedEmail ¶
func (*Emailer) SendPasskeyUpdatedEmail ¶
func (*Emailer) SendPasswordChangedEmail ¶
func (*Emailer) SendPasswordExpiryReminderEmail ¶
SendPasswordExpiryReminderEmail warns a user their password expires in the given number of days. Sent from the background sweep — no request context.
func (*Emailer) SendPasswordResetEmail ¶
func (*Emailer) SendSSHKeyUpdatedEmail ¶
func (*Emailer) SendUsernameReminderEmail ¶
SendUsernameReminderEmail mails the username(s) associated with an address. The recipient is identified only by email — no account context is leaked in the delivery metadata.
type FakeTLSTransport ¶
type FakeTLSTransport struct {
T http.RoundTripper
}
type GroupRequest ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics() *Metrics
NewMetrics returns the process-wide metrics instance. Counters register with the global prometheus registry, which panics on duplicate registration — so this must be a singleton.
type OTPRecoveryRequest ¶
type PhoneCountry ¶
type PhoneCountry struct {
Name string
Alpha2 string
Code string // ITU-T E.164 dial code, digits only
Flag string // Unicode regional-indicator pair
}
PhoneCountry is one entry of the country-code picker.
func PhoneCountries ¶
func PhoneCountries() []PhoneCountry
PhoneCountries feeds the country-code picker.
type PwPolicy ¶
type PwPolicy struct {
MinLength int
MinClasses int
HistorySize int
MaxLifeDays int // pwpolicy_show reports max lifetime in days
MinLifeHours int // ...and min lifetime in hours
MaxFailure int
}
PwPolicy is the password policy in effect for a user (pwpolicy_show). Zero values mean the attribute is unset in FreeIPA.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) AccessTest ¶
AccessTest runs FreeIPA's hbactest for the SESSION user against a host/service from the form. The username never comes from the form — users can only simulate their own access.
func (*Router) AdminOTPRecoveryList ¶
AdminOTPRecoveryList renders the OTP recovery queue for admin review. Always visible (unlike the pending-signup queue, which is gated by accounts.require_admin_verify).
func (*Router) AdminPendingList ¶
AdminPendingList renders signups that confirmed their email and now wait for admin approval (require_admin_verify)
func (*Router) EmailChangeConfirm ¶
EmailChangeConfirm applies a pending email change. GET renders a confirmation page, POST performs the change.
func (*Router) GroupRemoveMember ¶
GroupRemoveMember lets a sponsor remove a member directly, independent of the leave-request queue — the sponsor already holds standing authority over the group, the same authority Approve exercises.
func (*Router) GroupRequestJoin ¶
GroupRequestJoin queues a join request for a managed group and notifies its sponsors
func (*Router) GroupRequestLeave ¶
GroupRequestLeave queues a leave request for a group the user belongs to and notifies its sponsors. Membership can only be mutated by a sponsor's session (see groupAddMember), so leaving goes through the same approval queue as joining rather than executing instantly.
func (*Router) Healthz ¶
Healthz is an unauthenticated health check endpoint. It verifies the session storage backend and FreeIPA are reachable. Registered before the CSRF middleware so probes don't create sessions.
func (*Router) HydraLogout ¶
HydraLogout implements the Hydra OIDC logout flow. Hydra redirects the user here with a logout_challenge; we destroy the local session, accept the challenge, and redirect the user back (e.g. to the client's post_logout_redirect_uri). See https://www.ory.sh/docs/hydra/concepts/logout
func (*Router) InviteAccept ¶
InviteAccept lets an invited user complete their own account. The token proves ownership of the invited email address, so the account is created enabled with no further email verification.
func (*Router) InviteSend ¶
InviteSend handles the admin invite form. An invite token is emailed to the address; the invited user completes their own profile via InviteAccept. Works regardless of accounts.enable_signup.
func (*Router) LoginOAuthPost ¶
func (*Router) OTPRecoveryConfirm ¶
OTPRecoveryConfirm queues the recovery request after the emailed link is confirmed — mailbox possession is the identity proof
func (*Router) OTPRecoveryRequest ¶
OTPRecoveryRequest renders and handles the "Lost OTP token?" form. Every POST outcome renders the same success page — unknown, blocked, and non-OTP accounts are indistinguishable from a real request.
func (*Router) RequireOTPSelfService ¶
RequireOTPSelfService blocks OTP mutations for read-only users. The buttons are hidden in the UI, but enforcement lives here.
func (*Router) SessionRevoke ¶
SessionRevoke handles per-device revocation from the security page
func (*Router) SessionRevokeOthers ¶
SessionRevokeOthers signs the user out everywhere except this device
func (*Router) SetupRoutes ¶
func (*Router) StartExpiryReminders ¶
func (r *Router) StartExpiryReminders()
StartExpiryReminders launches the background sweep when reminders are configured. Runs for the lifetime of the process.
func (*Router) SubidGenerate ¶
SubidGenerate allocates the subordinate id range for the logged-in user and re-renders the subid card. Generation is one-shot per user; a duplicate error just renders the existing range.
type Server ¶
type SlackNotifier ¶
type SlackNotifier struct {
// contains filtered or unexported fields
}
func NewSlackNotifier ¶
func NewSlackNotifier() *SlackNotifier
func (*SlackNotifier) SendSlackMessage ¶
func (s *SlackNotifier) SendSlackMessage(email, message string) error
type TemplateRenderer ¶
type TemplateRenderer struct {
// contains filtered or unexported fields
}
func NewTemplateRenderer ¶
func NewTemplateRenderer() (*TemplateRenderer, error)
func (*TemplateRenderer) Load ¶
func (t *TemplateRenderer) Load() error
Source Files
¶
- access.go
- account.go
- admin.go
- audit.go
- auth.go
- captcha.go
- const.go
- csrf.go
- email.go
- expiry.go
- group_requests.go
- groups.go
- health.go
- hydra.go
- ipa_access.go
- ipa_group.go
- ipa_passkey.go
- ipa_stageuser.go
- ipa_subid.go
- ipaclient.go
- lockout.go
- metrics.go
- middleware.go
- otp.go
- otprecovery.go
- passkey.go
- password.go
- phone.go
- qrcode.go
- router.go
- security.go
- server.go
- session.go
- sessions.go
- slack.go
- sshpubkey.go
- subid.go
- template.go
- tls.go
- token.go
- translations.go
- usernames.go