Documentation
¶
Overview ¶
Package oidc is Access's OpenID Connect integration (research 21): the providers whose ID tokens artifactweave trusts, the identity mappings that turn a token's claims into an access token, and the token exchange that CI systems call (POST /access/api/v1/oidc/token). Providers and mappings are configuration documents (types.ConfigOIDC, types.ConfigOIDCMapping) stored in their wire form, so they read back exactly as written.
Index ¶
- Constants
- Variables
- func CanonicalType(s string) (string, bool)
- type ExchangeRequest
- type Exchanged
- type Mapping
- type Provider
- type Service
- func (s Service) CreateMapping(ctx context.Context, provider string, m Mapping) (Mapping, error)
- func (s Service) CreateProvider(ctx context.Context, p Provider) (Provider, error)
- func (s Service) DeleteMapping(ctx context.Context, provider, name string) error
- func (s Service) DeleteProvider(ctx context.Context, name string) error
- func (s Service) Exchange(ctx context.Context, r ExchangeRequest) (Exchanged, error)
- func (s Service) Mapping(ctx context.Context, provider, name string) (Mapping, error)
- func (s Service) Mappings(ctx context.Context, provider, project string) ([]Mapping, error)
- func (s Service) Provider(ctx context.Context, name string) (Provider, error)
- func (s Service) Providers(ctx context.Context) ([]Provider, error)
- func (s Service) UpdateMapping(ctx context.Context, provider, name string, m Mapping) (Mapping, error)
- func (s Service) UpdateProvider(ctx context.Context, name string, p Provider) (Provider, error)
- type TokenSpec
Constants ¶
const ( GrantTokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange" SubjectIDToken = "urn:ietf:params:oauth:token-type:id_token" IssuedAccessToken = "urn:ietf:params:oauth:token-type:access_token" )
The RFC 8693 identifiers of the exchange.
const ( TypeGeneric = "Generic OpenID Connect" TypeGitHub = "GitHub" TypeGitHubEnterprise = "GitHub Enterprise" TypeAzure = "Azure" )
Provider types in the Access vocabulary, which the jfrog/platform Terraform provider sends and reads back.
const DefaultExpiry = time.Hour
DefaultExpiry is the lifetime of a mapping's token when its spec sets none.
const MaxExpiry = 24 * time.Hour
MaxExpiry is the longest token a mapping issues: Access limits a mapping's expiration time to 24 hours.
Variables ¶
var ( // ErrNotFound reports a provider or mapping that does not exist. ErrNotFound = errors.New("oidc: not found") // ErrInvalid reports a configuration or exchange request the server // refuses as malformed. ErrInvalid = errors.New("oidc: invalid") // ErrNoMatch reports a verified token that no identity mapping accepts. ErrNoMatch = errors.New("oidc: no identity mapping matches the subject token") // ErrUnverified reports a subject token that does not verify. ErrUnverified = errors.New("oidc: the subject token does not verify") )
Functions ¶
func CanonicalType ¶
CanonicalType returns the Access form of a provider type; "" is generic.
Types ¶
type ExchangeRequest ¶
type ExchangeRequest struct {
GrantType, SubjectTokenType, SubjectToken string
ProviderName, ProjectKey, MappingName string
IncludeReference bool
JobID, RunID, Repo, Revision, Branch string
}
ExchangeRequest is a token exchange. The CI fields are recorded in the issued token's description for auditing.
type Mapping ¶
type Mapping struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Priority *int `json:"priority,omitempty"`
Claims map[string]any `json:"claims,omitempty"`
TokenSpec *TokenSpec `json:"token_spec,omitempty"`
ProjectKey *string `json:"project_key,omitempty"`
}
Mapping is an identity mapping in its wire form. ProjectKey is set by the server, from a project role in the scope.
type Provider ¶
type Provider struct {
Name *string `json:"name,omitempty"`
IssuerURL *string `json:"issuer_url,omitempty"`
Audience *string `json:"audience,omitempty"`
Description *string `json:"description,omitempty"`
ProviderType *string `json:"provider_type,omitempty"`
TokenIssuer *string `json:"token_issuer,omitempty"`
EnablePermissiveConfiguration *bool `json:"enable_permissive_configuration,omitempty"`
UseDefaultProxy *bool `json:"use_default_proxy,omitempty"`
AzureAppID *string `json:"azure_app_id,omitempty"`
Organization *string `json:"organization,omitempty"`
ProjectKey *string `json:"project_key,omitempty"`
}
Provider is an OIDC provider in its wire form.
type Service ¶
type Service struct {
Store store.Store
Tokens *token.Service
Keys *idtoken.Verifier
// Now supplies the time; nil means time.Now.
Now func() time.Time
}
Service manages providers and mappings and exchanges tokens.
func (Service) CreateMapping ¶
CreateMapping adds m to a provider; a name in use is invalid.
func (Service) CreateProvider ¶
CreateProvider adds p; a name in use is invalid, as Access answers 400.
func (Service) DeleteMapping ¶
DeleteMapping removes one mapping.
func (Service) DeleteProvider ¶
DeleteProvider removes a provider and its mappings.
func (Service) Exchange ¶
Exchange verifies the request's ID token against its provider, finds the first identity mapping whose claims it satisfies, and issues the access token that mapping describes.
func (Service) UpdateMapping ¶
func (s Service) UpdateMapping( ctx context.Context, provider, name string, m Mapping, ) (Mapping, error)
UpdateMapping replaces the mapping name with m, keeping its place among equal priorities. Its project, which its scope's project roles imply, cannot change: "Attempting to change the project key returns 400 Bad Request" (Manage Project-Scoped Identity Mappings), from a project to none or another, or from none to one.
type TokenSpec ¶
type TokenSpec struct {
Username *string `json:"username,omitempty"`
UsernamePattern *string `json:"username_pattern,omitempty"`
GroupsPattern *string `json:"groups_pattern,omitempty"`
ResourcePattern *string `json:"resource_pattern,omitempty"`
Scope *string `json:"scope,omitempty"`
Audience *string `json:"audience,omitempty"`
ExpiresIn *int64 `json:"expires_in,omitempty"`
SelfRevocable *bool `json:"self_revocable,omitempty"`
}
TokenSpec shapes the access token a mapping issues.