account

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 8 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

Index

Constants

View Source
const MaxDelegatedTokenLifetime = time.Hour

MaxDelegatedTokenLifetime bounds tokens minted by Delegate: they exist so a service account can hand a narrowed credential to a single job.

View Source
const MaxTokenLifetime = 90 * 24 * time.Hour

Variables

View Source
var (
	ErrForbidden = errors.New("forbidden")
	ErrInvalid   = errors.New("invalid token request")
)

Functions

This section is empty.

Types

type Grant

type Grant struct {
	ID         int64     `json:"id"`
	ClientName string    `json:"client_name"`
	Scope      string    `json:"scope,omitempty"`
	CreatedAt  time.Time `json:"created_at"`
	LastUsedAt time.Time `json:"last_used_at"`
	ExpiresAt  time.Time `json:"expires_at"`
}

Grant is a connected MCP client as the account owner sees it.

type Service

type Service struct {
	Manager    authn.TokenManager
	Authorizer repositoryAuthorizer
}

func (*Service) CreateToken

func (s *Service) CreateToken(ctx context.Context, principal authn.Principal, expires *time.Time, repositoryIDs []int64) (Token, string, error)

func (*Service) Delegate

func (s *Service) Delegate(ctx context.Context, principal authn.Principal, expires *time.Time, repositoryIDs []int64) (Token, string, error)

Delegate lets an administrator authenticated with an API token mint a further token for the same user that is narrower than its own: a non-empty repository ceiling inside the caller's, and a mandatory expiry within MaxDelegatedTokenLifetime. Interactive sessions use CreateToken instead.

func (*Service) Grants

func (s *Service) Grants(ctx context.Context, principal authn.Principal, afterID int64) ([]Grant, bool, error)

Grants lists the caller's live MCP OAuth grants. Like token management this is reserved for interactive sessions: an access token must not enumerate or revoke its siblings.

func (*Service) RevokeGrant

func (s *Service) RevokeGrant(ctx context.Context, principal authn.Principal, id int64) error

RevokeGrant revokes one of the caller's MCP OAuth grants.

func (*Service) RevokeToken

func (s *Service) RevokeToken(ctx context.Context, principal authn.Principal, id int64) error

func (*Service) Tokens

func (s *Service) Tokens(ctx context.Context, principal authn.Principal) ([]Token, error)

type Token

type Token struct {
	ID            int64      `json:"id"`
	Prefix        string     `json:"prefix"`
	RepositoryIDs []int64    `json:"repository_ids,omitempty"`
	CreatedAt     time.Time  `json:"created_at"`
	LastUsedAt    *time.Time `json:"last_used_at,omitempty"`
	ExpiresAt     *time.Time `json:"expires_at,omitempty"`
}

Jump to

Keyboard shortcuts

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