Go API
The public package façade, every Client method, and the exported type groups.
The root signet package is a façade of five files: signet.go (exported aliases),
client.go (Client and methods), config.go, errors.go and doc.go. Implementations
live in private internal/ packages; aliases may point to any of them. Your code imports
only github.com/shakibdshy/signet-auth.
Entry points
| Symbol | Purpose |
|---|---|
New(cfg Config) (*Client, error) | Validates config, applies defaults and builds a ready Client. |
DefaultConfig() Config | Secure baseline configuration. |
DocsHandler() http.Handler | Optional OpenAPI JSON + Scalar viewer; mount it yourself. |
JWKSHandler() http.Handler | Optional JWKS document for asymmetric JWT keys; not mounted by Handler(). |
UserFromContext(ctx context.Context) (*User, bool) | Reads the authenticated User set by RequireAuth/OptionalAuth. |
Client methods
| Method | Purpose |
|---|---|
SignUp(ctx, SignUpInput) (*SignUpResult, error) | Create a User and its credential Account. |
SignIn(ctx, SignInInput) (*SignInResult, error) | Verify a password, rehash if needed, create a Session. |
SendMagicLink(ctx, SendMagicLinkInput) error | Email a single-use magic-link proof. |
VerifyMagicLink(ctx, VerifyMagicLinkInput) (*SignInResult, error) | Consume a magic-link proof and create a Session. |
SendEmailOTP(ctx, SendEmailOTPInput) error | Email a six-digit sign-in code. |
VerifyEmailOTP(ctx, VerifyEmailOTPInput) (*SignInResult, error) | Consume a code and create a Session. |
SignOut(ctx, SignOutInput) error | Revoke the Session named by the token; unknown tokens are a no-op. |
VerifyFreshSession(ctx, string) error | Check that a Session was authenticated within FreshAge. |
RequireFreshSession(http.Handler) http.Handler | Middleware that rejects stale Sessions with 401. |
RequestUserDeletion(ctx, RequestDeleteUserInput) error | Issue a proof to confirm account deletion. |
DeleteUser(ctx, ConfirmDeleteUserInput) error | Consume the proof and remove the User and children. |
RequestEmailChange(ctx, ChangeEmailInput) error | Issue a single-use proof to a new email address. |
VerifyEmailChange(ctx, VerifyEmailChangeInput) error | Consume the proof and commit the new address. |
ChangePassword(ctx, ChangePasswordInput) error | Verify the current password, revoke all Sessions and Tokens, then replace the verifier. |
SendVerification(ctx, SendVerificationInput) error | Issue an email-verification Token. |
VerifyEmail(ctx, VerifyEmailInput) error | Consume a verification Token and mark the User verified. |
SendPasswordReset(ctx, SendPasswordResetInput) error | Issue a password-reset Token. |
ResetPassword(ctx, ResetPasswordInput) error | Consume a reset Token, revoke Sessions and set a new password. |
OAuthStart(ctx, OAuthStartInput) (*OAuthStartResult, error) | Begin an OAuth flow and return the authorization URL. |
OAuthCallback(ctx, OAuthCallbackInput) (*OAuthCallbackResult, error) | Redeem the provider code and return a User or link Token. |
LinkOAuthAccount(ctx, LinkOAuthAccountInput) error | Consume a link Token for an authenticated User. |
ExchangeToken(ctx, TokenInput) (*TokenPair, error) | Exchange credentials or a Refresh token for a TokenPair. |
VerifyAccessToken(ctx, raw string) (*User, error) | Validate an Access token and load its User. |
ListAccounts(ctx, ListAccountsInput) (*ListAccountsResult, error) | List safe Account fields for a User. |
UnlinkAccount(ctx, UnlinkAccountInput) error | Unlink one guarded Account. |
EnableTwoFactor(ctx, EnableTwoFactorInput) (*EnableTwoFactorResult, error) | Start TOTP enrollment. |
VerifyTwoFactor(ctx, VerifyTwoFactorInput) (*SignInResult, error) | Exchange a challenge and code for a Session. |
DisableTwoFactor(ctx, DisableTwoFactorInput) error | Remove Second factor enrollment. |
RegenerateBackupCodes(ctx, RegenerateBackupCodesInput) (*RegenerateBackupCodesResult, error) | Replace all Backup codes. |
SetLastMethodCookie(w, method string) | Write the signed Last sign-in method cookie. |
LastSignInMethod(r *http.Request) string | Read the signed Last sign-in method from a request. |
ClearLastSignInMethod(w) | Expire the Last sign-in method cookie. |
ListSessions(ctx, ListSessionsInput) (*ListSessionsResult, error) | List safe Session fields for a User. |
RevokeSession(ctx, RevokeSessionInput) error | Revoke one Session; unknown IDs are a no-op. |
RevokeAllSessions(ctx, RevokeAllSessionsInput) error | Revoke every Session of a User. |
RequireAuth(next http.Handler) http.Handler | Middleware that requires a valid Session. |
OptionalAuth(next http.Handler) http.Handler | Middleware that attaches a User when one is present. |
Handler() http.Handler | The HTTP endpoint router for mounting under a prefix. |
Exported types
- Models:
User,Account,Session,SessionInfo,Token,OAuthIdentity. - Contracts:
Store,UserStore,AccountStore,SessionStore,TokenStore,Mailer,RateLimiter,Clock,PasswordHasher,EmailTemplates,OAuthProvider. - Configuration:
Config,CookieConfig,SessionConfig,PasswordConfig,JWTConfig,OAuthConfig. - Inputs and results:
SignUpInput,SignUpResult,SignInInput,SignInResult,SignOutInput,RequestDeleteUserInput,ConfirmDeleteUserInput,ChangeEmailInput,VerifyEmailChangeInput,ChangePasswordInput,SendVerificationInput,VerifyEmailInput,SendPasswordResetInput,ResetPasswordInput,TokenInput,TokenPair,OAuthStartInput,OAuthStartResult,OAuthCallbackInput,OAuthCallbackResult,LinkOAuthAccountInput,ListSessionsInput,ListSessionsResult,RevokeSessionInput,RevokeAllSessionsInput,TemplateData,Message. - Helpers:
SystemClock,Argon2idHasher,TokenKind,Version,DefaultTemplates. - Errors: exported sentinels such as
ErrNotFound,ErrInvalidCredentials,ErrTokenInvalidandErrRefreshReuse— see Errors.
Token kinds distinguish the single-use proofs: TokenVerifyEmail, TokenResetPassword,
TokenOAuthLink, TokenRefresh, TokenOAuthState.
Programmatic vs HTTP
Calling a Client method does not round-trip through HTTP — it runs the same internal service
directly with the context.Context you supply. The HTTP endpoints are a separate adapter
over those services. Use whichever fits your application; both enforce the same security
rules and produce the same effects. See HTTP API and the
frontend client for the other surfaces.
Phase 5 methods
Authorization, API keys, organizations and admin management are opt-in. All state lives behind optional application-supplied adapters described in Authorization.
| Method | Purpose |
|---|---|
Authorize(ctx, userID, resource, action) bool | Read-only permission check through the Authorizer. |
AuthorizeIn(ctx, userID, orgID, resource, action) bool | Organization-scoped check through AuthorizeIn. |
SetRoles(ctx, userID, roles) error | Write global roles through the RoleWriter. |
NewMemoryAuthorizer(statements, roles) Authorizer | Build an in-memory Authorizer from role statements and a callback. |
CreateAPIKey(ctx, CreateAPIKeyInput) (*CreateAPIKeyResult, error) | Issue a digest-only key; the raw value is returned once. |
VerifyAPIKey(ctx, raw) (*Principal, error) | Atomically consume one use and return the key's owner and roles. |
ListAPIKeys(ctx, ListAPIKeysInput) (*ListAPIKeysResult, error) | List a User's keys. |
RevokeAPIKey(ctx, RevokeAPIKeyInput) error | Revoke a User's key. |
PrincipalFromContext(ctx) (*Principal, bool) | Read the Principal attached by key middleware. |
CreateOrganization(ctx, CreateOrganizationInput) (*CreateOrganizationResult, error) | Create an Organization. |
ListOrganizations(ctx, ListOrganizationsInput) (*ListOrganizationsResult, error) | List a User's Organizations. |
AddOrganizationMember(ctx, AddOrganizationMemberInput) error | Add a Member with a role. |
ListOrganizationMembers(ctx, orgID, userID, sessionToken) (*ListOrganizationMembersResult, error) | List Members. |
RemoveOrganizationMember(ctx, orgID, userID, actorID, sessionToken) error | Remove a Member. |
SetOrganizationMemberRole(ctx, orgID, userID, role, actorID, sessionToken) error | Change a Member's role. |
SetActiveOrganization(ctx, SetActiveOrganizationInput) error | Verify membership before selecting an Active organization. |
ActiveOrganizationFromRequest(r) *ActiveOrganization | Read the signed Active organization cookie. |
ClearActiveOrganization(w) | Expire the Active organization cookie. |
AdminListUsers(ctx, AdminListUsersInput) (*AdminListUsersResult, error) | List Users for an administrator. |
AdminSetUserRole(ctx, AdminSetUserRoleInput) error | Write global roles for a User. |
BanUser(ctx, BanUserInput) error | Disable a User. |
UnbanUser(ctx, UnbanUserInput) error | Re-enable a User. |
AdminListUserSessions(ctx, actorID, userID, sessionToken) (*ListSessionsResult, error) | List a User's Sessions. |
AdminRevokeUserSession(ctx, actorID, sessionID, sessionToken) error | Revoke one of a User's Sessions. |
ImpersonateUser(ctx, ImpersonateUserInput) (*ImpersonationResult, error) | Start a Store-backed impersonation Session. |
StopImpersonating(ctx, StopImpersonatingInput) (string, error) | Revoke the temp Session and return the original token. |
ImpersonationFromRequest(r) (string, string) | Read the admin ID and original token from the signed cookie. |
SetImpersonationCookie(w, adminID, originalToken) | Write the signed impersonation cookie. |
ClearImpersonationCookie(w) | Expire the impersonation cookie. |
IsImpersonating(r) bool | Report whether a request carries an impersonation cookie. |
AdminActorFromRequest(r, fallback) string | Resolve the administrator ID from the cookie. |
Phase 5 types
Permission, RoleStatements, Authorizer, AuthorizeIn, RoleWriter, APIKey,
APIKeyStore, Principal, CreateAPIKeyInput, CreateAPIKeyResult, ListAPIKeysInput,
ListAPIKeysResult, RevokeAPIKeyInput, Organization, OrganizationStore,
CreateOrganizationInput, CreateOrganizationResult, ListOrganizationsInput,
ListOrganizationsResult, AddOrganizationMemberInput, ListOrganizationMembersInput,
ListOrganizationMembersResult, MemberInfo, ActiveOrganization,
SetActiveOrganizationInput, AdminUserStore, UserInfo, AdminListUsersInput,
AdminListUsersResult, AdminSetUserRoleInput, BanUserInput, UnbanUserInput,
ImpersonateUserInput, ImpersonationResult and StopImpersonatingInput.
Passkey methods
| Method | Purpose |
|---|---|
BeginPasskeyRegistration(ctx, PasskeyRegistrationInput) (*PasskeyCeremonyResult, error) | Start enrollment for a signed-in User. |
FinishPasskeyRegistration(ctx, PasskeyFinishInput) error | Verify attestation and store the credential. |
BeginPasskeySignIn(ctx) (*PasskeyCeremonyResult, error) | Start a discoverable sign-in ceremony. |
FinishPasskeySignIn(ctx, PasskeyFinishSignInInput) (*SignInResult, error) | Verify assertion and create a Session. |
ListPasskeys(ctx, PasskeyListInput) (*PasskeyListResult, error) | List safe credential fields. |
DeletePasskey(ctx, PasskeyDeleteInput) error | Revoke one credential. |
Passkey types
PasskeysConfig, PasskeyStore, PasskeyProtocol, WebAuthnCredential, PasskeyInfo, PasskeyRegistrationInput, PasskeyCeremonyResult, PasskeyFinishInput, PasskeySignInInput, PasskeyFinishSignInInput, PasskeyListInput, PasskeyListResult, PasskeyDeleteInput, TokenPasskeyRegistration and TokenPasskeyAuthentication.
Automatic sign-in
| Method | Purpose |
|---|---|
VerifyEmailAndSignIn(ctx, VerifyEmailInput) (*VerifyEmailAndSignInResult, error) | Verify the email and issue a Session when configured. |
SignUpResult.SessionToken | Additive field carrying the Session issued at Sign-up when configured. |
Authorization server
| Method | Purpose |
|---|---|
OAuthAuthorize(ctx, OAuthAuthorizeInput) (*OAuthAuthorizeResult, error) | Issue an authorization code with PKCE. |
OAuthExchange(ctx, OAuthTokenInput) (*OAuthTokenResult, error) | Exchange a code for tokens. |
OAuthRefresh(ctx, OAuthTokenInput) (*OAuthTokenResult, error) | Rotate a Refresh token. |
BeginDeviceAuthorization(ctx, DeviceAuthorizeInput) (*DeviceAuthorizeResult, error) | Start device authorization. |
ApproveDeviceAuthorization(ctx, DeviceApproveInput) error | Approve a User code. |
ExchangeDeviceAuthorization(ctx, string) (*OAuthTokenResult, error) | Poll for device tokens. |
Types: AuthorizationServerConfig, OAuthClient, OAuthClientStore, DeviceAuthorization, DeviceStore, OAuthScope, OAuthAuthorizeInput, OAuthAuthorizeResult, OAuthTokenInput, OAuthTokenResult, DeviceAuthorizeInput, DeviceAuthorizeResult, DeviceApproveInput.
Organization SSO
| Method | Purpose |
|---|---|
CreateSSOConnection(ctx, CreateSSOConnectionInput) (*SSOConnectionInfo, error) | Store a verified connection. |
ListSSOConnections(ctx, string) ([]*SSOConnectionInfo, error) | List connections. |
DeleteSSOConnection(ctx, string, string) error | Delete a connection. |
StartSSOSignIn(ctx, SSOStartInput) (*SSOStartResult, error) | Begin an SSO ceremony. |
CompleteSSOSignIn(ctx, SSOCallbackInput) (*SSOCallbackResult, error) | Verify and create a Session. |
SAML SSO
| Method | Purpose |
|---|---|
StartSAMLSignIn(ctx, SAMLStartInput) (*SAMLStartResult, error) | Begin an SP-initiated ceremony. |
CompleteSAMLSignIn(ctx, string, *http.Request) (*SAMLACSResult, error) | Validate the assertion and create a Session. |
SCIM provisioning
SCIMHandler() http.Handler exposes the mounted SCIM server; ValidateSCIMToken(token) error checks a bearer token with ErrSCIMUnauthorized on failure. Types: SCIMConfig, SCIMStore, SCIMGroup, SCIMGroupProjector.
Account controls and operations
| Method | Purpose |
|---|---|
UpdateUser(ctx, UpdateUserInput) (*UserInfo, error) | Change safe profile fields. |
SetPassword(ctx, SetPasswordInput) error | Add a credential Account for a User without one. |
VerifyPassword(ctx, VerifyPasswordInput) (bool, error) | Server-only password check. |
QueryAudit(ctx, string, AuditQueryInput) ([]*AuditEvent, error) | Query recorded events. |
Types: WindowLimiter, AuditQueryStore, AuditQueryInput, UpdateUserInput, SetPasswordInput, VerifyPasswordInput.