Documentation
¶
Overview ¶
permission_interceptor.go
Index ¶
- Variables
- func CompareClientVersion(session *authenticationpb.Session, major, minor, patch int32) int
- func GetSession(ctx context.Context) (*authenticationpb.Session, error)
- func WithAPIKey(ctx context.Context, headerKey, apiKey string) context.Context
- type ExternalApiKeyAuthenticationInterceptor
- type ExternalApiKeyAuthenticationInterceptorOpts
- type ExternalApiKeysOpts
- type InternalServiceAuthenticationInterceptor
- type InternalServiceAuthenticationInterceptorOpts
- type JwtAuthenticationInterceptor
- type JwtAuthenticationInterceptorOpts
- type JwtMinter
- type MintJwtOpts
- type PermissionAuthenticationInterceptor
- type PermissionAuthenticationInterceptorOpts
- type SessionManager
- func (s *SessionManager) StreamServerLocalContextInjectorInterceptor() grpc.StreamServerInterceptor
- func (s *SessionManager) StreamServerLogInjectorInterceptor() grpc.StreamServerInterceptor
- func (s *SessionManager) StreamServerOutgoingContextInjectorInterceptor() grpc.StreamServerInterceptor
- func (s *SessionManager) UnaryServerLocalContextInjectorInterceptor() grpc.UnaryServerInterceptor
- func (s *SessionManager) UnaryServerLogInjectorInterceptor() grpc.UnaryServerInterceptor
- func (s *SessionManager) UnaryServerOutgoingContextInjectorInterceptor() grpc.UnaryServerInterceptor
- type SessionManagerOpts
Constants ¶
This section is empty.
Variables ¶
var ErrMethodNotConfigured = errors.New("method not configured")
ErrMethodNotConfigured indicates no CEL rule exists for the requested method.
var ErrSignedSessionNotFound = errors.New("session not found in context")
Functions ¶
func CompareClientVersion ¶
func CompareClientVersion(session *authenticationpb.Session, major, minor, patch int32) int
CompareClientVersion compares the session's client version against the given major.minor.patch. Returns -1, 0, or 1 if the client version is less than, equal to, or greater than the specified version. Returns -1 if no version is present.
func GetSession ¶
func GetSession(ctx context.Context) (*authenticationpb.Session, error)
Types ¶
type ExternalApiKeyAuthenticationInterceptor ¶
type ExternalApiKeyAuthenticationInterceptor struct {
// contains filtered or unexported fields
}
func NewExternalApiKeyAuthenticationInterceptor ¶
func NewExternalApiKeyAuthenticationInterceptor( opts *ExternalApiKeyAuthenticationInterceptorOpts, sessionManager *SessionManager, ) (*ExternalApiKeyAuthenticationInterceptor, error)
func (*ExternalApiKeyAuthenticationInterceptor) Stream ¶
func (i *ExternalApiKeyAuthenticationInterceptor) Stream() grpc.StreamServerInterceptor
Stream implements the API key authentication stream interceptor.
func (*ExternalApiKeyAuthenticationInterceptor) Unary ¶
func (i *ExternalApiKeyAuthenticationInterceptor) Unary() grpc.UnaryServerInterceptor
Unary implements the API key authentication unary interceptor.
type ExternalApiKeyAuthenticationInterceptorOpts ¶
type ExternalApiKeyAuthenticationInterceptorOpts struct {
*ExternalApiKeysOpts
}
type ExternalApiKeysOpts ¶
type ExternalApiKeysOpts struct {
MetadataHeader string `long:"metadata-header" env:"METADATA_HEADER" description:"The header you wish to use for api keys" default:"x-api-key"`
APIKeys string `long:"api-keys" env:"API_KEYS" description:"List of service_account_id:api_key pairs" required:"true"`
Config string `long:"config" env:"CONFIG" description:"Path to the authentication configuration file" required:"true"`
}
func (*ExternalApiKeysOpts) ParseAPIKey ¶
func (o *ExternalApiKeysOpts) ParseAPIKey(targetServiceAccountID string) (string, error)
func (*ExternalApiKeysOpts) WithAPIKey ¶
WithAPIKey creates a new context with the API key set in outgoing metadata.
type InternalServiceAuthenticationInterceptor ¶
type InternalServiceAuthenticationInterceptor struct {
// contains filtered or unexported fields
}
func NewInternalServiceAuthenticationInterceptor ¶
func NewInternalServiceAuthenticationInterceptor( opts *InternalServiceAuthenticationInterceptorOpts, sessionManager *SessionManager, ) (*InternalServiceAuthenticationInterceptor, error)
func (*InternalServiceAuthenticationInterceptor) Stream ¶
func (i *InternalServiceAuthenticationInterceptor) Stream() grpc.StreamServerInterceptor
Stream implements the internal service authentication stream interceptor.
func (*InternalServiceAuthenticationInterceptor) Unary ¶
func (i *InternalServiceAuthenticationInterceptor) Unary() grpc.UnaryServerInterceptor
Unary implements the internal service authentication unary interceptor.
type InternalServiceAuthenticationInterceptorOpts ¶
type InternalServiceAuthenticationInterceptorOpts struct {
MetadataHeader string `` /* 139-byte string literal not displayed */
InternalServiceSecret string `` /* 129-byte string literal not displayed */
Config string `long:"config" env:"CONFIG" description:"Path to the authentication configuration file" required:"true"`
// contains filtered or unexported fields
}
func (*InternalServiceAuthenticationInterceptorOpts) WithServiceAccount ¶
func (o *InternalServiceAuthenticationInterceptorOpts) WithServiceAccount( serviceAccountID string, ) (func(context.Context) context.Context, error)
WithInternalServiceAuth creates a new context with the internal service auth header in the format service_account_id/secret
type JwtAuthenticationInterceptor ¶
type JwtAuthenticationInterceptor struct {
// contains filtered or unexported fields
}
func NewJwtAuthenticationInterceptor ¶
func NewJwtAuthenticationInterceptor( ctx context.Context, opts *JwtAuthenticationInterceptorOpts, sessionManager *SessionManager, ) (*JwtAuthenticationInterceptor, error)
func (*JwtAuthenticationInterceptor) Stream ¶
func (i *JwtAuthenticationInterceptor) Stream() grpc.StreamServerInterceptor
func (*JwtAuthenticationInterceptor) Unary ¶
func (i *JwtAuthenticationInterceptor) Unary() grpc.UnaryServerInterceptor
type JwtMinter ¶
type JwtMinter struct {
// contains filtered or unexported fields
}
func NewJwtMinter ¶
func NewJwtMinter(issuerConfig *authenticationpb.JwtIssuer) (*JwtMinter, error)
type MintJwtOpts ¶
type PermissionAuthenticationInterceptor ¶
type PermissionAuthenticationInterceptor struct {
// contains filtered or unexported fields
}
func NewPermissionAuthenticationInterceptor ¶
func NewPermissionAuthenticationInterceptor( opts *PermissionAuthenticationInterceptorOpts, sessionManager *SessionManager, ) (*PermissionAuthenticationInterceptor, error)
func (*PermissionAuthenticationInterceptor) Stream ¶
func (i *PermissionAuthenticationInterceptor) Stream() grpc.StreamServerInterceptor
Stream implements the authentication stream interceptor. For all stream types, we peek the first client request so that CEL authorization rules can evaluate against it. The only exception is bidi streams, where we pass a nil request to authenticate() because either side may send first so we cannot reliably peek a request.
func (*PermissionAuthenticationInterceptor) Unary ¶
func (i *PermissionAuthenticationInterceptor) Unary() grpc.UnaryServerInterceptor
Unary implements the authentication unary interceptor.
type PermissionAuthenticationInterceptorOpts ¶
type PermissionAuthenticationInterceptorOpts struct {
Config string `long:"config" env:"CONFIG" description:"Path to the authentication configuration file" required:"true"`
}
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(opts *SessionManagerOpts) *SessionManager
func (*SessionManager) StreamServerLocalContextInjectorInterceptor ¶
func (s *SessionManager) StreamServerLocalContextInjectorInterceptor() grpc.StreamServerInterceptor
StreamServerLocalContextInjectorInterceptor
- parses the session from the incoming context
- injects it into the local context
func (*SessionManager) StreamServerLogInjectorInterceptor ¶
func (s *SessionManager) StreamServerLogInjectorInterceptor() grpc.StreamServerInterceptor
StreamServerLogInjectorInterceptor injects session fields into the log context for streaming RPCs
func (*SessionManager) StreamServerOutgoingContextInjectorInterceptor ¶
func (s *SessionManager) StreamServerOutgoingContextInjectorInterceptor() grpc.StreamServerInterceptor
StreamServerOutgoingContextInjectorInterceptor
- parses the session from the local context
- injects it into the outgoing context
func (*SessionManager) UnaryServerLocalContextInjectorInterceptor ¶
func (s *SessionManager) UnaryServerLocalContextInjectorInterceptor() grpc.UnaryServerInterceptor
UnaryServerLocalContextInjectorInterceptor
- parses the session from the incoming context
- injects it into the local context
func (*SessionManager) UnaryServerLogInjectorInterceptor ¶
func (s *SessionManager) UnaryServerLogInjectorInterceptor() grpc.UnaryServerInterceptor
UnaryServerLogInjectorInterceptor injects session fields into the log context for unary RPCs
func (*SessionManager) UnaryServerOutgoingContextInjectorInterceptor ¶
func (s *SessionManager) UnaryServerOutgoingContextInjectorInterceptor() grpc.UnaryServerInterceptor
UnaryServerOutgoingContextInjectorInterceptor
- parses the session from the local context
- injects it into the outgoing context
type SessionManagerOpts ¶
type SessionManagerOpts struct {
Secret string `long:"secret" env:"SECRET" description:"Secret key for signing sessions" required:"true"`
}