Documentation
¶
Overview ¶
Package identity verifies who sent a request and matches that person against access rules. It knows no grant and no repository store: each service turns a principal and a scope into its own claims.
Index ¶
Constants ¶
const ( ScopeRead = "read" ScopeWrite = "write" // ScopeAdmin lets its principal create a repository. It names no repository. ScopeAdmin = "admin" )
The scopes that a rule gives.
Variables ¶
var ErrNoPrincipal = errors.New("identity: no verifier accepts the credential")
ErrNoPrincipal is the answer of Chain when no verifier gives a principal.
Functions ¶
func ValidScope ¶
ValidScope reports whether a human identity may hold scope on repos: read or write on at least one repository, or admin on none.
Types ¶
type Principal ¶
type Principal struct {
// Subject is the text that rules match exactly.
Subject string
// Email is the email claim. Rules match it without case, and only when EmailVerified is true.
Email string
EmailVerified bool
// Exp is the end of the credential.
Exp time.Time
}
Principal is a verified person or service.
type Rule ¶
type Rule struct {
Principals []string `json:"principals"`
Repos []string `json:"repos"`
Scope string `json:"scope"`
}
Rule gives Scope on Repos to Principals. A principal is a subject text, or @domain for every verified email of the domain.
type Rules ¶
type Rules []Rule
Rules is an ordered list of rules.
func (Rules) Match ¶
Match returns the highest scope that the rules give p on repo. repo is empty for a call that names no repository, and only a rule of scope admin answers it. The subject matches exactly. A verified email matches without case, and a @domain principal matches the domain of a verified email.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package identitytest holds the conformance suite of identity.Verifier and a signer of Access JWTs.
|
Package identitytest holds the conformance suite of identity.Verifier and a signer of Access JWTs. |
|
Package oidc authenticates a request by a signed OIDC JWT from any issuer, and maps a claim of the JWT to a scope on a repository with rules.
|
Package oidc authenticates a request by a signed OIDC JWT from any issuer, and maps a claim of the JWT to a scope on a repository with rules. |
|
Package usertoken authenticates a request by a per-user token that an administrator issued.
|
Package usertoken authenticates a request by a per-user token that an administrator issued. |