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 ¶
- Variables
- func GeneratePKCE() (verifier, challenge string, err error)
- func PKCEChallenge(verifier string) string
- func RandomBase64(n int) string
- func Revoke(revocationEndpoint, clientID, token string) error
- func ValidateNonce(idToken, expectedNonce string) error
- type Discovery
- type TokenError
- type Tokens
Constants ¶
This section is empty.
Variables ¶
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 PKCEChallenge ¶
PKCEChallenge is the S256 code challenge for a verifier (RFC 7636 §4.2).
func RandomBase64 ¶
func Revoke ¶
Revoke asks the server to invalidate a token (RFC 7009). A 200 means it is gone or was never valid.
func ValidateNonce ¶
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"`
}
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 PasswordGrant ¶
PasswordGrant is the resource owner password credentials grant (RFC 6749 §4.3), for servers that authenticate users against their own user table.