Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- 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() func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) GetBasePath() string
- func (a *Auth) GetConfig() Config
- func (a *Auth) GetDB() *bun.DB
- func (a *Auth) GetForgeApp() forge.App
- func (a *Auth) GetHookRegistry() *hooks.HookRegistry
- func (a *Auth) GetPluginRegistry() plugins.PluginRegistry
- func (a *Auth) GetServiceRegistry() *registry.ServiceRegistry
- 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) RegisterPlugin(plugin plugins.Plugin) error
- func (a *Auth) Repository() repo.Repository
- func (a *Auth) RequireAPIKey() func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequireAdmin() func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequireAllScopes(scopes ...string) func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequireAnyScope(scopes ...string) func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequireAuth() func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequirePublishableKey() func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequireScope(scope string) func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequireSecretKey() func(func(forge.Context) error) func(forge.Context) error
- func (a *Auth) RequireUser() func(func(forge.Context) error) func(forge.Context) error
- type AuthConfig
- type AuthResponse
- type AuthService
- type Config
- type CreateAPIKeyRequest
- type CreateAppRequest
- type CreateJWTKeyRequest
- type CreateSessionRequest
- type CreateTeamRequest
- type CreateUserRequest
- type CreateWebhookRequest
- type Device
- type DeviceService
- 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 WithBasePath(path string) Option
- func WithDatabase(db interface{}) 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 WithRBACEnforcement(enabled bool) Option
- func WithRateLimitConfig(cfg rl.Config) Option
- func WithRateLimitStorage(storage rl.Storage) Option
- func WithSecret(secret string) Option
- func WithSecurityConfig(cfg sec.Config) Option
- func WithTrustedOrigins(origins []string) 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 ( // Member Roles MemberRoleOwner = app.MemberRoleOwner MemberRoleAdmin = app.MemberRoleAdmin MemberRoleMember = app.MemberRoleMember // Member Statuses MemberStatusActive = app.MemberStatusActive MemberStatusSuspended = app.MemberStatusSuspended MemberStatusPending = app.MemberStatusPending // Invitation Statuses InvitationStatusPending = app.InvitationStatusPending InvitationStatusAccepted = app.InvitationStatusAccepted InvitationStatusExpired = app.InvitationStatusExpired InvitationStatusCancelled = app.InvitationStatusCancelled InvitationStatusDeclined = app.InvitationStatusDeclined // Backward compatibility aliases RoleOwner = app.MemberRoleOwner RoleAdmin = app.MemberRoleAdmin RoleMember = app.MemberRoleMember StatusActive = app.MemberStatusActive StatusSuspended = app.MemberStatusSuspended StatusPending = app.MemberStatusPending )
Enum constants exported for convenience
Variables ΒΆ
var ( // RegisterDefaultPlatformRoles registers default platform roles RegisterDefaultPlatformRoles = rbac.RegisterDefaultPlatformRoles )
RBAC Functions
Functions ΒΆ
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 ΒΆ
AuthMiddleware returns the optional authentication middleware This middleware populates the auth context with API key and/or session data but does not block unauthenticated requests
func (*Auth) GetBasePath ΒΆ
GetBasePath returns the base path for AuthSome routes
func (*Auth) GetForgeApp ΒΆ
GetForgeApp returns the forge application instance
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) Initialize ΒΆ
Initialize initializes all core services
func (*Auth) IsPluginEnabled ΒΆ
IsPluginEnabled checks if a plugin is registered and enabled
func (*Auth) RegisterPlugin ΒΆ
RegisterPlugin registers a plugin
func (*Auth) Repository ΒΆ
func (a *Auth) Repository() repo.Repository
Repository implements core.Authsome.
func (*Auth) RequireAPIKey ΒΆ
RequireAPIKey returns middleware that requires API key authentication Blocks requests that don't have a valid API key
func (*Auth) RequireAdmin ΒΆ
RequireAdmin returns middleware that requires admin privileges Blocks requests that don't have admin:full scope via secret API key
func (*Auth) RequireAllScopes ΒΆ
func (a *Auth) RequireAllScopes(scopes ...string) func(func(forge.Context) error) func(forge.Context) error
RequireAllScopes returns middleware that requires all of the specified scopes
func (*Auth) RequireAnyScope ΒΆ
func (a *Auth) RequireAnyScope(scopes ...string) func(func(forge.Context) error) func(forge.Context) error
RequireAnyScope returns middleware that requires any of the specified scopes
func (*Auth) RequireAuth ΒΆ
RequireAuth returns middleware that requires authentication Blocks requests that are not authenticated via API key or session
func (*Auth) RequirePublishableKey ΒΆ
RequirePublishableKey returns middleware that requires a publishable (pk_) API key
func (*Auth) RequireScope ΒΆ
RequireScope returns middleware that requires a specific API key scope Blocks requests where the API key lacks the specified scope
func (*Auth) RequireSecretKey ΒΆ
RequireSecretKey returns middleware that requires a secret (sk_) API key
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 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 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 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 WithBasePath ΒΆ
WithBasePath sets the base path for routes
func WithDatabase ΒΆ
func WithDatabase(db interface{}) Option
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 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 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 WithTrustedOrigins ΒΆ
WithTrustedOrigins sets trusted origins for CORS
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
|
|
|
migrate-member-roles
command
|
|
|
pagination
Package pagination provides comprehensive pagination support for the AuthSome framework.
|
Package pagination provides comprehensive pagination support for the AuthSome framework. |
|
examples
|
|
|
apikey-demo
command
|
|
|
apikey-rbac
command
|
|
|
auth-context
command
|
|
|
comprehensive
command
|
|
|
consent-demo
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 |
|
forge-database-integration
command
|
|
|
forge-extension
command
|
|
|
geofence-demo
command
|
|
|
jwt-plugin
command
|
|
|
notification-complete
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. |
|
enterprise/stepup
Package stepup provides context-aware step-up authentication for AuthSome.
|
Package stepup provides context-aware step-up authentication for AuthSome. |
|
passkey
Package passkey provides WebAuthn/FIDO2 passkey authentication.
|
Package passkey provides WebAuthn/FIDO2 passkey authentication. |
|
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. |