Documentation
¶
Index ¶
- Variables
- type LegacyCredentials
- type ManagedToken
- type ManagedTokenHasher
- type ManagedTokenLookup
- type ManagedTokenRecord
- type Principal
- type PrincipalKind
- type PrincipalResolver
- type PrincipalSource
- type ProjectScopeAuthorizer
- type ResolverConfig
- type Role
- type Service
- func (s *Service) Authorize(r *http.Request) error
- func (s *Service) AuthorizeProject(project string) error
- func (s *Service) EnrolledProjects() []string
- func (s *Service) MintDashboardSession(bearerToken string) (string, error)
- func (s *Service) ParseDashboardSession(sessionToken string) (string, error)
- func (s *Service) ResolveBearerToken(_ context.Context, token string) (Principal, error)
- func (s *Service) SetAllowedProjects(projects []string)
- func (s *Service) SetBearerToken(token string)
- func (s *Service) SetDashboardSessionTokens(tokens []string)
Constants ¶
This section is empty.
Variables ¶
var ErrBearerTokenNotConfigured = errors.New("cloud bearer token is not configured")
var ErrInvalidDashboardSessionToken = errors.New("invalid dashboard session token")
var ErrInvalidPrincipal = errors.New("invalid principal")
var ErrManagedTokenRequired = errors.New("managed token is required")
var ErrPrincipalDisabled = errors.New("principal is disabled")
var ErrProjectNotAllowed = errors.New("project is not allowed for this token")
var ErrSecretTooShort = errors.New("jwt secret must be at least 32 bytes")
var ErrTokenPepperRequired = errors.New("dedicated cloud token pepper is required")
var ErrTokenPepperTooShort = fmt.Errorf("dedicated cloud token pepper must be at least %d bytes", managedTokenPepperMinBytes)
var ErrTokenRevoked = errors.New("token is revoked")
var ErrUnknownToken = errors.New("unknown token")
Functions ¶
This section is empty.
Types ¶
type LegacyCredentials ¶
type ManagedToken ¶
func GenerateManagedToken ¶
func GenerateManagedToken(environment string) (ManagedToken, error)
type ManagedTokenHasher ¶
type ManagedTokenHasher struct {
// contains filtered or unexported fields
}
func NewManagedTokenHasher ¶
func NewManagedTokenHasher(pepper []byte) (*ManagedTokenHasher, error)
type ManagedTokenLookup ¶
type ManagedTokenRecord ¶
type Principal ¶
type Principal struct {
ID string
Kind PrincipalKind
DisplayName string
Role Role
Enabled bool
Source PrincipalSource
TokenID string
}
type PrincipalKind ¶
type PrincipalKind string
const ( PrincipalKindHuman PrincipalKind = "human" PrincipalKindServiceAccount PrincipalKind = "service_account" PrincipalKindLegacy PrincipalKind = "legacy" )
func (PrincipalKind) String ¶
func (k PrincipalKind) String() string
func (PrincipalKind) Valid ¶
func (k PrincipalKind) Valid() bool
type PrincipalResolver ¶
type PrincipalResolver struct {
// contains filtered or unexported fields
}
func NewPrincipalResolver ¶
func NewPrincipalResolver(config ResolverConfig) *PrincipalResolver
func (*PrincipalResolver) ResolveBearerToken ¶
type PrincipalSource ¶
type PrincipalSource string
const ( PrincipalSourceManagedToken PrincipalSource = "managed_token" PrincipalSourceLegacyEnvSync PrincipalSource = "legacy_env_sync" PrincipalSourceLegacyEnvAdmin PrincipalSource = "legacy_env_admin" PrincipalSourceBootstrapCLI PrincipalSource = "bootstrap_cli" PrincipalSourceInsecureDev PrincipalSource = "insecure_dev" )
func (PrincipalSource) String ¶
func (s PrincipalSource) String() string
func (PrincipalSource) Valid ¶
func (s PrincipalSource) Valid() bool
type ProjectScopeAuthorizer ¶
type ProjectScopeAuthorizer struct {
// contains filtered or unexported fields
}
func NewProjectScopeAuthorizer ¶
func NewProjectScopeAuthorizer(projects []string) *ProjectScopeAuthorizer
func (*ProjectScopeAuthorizer) AuthorizeProject ¶
func (a *ProjectScopeAuthorizer) AuthorizeProject(project string) error
func (*ProjectScopeAuthorizer) EnrolledProjects ¶
func (a *ProjectScopeAuthorizer) EnrolledProjects() []string
EnrolledProjects returns the sorted list of projects this authorizer allows. Matches the cloudserver.EnrolledProjectsProvider contract so mutation pull can filter server-side by the caller's enrolled projects (REQ-202) rather than fail-closing to an empty result set.
When the wildcard "*" is configured, nil is returned to signal "no project filter" (matching the ListMutationsSince nil-means-all contract).
func (*ProjectScopeAuthorizer) SetAllowedProjects ¶
func (a *ProjectScopeAuthorizer) SetAllowedProjects(projects []string)
type ResolverConfig ¶
type ResolverConfig struct {
Hasher *ManagedTokenHasher
ManagedTokens ManagedTokenLookup
Legacy LegacyCredentials
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(store *cloudstore.CloudStore, jwtSecret string) (*Service, error)
func (*Service) AuthorizeProject ¶
func (*Service) EnrolledProjects ¶
EnrolledProjects returns the sorted list of projects that this Service is authorized to serve. Used by cloudserver's mutation pull to filter mutations to the caller's enrolled projects (REQ-202).
When the wildcard "*" is configured, nil is returned to signal "no project filter" — callers must treat nil as "allow all" (matching the ListMutationsSince nil-means-all contract).
The interface is cloudserver.EnrolledProjectsProvider; this method makes *Service satisfy it without importing cloudserver (structural assertion).
func (*Service) MintDashboardSession ¶
MintDashboardSession returns a signed dashboard session token. The token is opaque to clients and validated by ParseDashboardSession.
func (*Service) ParseDashboardSession ¶
ParseDashboardSession verifies and decodes a signed dashboard session token.