Identity & Auth
Authentication providers, API key validation, and the Authsome adapter.
Auth Interface
type Provider interface {
Authenticate(ctx context.Context) (Claims, error)
AuthenticateAPIKey(ctx context.Context, apiKey string) (Claims, error)
}Claims
type Claims struct {
TenantID string
Subject string
Scopes []string
}Default (Noop)
By default, Nexus uses a noop auth provider that allows all requests:
gw := nexus.New() // auth.NewNoop() is set automaticallyAPI Key Auth
Use the built-in key service for API key authentication:
keyService := key.NewService(store)
gw := nexus.New(
nexus.WithAuth(keyService),
)Authsome Adapter
If you use Authsome in a Forge application, Nexus provides an adapter:
import "github.com/xraph/nexus/auth/authsome"
adapter := authsome.NewAdapter(authsomeInstance)
gw := nexus.New(
nexus.WithAuth(adapter),
)