Skip to Content
Signet

Configuration

Every Config field, its default, and which settings are required.

signet.New(cfg Config) validates the required dependencies, then fills blank fields from DefaultConfig(). Always start from DefaultConfig() — a zero Config{} leaves cookies insecure and is rejected with ErrInsecureConfig.

cfg := signet.DefaultConfig()
cfg.Store = myStore
cfg.Mailer = myMailer
cfg.RateLimiter = myLimiter
cfg.CSRFKey = csrfKey // exactly 32 bytes
cfg.AppURL = "https://app.example.com"
auth, err := signet.New(cfg)

Secure defaults

DefaultConfig() sets Cookie.Secure and Cookie.HttpOnly to true, SameSite=Lax, PathPrefix="/", and Path="/". Do not disable the Insecure* options in production.

Top-level Config

FieldTypeRequired / defaultPurpose
StoreStorerequired — ErrMissingStorePersistence contract. See Storage.
MailerMailerrequired — ErrMissingMailerDelivers verification/reset messages. See Mail.
TrustedProxies[]netip.PrefixemptyProxy CIDRs trusted for X-Forwarded-For rate-limit keys.
RateLimitRulesmap[string]RateLimitRuleemptyPer-endpoint limiter/key overrides; keys must match published endpoint names.
RateLimiterRateLimiterrequired — ErrMissingRateLimiterBoolean gate called with `endpoint+"
PasswordHasherPasswordHasherdefault Argon2idHasher{}Verifier algorithm and rehash policy.
ClockClockdefault SystemClock{}Injected time source for tests and TTLs.
Logger*slog.Loggerdefault slog.Default()Receives structured events and security warnings.
OnSignUpfunc(context.Context, *User)default no-opRedacted hook after sign-up.
OnSignInfunc(context.Context, *User)default no-opRedacted hook after sign-in, including OAuth sign-in.
CookieCookieConfigsee belowSession cookie policy.
SessionSessionConfigsee belowSession lifetimes.
PasswordPasswordConfigsee belowAccepted password lengths.
PathPrefixstringdefault /Mount path for Client.Handler().
InsecureAllowHTTPCookiesbooldefault falsePermits Secure=false or HttpOnly=false; emits a warning.
InsecureDisableCSRFbooldefault falseDisables the CSRF guard; emits a warning.
JWT*JWTConfigdefault nil = cookie sessions onlyBearer access/refresh tokens. See JWT.
RequireVerifiedEmail*booldefault nil = trueBlock sign-in for unverified Users. Set a false pointer to disable.
SendVerificationOnSignUp*booldefault nil = trueIssue a verification Token on sign-up. Set a false pointer to disable.
AppURLstringno default; set for email flowsOrigin used to build email links; PathPrefix is prepended to each link path.
TemplatesEmailTemplatesdefault DefaultTemplatesRenders verification, reset and changed-password messages.
OAuth*OAuthConfigdefault nil = OAuth disabledExternal sign-in providers. See OAuth.
Passwordless*PasswordlessConfigdefault 5-minute TTLs, sign-up allowedMagic-link and email-OTP sign-in. See Passwordless.
Username*UsernameConfigdefault 3–30 chars, lowercasedUsername normalization, validation and reserved names. See Username and accounts.
Accounts*AccountConfigdefault 5-minute fresh windowFreshness required for account unlinking.
TOTPStoreTOTPStorenil = Second factor disabledApplication-supplied store for TOTP enrollment state. See Second factor.
TOTPKey[]byterequired with TOTPStore32-byte key for encrypting TOTP secrets.
TOTP*TOTPConfig6 digits, 30s period, ±1 windowTOTP code parameters and issuer.
BreachCheckerBreachCheckernil = disabledRejects passwords found in a known breach.
CaptchaVerifierCaptchaVerifiernil = disabledVerifies captcha tokens on configured endpoints.
CaptchaEndpoints[]stringsignup, signin, send-password-resetEndpoints that require a captcha token.
AuditSinkAuditSinknil = disabledReceives a security subset of Audit events.
LastSignInMethod*LastSignInMethodConfignil = disabledSigned HttpOnly cookie with 30-day default TTL; requires CSRF keys.
AuthorizerAuthorizernil = all checks denyRead-only roles and permission checks. See Authorization.
AuthorizeInAuthorizeInnil = org checks denyOptional organization-scoped permission checks.
RoleWriterRoleWriternil = role writes deniedPersists global role assignments.
APIKeyStoreAPIKeyStorenil = disabledDigest-only API key persistence. See API keys.
APIKeyProtectedEndpoints[]stringemptyEndpoint names that require an X-API-Key instead of a Session.
OrganizationStoreOrganizationStorenil = disabledOrganizations and memberships. See Organizations.
OrganizationRoles[]stringempty = owner and admin membersMembership roles the built-in organization policy grants member management to. See Organizations.
AdminUserStoreAdminUserStorenil = user listing disabledLists Users for guarded admin management. See Admin management.
Passkeys*PasskeysConfignil = disabledWebAuthn first factor. Requires RPID and RPOrigins. See Passkeys.
AutoSignIn*AutoSignInConfignil = disabledIssue a Session after Sign-up and/or email verification. See Verification and reset.
AuthorizationServer*AuthorizationServerConfignil = disabledIssue OAuth tokens with PKCE and device authorization. Requires JWT. See Authorization server.
SAML connectionsprotocol: "saml" on SSO connectionsopt-inPinned metadata, HTTPS SSO URL and signed assertions. See SAML SSO.
SCIM*SCIMConfignil = disabledProvision Users and Groups from a directory. Requires Store and Token. See SCIM provisioning.
WindowLimiterWindowLimiternil = boolean limiter onlyOptional window-aware rate-limit backend.
AuditQueryStoreAuditQueryStorenil = write-only auditEnables QueryAudit. See Account controls.
CSRFKey[]byteexactly 32 bytes unless JWTOnlyHMAC key for CSRF tokens.
CSRFKeys[][]byteempty = use CSRFKeyOrdered key ring; first signs, all verify. Each key must be 32 bytes.
SessionCacheSessionCachenil = disabledOptional short-lived Session lookup cache; the Store stays authoritative.
AllowedRedirectPatterns[]stringemptyhttps wildcard patterns for OAuth and passwordless redirects.
JWTOnlybooldefault falseAPI-only mode: no session cookies and no CSRF key required.

Hooks receive a redacted User: Email and Name are blanked so callbacks cannot leak personal data into logs. See Security.

Disabling email verification

Both switches are independent *bool fields; nil means the secure default (true):

off := false
cfg.RequireVerifiedEmail = &off     // sign-in no longer checks verification
cfg.SendVerificationOnSignUp = &off // no verification Token is issued

Set both for a fully password-only setup. See Verification and reset.

CookieConfig

FieldTypeDefaultPurpose
Namestringsignet_sessionCookie name, prefixed with __Host- where valid.
DomainstringemptyCookie domain. A non-empty domain suppresses the __Host- prefix.
Pathstring/Cookie path.
SameSitehttp.SameSiteSameSiteLaxModeSameSite attribute.
SecurebooltrueRequire HTTPS.
HttpOnlybooltrueHide from JavaScript.

The __Host- prefix is applied when Secure is true, Path is / and Domain is empty. CSRF cookies are deliberately not HttpOnly so the frontend can copy the token into a header.

SessionConfig

FieldTypeDefaultPurpose
FreshAgetime.Duration0 (disabled)Window since authentication for freshness checks.
IdleTimeouttime.Duration30mExtended on each successful request.
CacheTTLtime.Duration0 = disabledLifetime of an optional SessionCache entry, capped by IdleTimeout.
AbsoluteTimeouttime.Duration24hFixed at Session creation; never extended.

PasswordConfig

FieldTypeDefaultPurpose
MinLengthint8Shortest accepted password.
MaxLengthint128Longest accepted password; bounds hashing work.

JWTConfig

FieldTypeDefault / constraintPurpose
Algorithmstringrequired: HS256, RS256, EdDSASigning algorithm.
Keyanyrequired: []byte, *rsa.PrivateKey, ed25519.PrivateKeySigning key matching the algorithm; legacy single-key form.
Keys[]anyempty = use KeyOrdered key ring; first signs, all verify. All keys must match Algorithm.
AccessTTLtime.Duration15mAccess token lifetime.
RefreshTTLtime.Duration30 * 24hRefresh token lifetime.
IssuerstringoptionalClaim checked on verification.

TokenPair.ExpiresIn reports AccessTTL in seconds.

OAuthConfig

FieldTypeDefault / constraintPurpose
Providers[]OAuthProviderrequired when OAuth is setgoogle.Provider / github.Provider or a custom implementation.
RedirectBaseURLstringrequiredAPI origin used to build the callback URL.
AllowedRedirects[]stringrequiredExact allowlist of post-login destinations.
StateKey[]byteexactly 32 bytesAES-GCM key for OAuth state and link Tokens.

SMTP mailer Config

Import github.com/shakibdshy/signet-auth/mailer/smtp.

FieldTypeDefaultPurpose
HoststringrequiredSMTP host.
Portstring587 / 465 / 25 by TLS modeSMTP port.
UsernamestringemptySMTP username.
PasswordstringemptySMTP password; keep it in secrets, never in source.
FromstringrequiredSender address.
TLSTLSModeStartTLSStartTLS, ImplicitTLS or InsecurePlaintext.
InsecureAllowPlaintextboolfalseRequired to permit plaintext; emits a warning.

TLS minimum is 1.2. See Mail for the full setup.

Token kinds

TokenVerifyEmail, TokenChangeEmail, TokenDeleteUser, TokenResetPassword, TokenOAuthLink, TokenRefresh and TokenOAuthState distinguish the single-use proofs Signet issues. New kinds must be added to the canonical revocation list.

On this page