identity

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package identity maps the credential of a request to the claims of a grant.

Index

Constants

View Source
const ScopeAdmin grant.Scope = "admin"

ScopeAdmin is the scope of a rule or a token that lets its principal create a repository. It names no repository, and an Authenticator answers it only for a call that names none, with the claims of scope operator.

Variables

This section is empty.

Functions

func Claims

func Claims(scope grant.Scope, repo, subject string, exp int64) grant.Claims

Claims is the claims of a human identity that holds scope on repo. ScopeAdmin becomes operator.

func ScopeFor

func ScopeFor(rules []Rule, subject, repo string) grant.Scope

ScopeFor returns the highest scope that the rules give subject on repo, or "" for none. repo is empty for a call that names no repository. A subject that holds an @ is an email and matches without case. Any other subject matches exactly.

func ValidScope

func ValidScope(scope grant.Scope, repos []string) bool

ValidScope reports whether a human identity may hold scope on repos: read or write on at least one repository, or admin on none. A human identity never holds merge, operator, import or node.

func Validate

func Validate(rules []Rule) error

Validate checks the rules.

Types

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request, repo string) (grant.Claims, error)
}

Authenticator reads the credential of r and returns the claims that it gives. repo is the repository text that the route names, empty for a route with none. A credential that is missing, forged, expired or not allowed for repo answers grant.ErrGrant and nothing else. The claims never hold a scope above what the credential gives.

func Chain

func Chain(auths ...Authenticator) Authenticator

Chain returns an Authenticator that answers with the first claims that one of auths gives, and grant.ErrGrant when none gives any.

type Rule

type Rule struct {
	Principals []string    `json:"principals"`
	Repos      []string    `json:"repos"`
	Scope      grant.Scope `json:"scope"`
}

Rule gives Scope on Repos to Principals. A principal is a subject text, or @domain for every email of the domain.

Directories

Path Synopsis
Package identitytest holds the conformance suite of identity.Authenticator and a signer of Access JWTs.
Package identitytest holds the conformance suite of identity.Authenticator 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 token authenticates a request by a signed grant.
Package token authenticates a request by a signed grant.
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL