Documentation
¶
Index ¶
- func OAuthClientID() string
- func OpenBrowser(urlStr string) error
- func RevokeCredentials(creds *Credentials, clientID string) []string
- func RevokeToken(revocationEndpoint, clientID, token, tokenTypeHint string) error
- func Save(creds *Credentials, path string) error
- type Credentials
- type DeviceCodeResponse
- type OIDCConfig
- type TokenResponse
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OAuthClientID ¶
func OAuthClientID() string
OAuthClientID returns the OAuth client ID used for the device flow, overridable via MEMORY_OAUTH_CLIENT_ID (e.g. to point the CLI at a dev Zitadel instance whose memory-cli app has a different client ID).
func OpenBrowser ¶
func RevokeCredentials ¶
func RevokeCredentials(creds *Credentials, clientID string) []string
RevokeCredentials attempts to revoke all tokens in the given credentials using the OIDC revocation endpoint discovered from the stored issuer URL. It revokes the refresh token first (higher-value target), then the access token. Returns a list of warnings for any failures — callers should log these but not block.
func RevokeToken ¶
RevokeToken revokes a single OAuth token via the OIDC revocation endpoint (RFC 7009). tokenTypeHint should be "access_token" or "refresh_token". Returns nil if revocation succeeds or the endpoint is not available (best-effort).
func Save ¶
func Save(creds *Credentials, path string) error
Types ¶
type Credentials ¶
type Credentials struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresAt time.Time `json:"expires_at"`
UserEmail string `json:"user_email,omitempty"`
IssuerURL string `json:"issuer_url,omitempty"`
}
func Load ¶
func Load(path string) (*Credentials, error)
func (*Credentials) IsExpired ¶
func (c *Credentials) IsExpired() bool
type DeviceCodeResponse ¶
type DeviceCodeResponse struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
VerificationURIComplete string `json:"verification_uri_complete"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
func RequestDeviceCode ¶
func RequestDeviceCode(config *OIDCConfig, clientID string, scopes []string) (*DeviceCodeResponse, error)
type OIDCConfig ¶
type OIDCConfig struct {
Issuer string `json:"issuer"`
DeviceAuthorizationEndpoint string `json:"device_authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
AuthorizationEndpoint string `json:"authorization_endpoint,omitempty"`
RevocationEndpoint string `json:"revocation_endpoint,omitempty"`
JwksURI string `json:"jwks_uri,omitempty"`
}
func DiscoverOIDC ¶
func DiscoverOIDC(issuerURL string) (*OIDCConfig, error)
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int `json:"expires_in"`
TokenType string `json:"token_type"`
IDToken string `json:"id_token,omitempty"`
}
func PollForToken ¶
func PollForToken(config *OIDCConfig, deviceCode, clientID string, interval, expiresIn int) (*TokenResponse, error)
func RefreshToken ¶
func RefreshToken(config *OIDCConfig, refreshToken, clientID string) (*TokenResponse, error)