identity

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 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 caller token.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allows

func Allows(rules []Rule, subject, repo string, email bool) bool

Allows reports whether the rules let subject land on repo. An email is not case sensitive, so with email true the match ignores case. Any other claim is an opaque identifier and matches exactly.

func Claims

func Claims(repo, subject string, exp int64) token.Claims

Claims is the claims of a human identity that may land on repo.

func Validate

func Validate(rules []Rule) error

Validate checks the rules.

Types

type Authenticator

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

Authenticator reads the credential of r and returns the claims that it gives. repo is the repository text that the call names, empty when the call names none. A credential that is missing, forged, expired or not allowed for repo answers token.ErrToken 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 token.ErrToken when none gives any. It skips a nil member.

type Rule

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

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

Directories

Path Synopsis
Package bearer authenticates a request by a signed caller token in the header Authorization.
Package bearer authenticates a request by a signed caller token in the header Authorization.
Package identitytest holds the conformance suite of identity.Authenticator and a signer of JWTs.
Package identitytest holds the conformance suite of identity.Authenticator and a signer of JWTs.
Package oidc authenticates a request by a signed OIDC JWT from any issuer, and maps a claim of the JWT to the scope land 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 the scope land on a repository with rules.
Package usertoken authenticates a request by a per-user token that an operator issued.
Package usertoken authenticates a request by a per-user token that an operator issued.

Jump to

Keyboard shortcuts

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