Documentation
¶
Index ¶
- Constants
- Variables
- func BuildDefaultIdP(cfg DefaultIdPConfig) *domain.Auth
- func DefaultIdPAuthID() ids.AuthID
- func IsDefaultIdP(a *domain.Auth) bool
- func WithAuthContext(ctx context.Context, authCtx *AuthContext) context.Context
- type APIKeyFinder
- type AuthContext
- type ClientCertificateExtractor
- type CreateInput
- type Creator
- type CredentialFinder
- type DefaultIdPConfig
- type Deleter
- type Finder
- type IntrospectionValidator
- type JWTValidator
- type MTLSValidator
- type Method
- type OAuth2Verifier
- type OIDCFinder
- type OIDCVerifier
- type SessionTokenVerifier
- type TokenHints
- type UpdateInput
- type Updater
- type VerifiedClaims
Constants ¶
const DefaultIdPName = "NeuralTrust (built-in)"
DefaultIdPName is the display name carried by the synthetic default auth.
Variables ¶
var ( ErrInvalidAuthRequest = errors.New("invalid auth request") ErrAmbiguousOIDCConfig = errors.New("ambiguous oidc auth config") )
Functions ¶
func BuildDefaultIdP ¶ added in v0.21.0
func BuildDefaultIdP(cfg DefaultIdPConfig) *domain.Auth
BuildDefaultIdP turns the environment configuration into a synthetic oauth2 auth record, or returns nil when the feature is not configured. The record is built as a struct literal (bypassing domain.NewAuth) because it is a platform-wide fallback with no owning gateway: its GatewayID is resolved per request from the addressed MCP consumer, not stored here.
Endpoints default to the conventional paths under the issuer when not set explicitly, so operators only have to provide the issuer plus client credentials. session_mode is always on: the gateway brokers the login and mints its own short-lived MCP session token bound to the platform user.
func DefaultIdPAuthID ¶ added in v0.21.0
DefaultIdPAuthID returns the well-known AuthID of the built-in NeuralTrust identity provider.
func IsDefaultIdP ¶ added in v0.21.0
IsDefaultIdP reports whether the given auth is the synthetic built-in NeuralTrust identity provider.
func WithAuthContext ¶
func WithAuthContext(ctx context.Context, authCtx *AuthContext) context.Context
Types ¶
type APIKeyFinder ¶
type APIKeyFinder interface {
FindByAPIKey(ctx context.Context, rawKey string) (*domain.Auth, error)
}
func NewAPIKeyFinder ¶
func NewAPIKeyFinder(repo domain.Repository, manager *cache.TTLMapManager, logger *slog.Logger) APIKeyFinder
type AuthContext ¶
type AuthContext struct {
Method Method
GatewayID ids.GatewayID
GatewaySlug string
ConsumerID ids.ConsumerID
AuthID ids.AuthID
Subject string
Claims map[string]any
Scopes []string
RoleIDs []ids.RoleID
}
func AuthContextFromContext ¶
func AuthContextFromContext(ctx context.Context) (*AuthContext, bool)
type ClientCertificateExtractor ¶
type ClientCertificateExtractor interface {
FromXFCC(header string) (*x509.Certificate, error)
}
type CreateInput ¶
type Creator ¶
func NewCreator ¶
func NewCreator(repo domain.Repository, manager *cache.TTLMapManager, publisher cache.EventPublisher, logger *slog.Logger, signaler configsyncport.SnapshotSignaler) Creator
type CredentialFinder ¶
type CredentialFinder interface {
OAuth2Auths(ctx context.Context) ([]*domain.Auth, error)
OAuth2AuthsForGateway(ctx context.Context, gatewayID ids.GatewayID) ([]*domain.Auth, error)
MTLSAuths(ctx context.Context) ([]*domain.Auth, error)
// DefaultOAuth2ForGateway returns the built-in NeuralTrust identity
// provider scoped to the given gateway (a copy carrying that GatewayID), or
// nil when the default IdP is not configured. It is used as the fallback
// when an MCP consumer has no oauth2 identity provider of its own.
DefaultOAuth2ForGateway(gatewayID ids.GatewayID) *domain.Auth
}
func NewCredentialFinder ¶
func NewCredentialFinder(repo domain.Repository, manager *cache.TTLMapManager, logger *slog.Logger, defaultIdP *domain.Auth) CredentialFinder
type DefaultIdPConfig ¶ added in v0.21.0
type DefaultIdPConfig struct {
Issuer string
AuthorizeURL string
TokenURL string
JWKSURL string
ClientID string
ClientSecret string
Audiences []string
Scopes []string
}
DefaultIdPConfig is the environment-sourced configuration of the built-in NeuralTrust identity provider. When Issuer is empty the feature is disabled and TrustGate behaves exactly as before (an MCP consumer without its own oauth2 identity provider cannot broker interactive logins).
type Deleter ¶
type Deleter interface {
Delete(ctx context.Context, gatewayID ids.GatewayID, id ids.AuthID) error
}
func NewDeleter ¶
func NewDeleter( repo domain.Repository, consumerRepo consumerAuthRefs, manager *cache.TTLMapManager, publisher cache.EventPublisher, logger *slog.Logger, signaler configsyncport.SnapshotSignaler, ) Deleter
type Finder ¶
type Finder interface {
FindByID(ctx context.Context, gatewayID ids.GatewayID, id ids.AuthID) (*domain.Auth, error)
List(ctx context.Context, filter domain.ListFilter) ([]*domain.Auth, int, error)
}
func NewFinder ¶
func NewFinder(repo domain.Repository, manager *cache.TTLMapManager, logger *slog.Logger) Finder
type IntrospectionValidator ¶
type IntrospectionValidator interface {
Validate(ctx context.Context, raw string, cfg *authdomain.OAuth2Config) (*identity.Principal, error)
}
type JWTValidator ¶
type JWTValidator interface {
Validate(ctx context.Context, raw string, cfg *authdomain.OAuth2Config) (*identity.Principal, error)
}
type MTLSValidator ¶
type MTLSValidator interface {
Validate(cert *x509.Certificate, cfg *authdomain.MTLSConfig) (*identity.Principal, error)
}
type OAuth2Verifier ¶
type OAuth2Verifier interface {
Verify(ctx context.Context, token string, cfg domain.OAuth2Config) (*VerifiedClaims, error)
}
func NewOAuth2Verifier ¶
func NewOAuth2Verifier(jwtVerifier OIDCVerifier) OAuth2Verifier
type OIDCFinder ¶
type OIDCFinder interface {
FindOIDCAuth(ctx context.Context, auths []*domain.Auth, token string) (*domain.Auth, error)
}
func NewOIDCFinder ¶
func NewOIDCFinder(verifier OIDCVerifier) OIDCFinder
type OIDCVerifier ¶
type OIDCVerifier interface {
Peek(token string) (TokenHints, error)
Verify(ctx context.Context, token string, cfg domain.OIDCConfig) (*VerifiedClaims, error)
}
type SessionTokenVerifier ¶ added in v0.2.3
type TokenHints ¶
type UpdateInput ¶
type Updater ¶
func NewUpdater ¶
func NewUpdater( repo domain.Repository, consumerRepo consumerAuthRefs, manager *cache.TTLMapManager, publisher cache.EventPublisher, logger *slog.Logger, signaler configsyncport.SnapshotSignaler, ) Updater