Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- func InjectAPIKeyService(container forge.Container) (*apikey.Service, error)
- func InjectAppService(container forge.Container) (*app.ServiceImpl, error)
- func InjectAuditService(container forge.Container) (*audit.Service, error)
- func InjectAuthService(container forge.Container) (auth.ServiceInterface, error)
- func InjectDatabase(container forge.Container) (*bun.DB, error)
- func InjectDeviceService(container forge.Container) (*device.Service, error)
- func InjectHookRegistry(container forge.Container) (*hooks.HookRegistry, error)
- func InjectJWTService(container forge.Container) (*jwt.Service, error)
- func InjectNotificationService(container forge.Container) (*notification.Service, error)
- func InjectPluginRegistry(container forge.Container) (plugins.PluginRegistry, error)
- func InjectRBACService(container forge.Container) (*rbac.Service, error)
- func InjectRateLimitService(container forge.Container) (*ratelimit.Service, error)
- func InjectSecurityService(container forge.Container) (*security.Service, error)
- func InjectSessionService(container forge.Container) (session.ServiceInterface, error)
- func InjectUserService(container forge.Container) (user.ServiceInterface, error)
- func InjectWebhookService(container forge.Container) (*webhook.Service, error)
- func ResolveAPIKeyService(container forge.Container) (*apikey.Service, error)
- func ResolveAppService(container forge.Container) (*app.ServiceImpl, error)
- func ResolveAuditService(container forge.Container) (*audit.Service, error)
- func ResolveAuthService(container forge.Container) (auth.ServiceInterface, error)
- func ResolveDatabase(container forge.Container) (*bun.DB, error)
- func ResolveDatabaseManager(container forge.Container) (*forgedb.DatabaseManager, error)
- func ResolveDeviceService(container forge.Container) (*device.Service, error)
- func ResolveHookRegistry(container forge.Container) (*hooks.HookRegistry, error)
- func ResolveJWTService(container forge.Container) (*jwt.Service, error)
- func ResolveNotificationService(container forge.Container) (*notification.Service, error)
- func ResolvePluginRegistry(container forge.Container) (*plugins.Registry, error)
- func ResolveRBACService(container forge.Container) (*rbac.Service, error)
- func ResolveRateLimitService(container forge.Container) (*ratelimit.Service, error)
- func ResolveSecurityService(container forge.Container) (*security.Service, error)
- func ResolveSessionService(container forge.Container) (session.ServiceInterface, error)
- func ResolveUserService(container forge.Container) (user.ServiceInterface, error)
- func ResolveWebhookService(container forge.Container) (*webhook.Service, error)
- type APIKey
- type APIKeyConfig
- type APIKeyService
- type AfterMemberAddHook
- type AfterOrganizationCreateHook
- type AfterSessionCreateHook
- type AfterSignInHook
- type AfterSignOutHook
- type AfterSignUpHook
- type App
- type AppConfig
- type AppRepository
- type AppService
- type AuditService
- type Auth
- func (a *Auth) AuthMiddleware() forge.Middleware
- func (a *Auth) Authenticate() forge.Middleware
- func (a *Auth) AuthenticateOptional() forge.Middleware
- func (a *Auth) GetBasePath() string
- func (a *Auth) GetConfig() Config
- func (a *Auth) GetDB() *bun.DB
- func (a *Auth) GetDefaultApp(ctx context.Context) (*app.App, error)
- func (a *Auth) GetDefaultEnvironment(ctx context.Context, appID xid.ID) (*env.Environment, error)
- func (a *Auth) GetForgeApp() forge.App
- func (a *Auth) GetGlobalGroupRoutesOptions() []forge.GroupOption
- func (a *Auth) GetGlobalRoutesOptions() []forge.RouteOption
- func (a *Auth) GetHookRegistry() *hooks.HookRegistry
- func (a *Auth) GetPluginRegistry() plugins.PluginRegistry
- func (a *Auth) GetServiceRegistry() *registry.ServiceRegistry
- func (a *Auth) Hooks() *hooks.HookRegistry
- func (a *Auth) Initialize(ctx context.Context) error
- func (a *Auth) IsPluginEnabled(pluginID string) bool
- func (a *Auth) Logger() forge.Logger
- func (a *Auth) Mount(router forge.Router, basePath string) error
- func (a *Auth) RegisterAuthStrategy(strategy middleware.AuthStrategy) error
- func (a *Auth) RegisterPlugin(plugin plugins.Plugin) error
- func (a *Auth) Repository() repo.Repository
- func (a *Auth) RequireAPIKey() forge.Middleware
- func (a *Auth) RequireAdmin() forge.Middleware
- func (a *Auth) RequireAllPermissions(permissions ...string) forge.Middleware
- func (a *Auth) RequireAllScopes(scopes ...string) forge.Middleware
- func (a *Auth) RequireAnyPermission(permissions ...string) forge.Middleware
- func (a *Auth) RequireAnyScope(scopes ...string) forge.Middleware
- func (a *Auth) RequireAuth() forge.Middleware
- func (a *Auth) RequireCanAccess(action, resource string) forge.Middleware
- func (a *Auth) RequirePublishableKey() forge.Middleware
- func (a *Auth) RequireRBACPermission(action, resource string) forge.Middleware
- func (a *Auth) RequireScope(scope string) forge.Middleware
- func (a *Auth) RequireSecretKey() forge.Middleware
- func (a *Auth) RequireUser() forge.Middleware
- func (a *Auth) ServiceRegistry() *registry.ServiceRegistry
- type AuthConfig
- type AuthContext
- type AuthMethod
- type AuthMiddleware
- type AuthMiddlewareConfig
- type AuthResponse
- type AuthService
- type Config
- type ContextConfig
- type ContextResolution
- type ContextSource
- type CreateAPIKeyRequest
- type CreateAppRequest
- type CreateJWTKeyRequest
- type CreateSessionRequest
- type CreateTeamRequest
- type CreateUserRequest
- type CreateWebhookRequest
- type Device
- type DeviceService
- type Environment
- type EnvironmentRepository
- type GenerateTokenRequest
- type GeoIPProvider
- type HookRegistry
- type Invitation
- type InvitationRepository
- type InvitationStatus
- type InviteMemberRequest
- type JWTConfig
- type JWTKey
- type JWTService
- type Member
- type MemberRepository
- type MemberRole
- type MemberStatus
- type Notification
- type NotificationConfig
- type NotificationService
- type NotificationTemplate
- type Option
- func WithAuthMiddlewareConfig(config middleware.AuthMiddlewareConfig) Option
- func WithBasePath(path string) Option
- func WithCORSEnabled(enabled bool) Option
- func WithDatabase(db any) Option
- func WithDatabaseFromForge() Option
- func WithDatabaseManager(manager *forgedb.DatabaseManager, dbName ...string) Option
- func WithDatabaseSchema(schema string) Option
- func WithForgeApp(app forge.App) Option
- func WithGeoIPProvider(provider sec.GeoIPProvider) Option
- func WithGlobalCookieConfig(config session.CookieConfig) Option
- func WithGlobalGroupRoutesOptions(opts ...forge.GroupOption) Option
- func WithGlobalRoutesOptions(opts ...forge.RouteOption) Option
- func WithMinPasswordLength(length int) Option
- func WithPasswordPolicy(policy string) Option
- func WithPasswordRequirements(reqs validator.PasswordRequirements) Option
- func WithRBACEnforcement(enabled bool) Option
- func WithRateLimitConfig(cfg rl.Config) Option
- func WithRateLimitStorage(storage rl.Storage) Option
- func WithRefreshTokens(enabled bool, accessTTL, refreshTTL time.Duration) Option
- func WithRequireEmailVerification(require bool) Option
- func WithSecret(secret string) Option
- func WithSecurityConfig(cfg sec.Config) Option
- func WithSessionConfig(config session.Config) Option
- func WithSessionCookieEnabled(enabled bool) Option
- func WithSessionCookieMaxAge(seconds int) Option
- func WithSessionCookieName(name string) Option
- func WithSessionTTL(defaultTTL, rememberTTL time.Duration) Option
- func WithSlidingWindowSessions(enabled bool, renewalThreshold ...time.Duration) Option
- func WithTrustedOrigins(origins []string) Option
- func WithUserConfig(config user.Config) Option
- type Organization
- type OrganizationConfig
- type OrganizationService
- type Permission
- type Plugin
- type PluginDependencies
- type PluginRegistry
- type Policy
- type RBACService
- type RateLimitConfig
- type RateLimitService
- type RateLimitStorage
- type Role
- type RoleRegistry
- type SchemaAPIKey
- type SchemaApp
- type SchemaDevice
- type SchemaInvitation
- type SchemaJWTKey
- type SchemaMember
- type SchemaNotification
- type SchemaRole
- type SchemaSession
- type SchemaTeam
- type SchemaTeamMember
- type SchemaUser
- type SchemaUserRole
- type SchemaWebhook
- type SecurityConfig
- type SecurityService
- type ServiceRegistry
- type Session
- type SessionConfig
- type SessionService
- type SignInRequest
- type SignUpRequest
- type Team
- type TeamMember
- type TeamRepository
- type UpdateAppRequest
- type UpdateMemberRequest
- type UpdateTeamRequest
- type UpdateUserRequest
- type User
- type UserConfig
- type UserService
- type Webhook
- type WebhookConfig
- type WebhookDelivery
- type WebhookEvent
- type WebhookService
Constants ΒΆ
const ( ServiceDatabase = "authsome.database" ServiceUser = "authsome.user" ServiceSession = "authsome.session" ServiceAuth = "authsome.auth" ServiceApp = "authsome.app" ServiceOrganization = "authsome.organization" ServiceRateLimit = "authsome.ratelimit" ServiceDevice = "authsome.device" ServiceSecurity = "authsome.security" ServiceAudit = "authsome.audit" ServiceRBAC = "authsome.rbac" ServiceWebhook = "authsome.webhook" ServiceNotification = "authsome.notification" ServiceJWT = "authsome.jwt" ServiceAPIKey = "authsome.apikey" ServiceHookRegistry = "authsome.hooks" ServicePluginRegistry = "authsome.plugins" )
ServiceImpl name constants for DI container.
const ( // AuthMethodNone indicates no authentication. AuthMethodNone = contexts.AuthMethodNone // AuthMethodSession indicates session-based authentication. AuthMethodSession = contexts.AuthMethodSession // AuthMethodAPIKey indicates API key authentication. AuthMethodAPIKey = contexts.AuthMethodAPIKey // AuthMethodBoth indicates both session and API key authentication. AuthMethodBoth = contexts.AuthMethodBoth )
AuthMethod constants.
const ( // MemberRoleOwner is the owner member role. MemberRoleOwner = app.MemberRoleOwner MemberRoleAdmin = app.MemberRoleAdmin MemberRoleMember = app.MemberRoleMember // MemberStatusActive is the active member status. MemberStatusActive = app.MemberStatusActive MemberStatusSuspended = app.MemberStatusSuspended MemberStatusPending = app.MemberStatusPending // InvitationStatusPending is the pending invitation status. InvitationStatusPending = app.InvitationStatusPending InvitationStatusAccepted = app.InvitationStatusAccepted InvitationStatusExpired = app.InvitationStatusExpired InvitationStatusCancelled = app.InvitationStatusCancelled InvitationStatusDeclined = app.InvitationStatusDeclined // RoleOwner is a backward compatibility alias for MemberRoleOwner. RoleOwner = app.MemberRoleOwner RoleAdmin = app.MemberRoleAdmin RoleMember = app.MemberRoleMember StatusActive = app.MemberStatusActive StatusSuspended = app.MemberStatusSuspended StatusPending = app.MemberStatusPending )
Enum constants exported for convenience.
const ( // ContextSourceNone indicates no context source. ContextSourceNone = middleware.ContextSourceNone // ContextSourceExisting indicates context already exists in request. ContextSourceExisting = middleware.ContextSourceExisting // ContextSourceHeader indicates context from HTTP header. ContextSourceHeader = middleware.ContextSourceHeader // ContextSourceAPIKey indicates context from verified API key. ContextSourceAPIKey = middleware.ContextSourceAPIKey // ContextSourceDefault indicates context from default config. ContextSourceDefault = middleware.ContextSourceDefault // ContextSourceAutoDetect indicates context from AuthSome config. ContextSourceAutoDetect = middleware.ContextSourceAutoDetect )
Context Source Constants.
Variables ΒΆ
var ( // GetAppID gets the app ID from context. GetAppID = contexts.GetAppID SetAppID = contexts.SetAppID RequireAppID = contexts.RequireAppID // GetEnvironmentID gets the environment ID from context. GetEnvironmentID = contexts.GetEnvironmentID SetEnvironmentID = contexts.SetEnvironmentID RequireEnvironmentID = contexts.RequireEnvironmentID // GetOrganizationID gets the organization ID from context. GetOrganizationID = contexts.GetOrganizationID SetOrganizationID = contexts.SetOrganizationID RequireOrganizationID = contexts.RequireOrganizationID // GetUserID gets the user ID from context. GetUserID = contexts.GetUserID SetUserID = contexts.SetUserID RequireUserID = contexts.RequireUserID // WithAppAndOrganization creates a context with app and organization IDs. WithAppAndOrganization = contexts.WithAppAndOrganization WithAppAndUser = contexts.WithAppAndUser WithAppEnvironmentAndOrganization = contexts.WithAppEnvironmentAndOrganization WithAll = contexts.WithAll // SetAuthContext sets the auth context. SetAuthContext = contexts.SetAuthContext GetAuthContext = contexts.GetAuthContext RequireAuthContext = contexts.RequireAuthContext RequireUser = contexts.RequireUser RequireAPIKey = contexts.RequireAPIKey GetUser = contexts.GetUser GetAPIKey = contexts.GetAPIKey GetSession = contexts.GetSession )
Contexts Functions.
var ( // ErrAppContextRequired is returned when app context is required but not found. ErrAppContextRequired = contexts.ErrAppContextRequired // ErrEnvironmentContextRequired is returned when environment context is required but not found. ErrEnvironmentContextRequired = contexts.ErrEnvironmentContextRequired // ErrOrganizationContextRequired is returned when organization context is required but not found. ErrOrganizationContextRequired = contexts.ErrOrganizationContextRequired // ErrUserContextRequired is returned when user context is required but not found. ErrUserContextRequired = contexts.ErrUserContextRequired // ErrAuthContextRequired is returned when auth context is required but not found. ErrAuthContextRequired = contexts.ErrAuthContextRequired // ErrUserAuthRequired is returned when user authentication is required. ErrUserAuthRequired = contexts.ErrUserAuthRequired // ErrAPIKeyRequired is returned when API key authentication is required. ErrAPIKeyRequired = contexts.ErrAPIKeyRequired // ErrInsufficientScope is returned when API key lacks required scope. ErrInsufficientScope = contexts.ErrInsufficientScope // ErrInsufficientPermission is returned when lacking required RBAC permission. ErrInsufficientPermission = contexts.ErrInsufficientPermission )
Context Errors.
var ( // NewAuthMiddleware creates a new authentication middleware. NewAuthMiddleware = middleware.NewAuthMiddleware // DefaultContextConfig returns a ContextConfig with sensible defaults. DefaultContextConfig = middleware.DefaultContextConfig )
Middleware Config Functions.
var ( // RegisterDefaultPlatformRoles registers default platform roles. RegisterDefaultPlatformRoles = rbac.RegisterDefaultPlatformRoles )
RBAC Functions.
Functions ΒΆ
func InjectAPIKeyService ΒΆ added in v0.0.15
InjectAPIKeyService resolves the API key service using type-based injection.
func InjectAppService ΒΆ added in v0.0.15
func InjectAppService(container forge.Container) (*app.ServiceImpl, error)
InjectAppService resolves the app service using type-based injection.
func InjectAuditService ΒΆ added in v0.0.15
InjectAuditService resolves the audit service using type-based injection.
func InjectAuthService ΒΆ added in v0.0.15
func InjectAuthService(container forge.Container) (auth.ServiceInterface, error)
InjectAuthService resolves the auth service using type-based injection.
func InjectDatabase ΒΆ added in v0.0.15
InjectDatabase resolves the database using type-based injection.
func InjectDeviceService ΒΆ added in v0.0.15
InjectDeviceService resolves the device service using type-based injection.
func InjectHookRegistry ΒΆ added in v0.0.15
func InjectHookRegistry(container forge.Container) (*hooks.HookRegistry, error)
InjectHookRegistry resolves the hook registry using type-based injection.
func InjectJWTService ΒΆ added in v0.0.15
InjectJWTService resolves the JWT service using type-based injection.
func InjectNotificationService ΒΆ added in v0.0.15
func InjectNotificationService(container forge.Container) (*notification.Service, error)
InjectNotificationService resolves the notification service using type-based injection.
func InjectPluginRegistry ΒΆ added in v0.0.15
func InjectPluginRegistry(container forge.Container) (plugins.PluginRegistry, error)
InjectPluginRegistry resolves the plugin registry using type-based injection.
func InjectRBACService ΒΆ added in v0.0.15
InjectRBACService resolves the RBAC service using type-based injection.
func InjectRateLimitService ΒΆ added in v0.0.15
InjectRateLimitService resolves the rate limit service using type-based injection.
func InjectSecurityService ΒΆ added in v0.0.15
InjectSecurityService resolves the security service using type-based injection.
func InjectSessionService ΒΆ added in v0.0.15
func InjectSessionService(container forge.Container) (session.ServiceInterface, error)
InjectSessionService resolves the session service using type-based injection.
func InjectUserService ΒΆ added in v0.0.15
func InjectUserService(container forge.Container) (user.ServiceInterface, error)
InjectUserService resolves the user service using type-based injection.
func InjectWebhookService ΒΆ added in v0.0.15
InjectWebhookService resolves the webhook service using type-based injection.
func ResolveAPIKeyService ΒΆ
ResolveAPIKeyService resolves the API key service from the container.
func ResolveAppService ΒΆ
func ResolveAppService(container forge.Container) (*app.ServiceImpl, error)
ResolveAppService resolves the app service from the container.
func ResolveAuditService ΒΆ
ResolveAuditService resolves the audit service from the container.
func ResolveAuthService ΒΆ
func ResolveAuthService(container forge.Container) (auth.ServiceInterface, error)
ResolveAuthService resolves the auth service from the container.
func ResolveDatabase ΒΆ
ResolveDatabase resolves the database from the container First tries AuthSome's registered database, then falls back to Forge's database extension.
func ResolveDatabaseManager ΒΆ
func ResolveDatabaseManager(container forge.Container) (*forgedb.DatabaseManager, error)
ResolveDatabaseManager resolves Forge's DatabaseManager from the container This is useful for plugins that need access to multiple databases.
func ResolveDeviceService ΒΆ
ResolveDeviceService resolves the device service from the container.
func ResolveHookRegistry ΒΆ
func ResolveHookRegistry(container forge.Container) (*hooks.HookRegistry, error)
ResolveHookRegistry resolves the hook registry from the container.
func ResolveJWTService ΒΆ
ResolveJWTService resolves the JWT service from the container.
func ResolveNotificationService ΒΆ
func ResolveNotificationService(container forge.Container) (*notification.Service, error)
ResolveNotificationService resolves the notification service from the container.
func ResolvePluginRegistry ΒΆ
ResolvePluginRegistry resolves the plugin registry from the container.
func ResolveRBACService ΒΆ
ResolveRBACService resolves the RBAC service from the container.
func ResolveRateLimitService ΒΆ
ResolveRateLimitService resolves the rate limit service from the container.
func ResolveSecurityService ΒΆ
ResolveSecurityService resolves the security service from the container.
func ResolveSessionService ΒΆ
func ResolveSessionService(container forge.Container) (session.ServiceInterface, error)
ResolveSessionService resolves the session service from the container.
func ResolveUserService ΒΆ
func ResolveUserService(container forge.Container) (user.ServiceInterface, error)
ResolveUserService resolves the user service from the container.
Types ΒΆ
type APIKeyConfig ΒΆ
APIKeyConfig holds API key service configuration.
type AfterMemberAddHook ΒΆ
type AfterMemberAddHook = hooks.AfterMemberAddHook
AfterMemberAddHook registers an organization lifecycle hook.
type AfterOrganizationCreateHook ΒΆ
type AfterOrganizationCreateHook = hooks.AfterOrganizationCreateHook
AfterOrganizationCreateHook registers a user lifecycle hook.
type AfterSessionCreateHook ΒΆ
type AfterSessionCreateHook = hooks.AfterSessionCreateHook
AfterSessionCreateHook registers a session lifecycle hook.
type AfterSignInHook ΒΆ
type AfterSignInHook = hooks.AfterSignInHook
AfterSignInHook registers an authentication lifecycle hook.
type AfterSignOutHook ΒΆ
type AfterSignOutHook = hooks.AfterSignOutHook
AfterSignOutHook registers an authentication lifecycle hook.
type AfterSignUpHook ΒΆ
type AfterSignUpHook = hooks.AfterSignUpHook
AfterSignUpHook registers an authentication lifecycle hook.
type AppRepository ΒΆ
type AppRepository = app.AppRepository
AppRepository defines the app repository interface.
type AppService ΒΆ
type AppService = app.AppService
AppService is the service interface for app operations.
type Auth ΒΆ
type Auth struct {
// contains filtered or unexported fields
}
Auth is the main authentication instance.
func (*Auth) AuthMiddleware ΒΆ
func (a *Auth) AuthMiddleware() forge.Middleware
AuthMiddleware returns the optional authentication middleware This middleware populates the auth context with API key and/or session data.
func (*Auth) Authenticate ΒΆ added in v0.0.2
func (a *Auth) Authenticate() forge.Middleware
Authenticate returns the authentication middleware.
func (*Auth) AuthenticateOptional ΒΆ added in v0.0.15
func (a *Auth) AuthenticateOptional() forge.Middleware
AuthenticateOptional returns the authentication middleware.
func (*Auth) GetBasePath ΒΆ
GetBasePath returns the base path for AuthSome routes.
func (*Auth) GetDefaultApp ΒΆ added in v0.0.2
GetDefaultApp returns the default app when in standalone mode This is useful for middleware context auto-detection Returns nil if not in standalone mode or app not found.
func (*Auth) GetDefaultEnvironment ΒΆ added in v0.0.2
GetDefaultEnvironment returns the default environment for an app This is useful for middleware context auto-detection Returns nil if environment not found.
func (*Auth) GetForgeApp ΒΆ
GetForgeApp returns the forge application instance.
func (*Auth) GetGlobalGroupRoutesOptions ΒΆ added in v0.0.2
func (a *Auth) GetGlobalGroupRoutesOptions() []forge.GroupOption
GetGlobalGroupRoutesOptions returns the global group routes options.
func (*Auth) GetGlobalRoutesOptions ΒΆ added in v0.0.2
func (a *Auth) GetGlobalRoutesOptions() []forge.RouteOption
GetGlobalRoutesOptions returns the global routes options.
func (*Auth) GetHookRegistry ΒΆ
func (a *Auth) GetHookRegistry() *hooks.HookRegistry
GetHookRegistry returns the hook registry for plugins.
func (*Auth) GetPluginRegistry ΒΆ
func (a *Auth) GetPluginRegistry() plugins.PluginRegistry
GetPluginRegistry returns the plugin registry.
func (*Auth) GetServiceRegistry ΒΆ
func (a *Auth) GetServiceRegistry() *registry.ServiceRegistry
GetServiceRegistry returns the service registry for plugins.
func (*Auth) Hooks ΒΆ added in v0.0.3
func (a *Auth) Hooks() *hooks.HookRegistry
Hooks returns the hook registry for plugins.
func (*Auth) Initialize ΒΆ
Initialize initializes all core services.
func (*Auth) IsPluginEnabled ΒΆ
IsPluginEnabled checks if a plugin is registered and enabled.
func (*Auth) RegisterAuthStrategy ΒΆ added in v0.0.5
func (a *Auth) RegisterAuthStrategy(strategy middleware.AuthStrategy) error
RegisterAuthStrategy registers an authentication strategy This allows plugins to add custom authentication methods Strategies are tried in priority order during authentication.
func (*Auth) RegisterPlugin ΒΆ
RegisterPlugin registers a plugin.
func (*Auth) Repository ΒΆ
func (a *Auth) Repository() repo.Repository
Repository implements core.Authsome.
func (*Auth) RequireAPIKey ΒΆ
func (a *Auth) RequireAPIKey() forge.Middleware
RequireAPIKey returns middleware that requires API key authentication Blocks requests that don't have a valid API key.
func (*Auth) RequireAdmin ΒΆ
func (a *Auth) RequireAdmin() forge.Middleware
RequireAdmin returns middleware that requires admin privileges Blocks requests that don't have admin:full scope via secret API key.
func (*Auth) RequireAllPermissions ΒΆ added in v0.0.2
func (a *Auth) RequireAllPermissions(permissions ...string) forge.Middleware
RequireAllPermissions returns middleware that requires all of the specified permissions.
func (*Auth) RequireAllScopes ΒΆ
func (a *Auth) RequireAllScopes(scopes ...string) forge.Middleware
RequireAllScopes returns middleware that requires all of the specified scopes.
func (*Auth) RequireAnyPermission ΒΆ added in v0.0.2
func (a *Auth) RequireAnyPermission(permissions ...string) forge.Middleware
RequireAnyPermission returns middleware that requires any of the specified permissions.
func (*Auth) RequireAnyScope ΒΆ
func (a *Auth) RequireAnyScope(scopes ...string) forge.Middleware
RequireAnyScope returns middleware that requires any of the specified scopes.
func (*Auth) RequireAuth ΒΆ
func (a *Auth) RequireAuth() forge.Middleware
RequireAuth returns middleware that requires authentication Blocks requests that are not authenticated via API key or session.
func (*Auth) RequireCanAccess ΒΆ added in v0.0.2
func (a *Auth) RequireCanAccess(action, resource string) forge.Middleware
RequireCanAccess returns middleware that checks if auth context can access a resource This is flexible - accepts EITHER legacy scopes OR RBAC permissions Recommended for backward compatibility.
func (*Auth) RequirePublishableKey ΒΆ
func (a *Auth) RequirePublishableKey() forge.Middleware
RequirePublishableKey returns middleware that requires a publishable (pk_) API key.
func (*Auth) RequireRBACPermission ΒΆ added in v0.0.2
func (a *Auth) RequireRBACPermission(action, resource string) forge.Middleware
RequireRBACPermission returns middleware that requires a specific RBAC permission Checks only RBAC permissions (not legacy scopes).
func (*Auth) RequireScope ΒΆ
func (a *Auth) RequireScope(scope string) forge.Middleware
RequireScope returns middleware that requires a specific API key scope Blocks requests where the API key lacks the specified scope.
func (*Auth) RequireSecretKey ΒΆ
func (a *Auth) RequireSecretKey() forge.Middleware
RequireSecretKey returns middleware that requires a secret (sk_) API key.
func (*Auth) RequireUser ΒΆ
func (a *Auth) RequireUser() forge.Middleware
RequireUser returns middleware that requires user authentication (session) Blocks requests that don't have a valid user session.
func (*Auth) ServiceRegistry ΒΆ added in v0.0.3
func (a *Auth) ServiceRegistry() *registry.ServiceRegistry
ServiceRegistry returns the service registry for plugins.
type AuthContext ΒΆ added in v0.0.2
type AuthContext = contexts.AuthContext
AuthContext holds complete authentication state for a request.
type AuthMethod ΒΆ added in v0.0.2
type AuthMethod = contexts.AuthMethod
AuthMethod indicates how the request was authenticated.
type AuthMiddleware ΒΆ added in v0.0.2
type AuthMiddleware = middleware.AuthMiddleware
AuthMiddleware is the authentication middleware.
type AuthMiddlewareConfig ΒΆ added in v0.0.2
type AuthMiddlewareConfig = middleware.AuthMiddlewareConfig
AuthMiddlewareConfig configures the authentication middleware behavior.
type AuthResponse ΒΆ
type AuthResponse = responses.AuthResponse
AuthResponse is the response from authentication operations.
type AuthService ΒΆ
type AuthService = auth.ServiceInterface
AuthService is the authentication service interface.
type ContextConfig ΒΆ added in v0.0.2
type ContextConfig = middleware.ContextConfig
ContextConfig configures how app and environment context is populated.
type ContextResolution ΒΆ added in v0.0.2
type ContextResolution = middleware.ContextResolution
ContextResolution tracks how context values were resolved.
type ContextSource ΒΆ added in v0.0.2
type ContextSource = middleware.ContextSource
ContextSource indicates where the context value came from.
type CreateAPIKeyRequest ΒΆ
type CreateAPIKeyRequest = apikey.CreateAPIKeyRequest
CreateAPIKeyRequest is the request for creating an API key.
type CreateAppRequest ΒΆ
type CreateAppRequest = app.CreateAppRequest
CreateAppRequest is the request for creating an app.
type CreateJWTKeyRequest ΒΆ
type CreateJWTKeyRequest = jwt.CreateJWTKeyRequest
CreateJWTKeyRequest is the request for creating a JWT key.
type CreateSessionRequest ΒΆ
type CreateSessionRequest = session.CreateSessionRequest
CreateSessionRequest is the request for creating a session.
type CreateTeamRequest ΒΆ
type CreateTeamRequest = app.CreateTeamRequest
CreateTeamRequest is the request for creating a team.
type CreateUserRequest ΒΆ
type CreateUserRequest = user.CreateUserRequest
CreateUserRequest is the request for creating a user.
type CreateWebhookRequest ΒΆ
type CreateWebhookRequest = webhook.CreateWebhookRequest
CreateWebhookRequest is the request for creating a webhook.
type Environment ΒΆ added in v0.0.3
type Environment = environment.Environment
Environment represents an environment.
type EnvironmentRepository ΒΆ added in v0.0.3
type EnvironmentRepository = environment.Repository
EnvironmentRepository defines the environment repository interface.
type GenerateTokenRequest ΒΆ
type GenerateTokenRequest = jwt.GenerateTokenRequest
GenerateTokenRequest is the request for generating a JWT token.
type GeoIPProvider ΒΆ
type GeoIPProvider = sec.GeoIPProvider
GeoIPProvider is the interface for GeoIP providers.
type HookRegistry ΒΆ
type HookRegistry = hooks.HookRegistry
HookRegistry is the registry for registering hooks.
type InvitationRepository ΒΆ
type InvitationRepository = app.InvitationRepository
InvitationRepository defines the invitation repository interface.
type InvitationStatus ΒΆ
type InvitationStatus = app.InvitationStatus
InvitationStatus is an invitation status type.
type InviteMemberRequest ΒΆ
type InviteMemberRequest = app.InviteMemberRequest
InviteMemberRequest is the request for inviting a member.
type MemberRepository ΒΆ
type MemberRepository = app.MemberRepository
MemberRepository defines the member repository interface.
type MemberStatus ΒΆ
type MemberStatus = app.MemberStatus
Schema Enums - Type aliases for cleaner API (re-exported from core/app).
type Notification ΒΆ
type Notification = notification.Notification
Notification represents a notification entity.
type NotificationConfig ΒΆ
type NotificationConfig = notification.Config
NotificationConfig holds notification service configuration.
type NotificationService ΒΆ
type NotificationService = notification.Service
NotificationService is the notification service.
type NotificationTemplate ΒΆ
type NotificationTemplate = notification.Template
NotificationTemplate represents a notification template.
type Option ΒΆ
type Option func(*Auth)
Option is a function that configures Auth.
func WithAuthMiddlewareConfig ΒΆ added in v0.0.2
func WithAuthMiddlewareConfig(config middleware.AuthMiddlewareConfig) Option
WithAuthMiddlewareConfig sets the authentication middleware configuration This controls how the global authentication middleware behaves, including: - Session cookie name - Optional authentication (allow unauthenticated requests) - API key authentication settings - Context resolution (app/environment from headers or API key)
Example:
WithAuthMiddlewareConfig(middleware.AuthMiddlewareConfig{
SessionCookieName: "my_session",
Optional: true,
AllowAPIKeyInQuery: false, // Security best practice
AllowSessionInQuery: false, // Security best practice
Context: middleware.ContextConfig{
AutoDetectFromAPIKey: true,
AutoDetectFromConfig: true,
},
})
func WithBasePath ΒΆ
WithBasePath sets the base path for routes.
func WithCORSEnabled ΒΆ added in v0.0.2
WithCORSEnabled enables or disables CORS middleware When enabled, uses TrustedOrigins for allowed origins Default: false (disabled - let Forge or your app handle CORS).
func WithDatabase ΒΆ
WithDatabase sets the database connection directly (backwards compatible) For new applications, consider using WithDatabaseManager with Forge's database extension.
func WithDatabaseFromForge ΒΆ
func WithDatabaseFromForge() Option
WithDatabaseFromForge resolves the database from Forge's DI container This automatically uses the database extension if registered.
func WithDatabaseManager ΒΆ
func WithDatabaseManager(manager *forgedb.DatabaseManager, dbName ...string) Option
WithDatabaseManager uses Forge's database extension DatabaseManager This is the recommended approach when using Forge's database extension The database will be resolved from the manager using the default or specified name.
func WithDatabaseSchema ΒΆ
WithDatabaseSchema sets the PostgreSQL schema for AuthSome tables This allows organizational separation of auth tables from application tables Example: WithDatabaseSchema("auth") creates tables in the "auth" schema Default: "" (uses database default, typically "public") Note: Schema must be valid SQL identifier; will be created if it doesn't exist.
func WithForgeApp ΒΆ
WithForgeApp sets the Forge application instance.
func WithGeoIPProvider ΒΆ
func WithGeoIPProvider(provider sec.GeoIPProvider) Option
WithGeoIPProvider sets a GeoIP provider for country-based restrictions.
func WithGlobalCookieConfig ΒΆ added in v0.0.2
func WithGlobalCookieConfig(config session.CookieConfig) Option
WithGlobalCookieConfig sets the global cookie configuration for session management This configuration applies to all apps unless overridden at the app level Example:
WithGlobalCookieConfig(session.CookieConfig{
Enabled: true,
Name: "my_session",
HttpOnly: true,
SameSite: "Lax",
})
func WithGlobalGroupRoutesOptions ΒΆ added in v0.0.2
func WithGlobalGroupRoutesOptions(opts ...forge.GroupOption) Option
WithGlobalGroupRoutesOptions sets the global group routes options.
func WithGlobalRoutesOptions ΒΆ added in v0.0.2
func WithGlobalRoutesOptions(opts ...forge.RouteOption) Option
WithGlobalRoutesOptions sets global route options for all routes.
func WithMinPasswordLength ΒΆ added in v0.0.3
WithMinPasswordLength sets the minimum password length
Example:
WithMinPasswordLength(12)
func WithPasswordPolicy ΒΆ added in v0.0.3
WithPasswordPolicy is a convenience function to set common password policies Predefined policies: "weak", "medium", "strong", "enterprise"
Example:
WithPasswordPolicy("strong")
func WithPasswordRequirements ΒΆ added in v0.0.3
func WithPasswordRequirements(reqs validator.PasswordRequirements) Option
WithPasswordRequirements sets the password requirements This controls password validation for user registration and password changes
Example:
WithPasswordRequirements(validator.PasswordRequirements{
MinLength: 12,
RequireUpper: true,
RequireLower: true,
RequireNumber: true,
RequireSpecial: true,
})
func WithRBACEnforcement ΒΆ
WithRBACEnforcement enables/disables handler-level RBAC enforcement.
func WithRateLimitConfig ΒΆ
WithRateLimitConfig sets rate limit configuration (enabled, default rule, per-path rules).
func WithRateLimitStorage ΒΆ
WithRateLimitStorage sets the rate limit storage backend (memory or redis).
func WithRefreshTokens ΒΆ added in v0.0.3
WithRefreshTokens enables the refresh token pattern Short-lived access tokens are issued with long-lived refresh tokens Clients must explicitly refresh when access token expires
Example:
WithRefreshTokens(true, 15*time.Minute, 30*24*time.Hour) // 15 min access tokens, 30 day refresh tokens
func WithRequireEmailVerification ΒΆ added in v0.0.7
func WithSecret ΒΆ
WithSecret sets the secret for token signing.
func WithSecurityConfig ΒΆ
WithSecurityConfig sets security service configuration (IP rules, country rules) Pass lists like IPWhitelist/IPBlacklist; Enabled true to enforce checks.
func WithSessionConfig ΒΆ added in v0.0.3
WithSessionConfig sets the full session configuration This controls session behavior including TTL, sliding window, and refresh tokens
Example:
WithSessionConfig(session.Config{
DefaultTTL: 24 * time.Hour,
RememberTTL: 7 * 24 * time.Hour,
EnableSlidingWindow: true,
SlidingRenewalAfter: 5 * time.Minute,
EnableRefreshTokens: true,
RefreshTokenTTL: 30 * 24 * time.Hour,
AccessTokenTTL: 15 * time.Minute,
})
func WithSessionCookieEnabled ΒΆ added in v0.0.2
WithSessionCookieEnabled enables or disables cookie-based session management globally When enabled, authentication responses will automatically set secure HTTP cookies.
func WithSessionCookieMaxAge ΒΆ added in v0.0.3
WithSessionCookieMaxAge sets the cookie MaxAge in seconds This controls how long the browser keeps the cookie If not set, defaults to session TTL (24 hours)
Example:
authsome.WithSessionCookieMaxAge(3600) // 1 hour authsome.WithSessionCookieMaxAge(86400) // 24 hours
func WithSessionCookieName ΒΆ added in v0.0.2
WithSessionCookieName sets the session cookie name Default: "authsome_session".
func WithSessionTTL ΒΆ added in v0.0.3
WithSessionTTL sets the default and "remember me" session TTL
Example:
WithSessionTTL(24*time.Hour, 7*24*time.Hour)
func WithSlidingWindowSessions ΒΆ added in v0.0.3
WithSlidingWindowSessions enables automatic session renewal on each request When enabled, sessions are extended whenever the user makes a request The renewalThreshold determines how often to actually update the database (default: 5 minutes) This prevents logging out active users while minimizing database writes
Example:
WithSlidingWindowSessions(true, 5*time.Minute)
func WithTrustedOrigins ΒΆ
WithTrustedOrigins sets trusted origins for CORS Setting origins does NOT automatically enable CORS - use WithCORSEnabled(true).
func WithUserConfig ΒΆ added in v0.0.3
WithUserConfig sets the full user configuration This controls user service behavior including password requirements
Example:
WithUserConfig(user.Config{
PasswordRequirements: validator.PasswordRequirements{
MinLength: 12,
RequireUpper: true,
RequireLower: true,
RequireNumber: true,
RequireSpecial: true,
},
})
type Organization ΒΆ
type Organization = organization.Organization
Organization represents an organization entity.
type OrganizationConfig ΒΆ
type OrganizationConfig = organization.Config
OrganizationConfig holds organization service configuration.
type OrganizationService ΒΆ
type OrganizationService = organization.OrganizationService
OrganizationService is the organization service interface.
type PluginDependencies ΒΆ
type PluginDependencies struct {
Container forge.Container
Database *bun.DB
UserService user.ServiceInterface
SessionService session.ServiceInterface
AuthService auth.ServiceInterface
AuditService *audit.Service
RBACService *rbac.Service
HookRegistry *hooks.HookRegistry
}
PluginDependencies is a convenience struct for plugins to get all common dependencies.
func ResolvePluginDependencies ΒΆ
func ResolvePluginDependencies(container forge.Container) (*PluginDependencies, error)
ResolvePluginDependencies resolves all common plugin dependencies from the container.
type PluginRegistry ΒΆ
type PluginRegistry = plugins.PluginRegistry
PluginRegistry is the registry for managing plugins.
type RateLimitConfig ΒΆ
RateLimitConfig holds rate limit service configuration.
type RateLimitService ΒΆ
RateLimitService is the rate limit service.
type RateLimitStorage ΒΆ
RateLimitStorage is the interface for rate limit storage.
type RoleRegistry ΒΆ
type RoleRegistry = rbac.RoleRegistry
RoleRegistry is the role registry for registering roles.
type SchemaAPIKey ΒΆ
SchemaAPIKey is the database model for API keys.
type SchemaDevice ΒΆ
SchemaDevice is the database model for devices.
type SchemaInvitation ΒΆ
type SchemaInvitation = schema.Invitation
SchemaInvitation is the database model for invitations.
type SchemaJWTKey ΒΆ
SchemaJWTKey is the database model for JWT keys.
type SchemaMember ΒΆ
SchemaMember is the database model for members.
type SchemaNotification ΒΆ
type SchemaNotification = schema.Notification
SchemaNotification is the database model for notifications.
type SchemaSession ΒΆ
SchemaSession is the database model for sessions.
type SchemaTeamMember ΒΆ
type SchemaTeamMember = schema.TeamMember
SchemaTeamMember is the database model for team members.
type SchemaUserRole ΒΆ
SchemaUserRole is the database model for user roles.
type SchemaWebhook ΒΆ
SchemaWebhook is the database model for webhooks.
type SecurityConfig ΒΆ
SecurityConfig holds security service configuration.
type ServiceRegistry ΒΆ
type ServiceRegistry = registry.ServiceRegistry
ServiceRegistry manages all core services and allows plugins to replace them.
type SessionConfig ΒΆ
SessionConfig holds session service configuration.
type SessionService ΒΆ
type SessionService = session.ServiceInterface
SessionService is the session service interface.
type SignInRequest ΒΆ
type SignInRequest = auth.SignInRequest
SignInRequest is the request for signing in.
type SignUpRequest ΒΆ
type SignUpRequest = auth.SignUpRequest
SignUpRequest is the request for signing up.
type TeamRepository ΒΆ
type TeamRepository = app.TeamRepository
TeamRepository defines the team repository interface.
type UpdateAppRequest ΒΆ
type UpdateAppRequest = app.UpdateAppRequest
UpdateAppRequest is the request for updating an app.
type UpdateMemberRequest ΒΆ
type UpdateMemberRequest = app.UpdateMemberRequest
UpdateMemberRequest is the request for updating a member.
type UpdateTeamRequest ΒΆ
type UpdateTeamRequest = app.UpdateTeamRequest
UpdateTeamRequest is the request for updating a team.
type UpdateUserRequest ΒΆ
type UpdateUserRequest = user.UpdateUserRequest
UpdateUserRequest is the request for updating a user.
type UserService ΒΆ
type UserService = user.ServiceInterface
UserService is the user service interface.
type WebhookConfig ΒΆ
WebhookConfig holds webhook service configuration.
type WebhookDelivery ΒΆ
WebhookDelivery represents a webhook delivery.
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
clients
|
|
|
go
module
|
|
|
cmd
|
|
|
authsome-cli
command
|
|
|
pagination
Package pagination provides comprehensive pagination support for the AuthSome framework.
|
Package pagination provides comprehensive pagination support for the AuthSome framework. |
|
ui/schema
Package schema provides a dynamic UI schema system for building settings forms with validation, forgeui component rendering, and plugin extensibility.
|
Package schema provides a dynamic UI schema system for building settings forms with validation, forgeui component rendering, and plugin extensibility. |
|
docs
|
|
|
examples
|
|
|
apikey-demo
command
|
|
|
apikey-rbac
command
|
|
|
auth-context
command
|
|
|
bearer-plugin
command
|
|
|
comprehensive
command
|
|
|
consent-demo
command
|
|
|
cookie-sessions
command
|
|
|
dashboard
command
Package main demonstrates how to integrate the dashboard plugin with AuthSome
|
Package main demonstrates how to integrate the dashboard plugin with AuthSome |
|
deviceflow-cli
command
|
|
|
extension-middleware-config
command
|
|
|
forge-database-integration
command
|
|
|
forge-extension
command
|
|
|
geofence-demo
command
|
|
|
jwt-plugin
command
|
|
|
middleware-config
command
|
|
|
notification-complete
command
|
|
|
quick-start-fixed
command
|
|
|
servemux-test
command
|
|
|
test-integration
command
|
|
|
test-multitenancy
command
|
|
|
test-multitenancy-integration
command
|
|
|
test-providers
command
|
|
|
test-webhooks
command
|
|
|
internal
|
|
|
pkg
|
|
|
admin
Package admin provides cross-cutting administrative operations for the AuthSome platform.
|
Package admin provides cross-cutting administrative operations for the AuthSome platform. |
|
cms
Package cms provides a content management system plugin for AuthSome.
|
Package cms provides a content management system plugin for AuthSome. |
|
cms/core
Package core provides core types and utilities for the CMS plugin.
|
Package core provides core types and utilities for the CMS plugin. |
|
cms/handlers
Package handlers provides HTTP handlers for the CMS plugin.
|
Package handlers provides HTTP handlers for the CMS plugin. |
|
cms/pages
Package pages provides gomponent-based page templates for the CMS dashboard.
|
Package pages provides gomponent-based page templates for the CMS dashboard. |
|
cms/query
Package query provides a query language parser and builder for the CMS plugin.
|
Package query provides a query language parser and builder for the CMS plugin. |
|
cms/repository
Package repository implements the data access layer for the CMS plugin.
|
Package repository implements the data access layer for the CMS plugin. |
|
cms/schema
Package schema defines the database schema for the CMS plugin.
|
Package schema defines the database schema for the CMS plugin. |
|
cms/service
Package service implements the business logic layer for the CMS plugin.
|
Package service implements the business logic layer for the CMS plugin. |
|
enterprise/stepup
Package stepup provides context-aware step-up authentication for AuthSome.
|
Package stepup provides context-aware step-up authentication for AuthSome. |
|
multisession/pages
Package pages provides ForgeUI-based page templates for the multisession plugin dashboard.
|
Package pages provides ForgeUI-based page templates for the multisession plugin dashboard. |
|
organization/pages
Package pages provides ForgeUI-based page templates for the organization plugin dashboard.
|
Package pages provides ForgeUI-based page templates for the organization plugin dashboard. |
|
passkey
Package passkey provides WebAuthn/FIDO2 passkey authentication.
|
Package passkey provides WebAuthn/FIDO2 passkey authentication. |
|
secrets
Package secrets provides the secrets management plugin for AuthSome.
|
Package secrets provides the secrets management plugin for AuthSome. |
|
secrets/core
Package core provides core types and utilities for the secrets plugin.
|
Package core provides core types and utilities for the secrets plugin. |
|
secrets/schema
Package schema defines the database schema for the secrets plugin.
|
Package schema defines the database schema for the secrets plugin. |
|
subscription
Package subscription provides a comprehensive SaaS subscription and billing plugin for AuthSome.
|
Package subscription provides a comprehensive SaaS subscription and billing plugin for AuthSome. |
|
subscription/core
Package core defines the core domain types for the subscription plugin.
|
Package core defines the core domain types for the subscription plugin. |
|
subscription/errors
Package errors defines domain errors for the subscription plugin.
|
Package errors defines domain errors for the subscription plugin. |
|
subscription/handlers
Package handlers provides HTTP handlers for the subscription plugin.
|
Package handlers provides HTTP handlers for the subscription plugin. |
|
subscription/internal/hooks
Package hooks provides subscription-specific hook types and registry.
|
Package hooks provides subscription-specific hook types and registry. |
|
subscription/migrations
Package migrations provides migration utilities for the subscription plugin.
|
Package migrations provides migration utilities for the subscription plugin. |
|
subscription/providers
Package providers defines the payment provider abstraction for the subscription plugin.
|
Package providers defines the payment provider abstraction for the subscription plugin. |
|
subscription/providers/mock
Package mock provides a mock payment provider for testing.
|
Package mock provides a mock payment provider for testing. |
|
subscription/providers/paddle
Package paddle provides a stub implementation of the PaymentProvider interface for Paddle.
|
Package paddle provides a stub implementation of the PaymentProvider interface for Paddle. |
|
subscription/providers/paypal
Package paypal provides a stub implementation of the PaymentProvider interface for PayPal.
|
Package paypal provides a stub implementation of the PaymentProvider interface for PayPal. |
|
subscription/providers/stripe
Package stripe provides Stripe payment provider implementation.
|
Package stripe provides Stripe payment provider implementation. |
|
subscription/providers/types
Package types defines shared types for payment providers.
|
Package types defines shared types for payment providers. |
|
subscription/repository
Package repository provides data access interfaces and implementations for the subscription plugin.
|
Package repository provides data access interfaces and implementations for the subscription plugin. |
|
subscription/schema
Package schema defines the database models for the subscription plugin.
|
Package schema defines the database models for the subscription plugin. |
|
subscription/service
Package service provides business logic services for the subscription plugin.
|
Package service provides business logic services for the subscription plugin. |
|
subscription/ui
Package ui provides Pine UI components for the subscription plugin dashboard
|
Package ui provides Pine UI components for the subscription plugin dashboard |
|
providers
|
|
|
Package testing provides comprehensive mocking utilities for testing applications that integrate with the AuthSome authentication framework.
|
Package testing provides comprehensive mocking utilities for testing applications that integrate with the AuthSome authentication framework. |