oidcclient

package
v1.21.108 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 12 Imported by: ? 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 oidcclient is the client half of an OAuth 2.0 / OIDC login for a CLI: provider discovery, PKCE, the token endpoint grants (authorization code, refresh, password) and revocation. It holds no state; persistence lives in the credentials package and the per-context refresh policy in remote.

Index

Constants

This section is empty.

Variables

View Source
var HTTPClient = commonshttp.NewClient().
	Timeout(30*time.Second).
	Header("Accept", "application/json").
	UserAgent("clicky-cli")

HTTPClient sends every discovery, token and revocation request.

Functions

func GeneratePKCE

func GeneratePKCE() (verifier, challenge string, err error)

func PKCEChallenge

func PKCEChallenge(verifier string) string

PKCEChallenge is the S256 code challenge for a verifier (RFC 7636 §4.2).

func RandomBase64

func RandomBase64(n int) string

func Revoke

func Revoke(revocationEndpoint, clientID, token string) error

Revoke asks the server to invalidate a token (RFC 7009). A 200 means it is gone or was never valid.

func ValidateNonce

func ValidateNonce(idToken, expectedNonce string) error

Types

type Discovery

type Discovery struct {
	Issuer                string `json:"issuer,omitempty"`
	AuthorizationEndpoint string `json:"authorization_endpoint"`
	TokenEndpoint         string `json:"token_endpoint"`
	UserinfoEndpoint      string `json:"userinfo_endpoint"`
	RevocationEndpoint    string `json:"revocation_endpoint,omitempty"`
	// GrantTypesSupported lists the grants the token endpoint accepts (RFC 8414).
	GrantTypesSupported []string `json:"grant_types_supported,omitempty"`
}

func Discover

func Discover(discoveryURL string) (*Discovery, error)

type TokenError

type TokenError struct {
	StatusCode  int    `json:"-"`
	Code        string `json:"error"`
	Description string `json:"error_description"`
	Body        string `json:"-"`
}

TokenError is a non-2xx response from the token endpoint, carrying the RFC 6749 §5.2 `error` code. Callers need that code rather than the message, because it is what separates a terminally dead grant from a transient failure — see Terminal.

func (*TokenError) Error

func (e *TokenError) Error() string

func (*TokenError) Terminal

func (e *TokenError) Terminal() bool

Terminal reports whether the grant is permanently dead. `invalid_grant` means the server will never accept this token again, so retrying it — or keeping it on disk — is pointless; only a fresh login recovers.

type Tokens

type Tokens struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	IDToken      string    `json:"id_token"`
	ExpiresAt    time.Time `json:"expires_at"`
}

func ExchangeCode

func ExchangeCode(tokenEndpoint, clientID, code, redirectURI, verifier string) (*Tokens, error)

func PasswordGrant

func PasswordGrant(tokenEndpoint, clientID, username, password string) (*Tokens, error)

PasswordGrant is the resource owner password credentials grant (RFC 6749 §4.3), for servers that authenticate users against their own user table.

func RefreshToken

func RefreshToken(tokenEndpoint, clientID, refreshToken string) (*Tokens, error)

Jump to

Keyboard shortcuts

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