oauth

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: BSD-3-Clause-Clear Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertExchangeInfo

type CertExchangeInfo struct {
	HTTPClient *http.Client
	Audience   []string
}

type ClientCredentials

type ClientCredentials struct {
	ClientAuth interface{} // the supported types for this are a JWK (implying jwt-bearer auth) or a string (implying client secret auth)
	ClientID   string
}

type Token

type Token struct {
	AccessToken      string        `json:"access_token"`
	TokenType        string        `json:"token_type"`
	ExpiresIn        int64         `json:"expires_in,omitempty"`
	Scope            string        `json:"scope,omitempty"`
	ExpirationBuffer time.Duration `json:"-"`
	// contains filtered or unexported fields
}

func DoCertExchange

func DoCertExchange(ctx context.Context, tokenEndpoint string, exchangeInfo CertExchangeInfo, clientCredentials ClientCredentials, key jwk.Key) (*Token, error)

func DoTokenExchange

func DoTokenExchange(ctx context.Context, client *http.Client, tokenEndpoint string, scopes []string, clientCredentials ClientCredentials, tokenExchange TokenExchangeInfo, key jwk.Key) (*Token, error)

func GetAccessToken

func GetAccessToken(client *http.Client, tokenEndpoint string, scopes []string, clientCredentials ClientCredentials, dpopPrivateKey jwk.Key) (*Token, error)

GetAccessToken this misses the flow where the Authorization server can tell us the next nonce to use. missing this flow costs us a bit in efficiency (a round trip per access token) but this is still correct because

func (Token) Expired

func (t Token) Expired() bool

Expired reports whether the token's lifetime has elapsed. Use `ShouldRenew()` to determine if the expiration may happen before `ExpirationBuffer` units of time from now.

func (Token) ShouldRenew added in v0.35.0

func (t Token) ShouldRenew() bool

ShouldRenew reports whether the token expires within its ExpirationBuffer. Tokens without an expires_in value are treated as non-expiring.

type TokenExchangeInfo

type TokenExchangeInfo struct {
	SubjectToken string
	// SubjectTokenType declares the type of SubjectToken per RFC 8693 §2.1.
	// Defaults to urn:ietf:params:oauth:token-type:access_token when empty.
	SubjectTokenType string
	Audience         []string
}

Jump to

Keyboard shortcuts

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