Documentation
¶
Index ¶
- Constants
- Variables
- type Grant
- type Service
- func (s *Service) CreateToken(ctx context.Context, principal authn.Principal, expires *time.Time, ...) (Token, string, error)
- func (s *Service) Delegate(ctx context.Context, principal authn.Principal, expires *time.Time, ...) (Token, string, error)
- func (s *Service) Grants(ctx context.Context, principal authn.Principal, afterID int64) ([]Grant, bool, error)
- func (s *Service) RevokeGrant(ctx context.Context, principal authn.Principal, id int64) error
- func (s *Service) RevokeToken(ctx context.Context, principal authn.Principal, id int64) error
- func (s *Service) Tokens(ctx context.Context, principal authn.Principal) ([]Token, error)
- type Token
Constants ¶
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.
const MaxTokenLifetime = 90 * 24 * time.Hour
Variables ¶
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 (*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 ¶
RevokeGrant revokes one of the caller's MCP OAuth grants.