auth

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDiscoveryCache

func ClearDiscoveryCache()

ClearDiscoveryCache empties the OIDC discovery cache.

func GetDeviceAuthorizationEndpoint

func GetDeviceAuthorizationEndpoint(idpDomain string) (string, error)

GetDeviceAuthorizationEndpoint returns the device auth endpoint from discovery.

func GetRevocationEndpoint

func GetRevocationEndpoint(idpDomain string) (string, error)

GetRevocationEndpoint returns the revocation endpoint, or "" if not supported.

func GetTokenEndpoint

func GetTokenEndpoint(idpDomain string) (string, error)

GetTokenEndpoint returns the token endpoint from OIDC discovery.

func RefreshAccessToken

func RefreshAccessToken(s *store.Store, idpClientID string) (string, error)

RefreshAccessToken uses a stored refresh token to obtain a new access token.

func RequestClientCredentialsAuthorization

func RequestClientCredentialsAuthorization(s *store.Store, cfg ClientCredentialsConfig) error

RequestClientCredentialsAuthorization performs the client credentials flow.

func RequestDeviceAuthorization

func RequestDeviceAuthorization(s *store.Store, cfg DeviceAuthConfig) error

RequestDeviceAuthorization runs the full device authorization flow: discover endpoints, request device code, open browser, poll for token.

func RequestIdentityFileAuthorization

func RequestIdentityFileAuthorization(s *store.Store, identityFile string) error

RequestIdentityFileAuthorization reads a Ziti identity JSON file, validates it, and stores the certificate material in the credential store.

func RequestIdentityJSONAuthorization

func RequestIdentityJSONAuthorization(s *store.Store, jsonContent string) error

RequestIdentityJSONAuthorization takes raw identity JSON content (not a file path), validates it, and stores the certificate material in the credential store.

func RevokeRefreshToken

func RevokeRefreshToken(s *store.Store, idpClientID string) error

RevokeRefreshToken revokes the stored refresh token via the IdP's revocation endpoint.

func StoreTokens

func StoreTokens(s *store.Store, tr *TokenResponse) error

StoreTokens saves token data from a token response into the credential store.

func StoreUPDBCredentials

func StoreUPDBCredentials(s *store.Store, controllerHost, username, password string) error

StoreUPDBCredentials saves UPDB (username/password) credentials to the store.

Types

type ClientCredentialsConfig

type ClientCredentialsConfig struct {
	ZitiControllerHost string
	IDPDomain          string
	IDPClientID        string
	IDPClientSecret    string
	Audience           string
	Scopes             []string
}

ClientCredentialsConfig holds parameters for client credentials flow.

type DeviceAuthConfig

type DeviceAuthConfig struct {
	IDPDomain string
	ClientID  string
	Audience  string
	Scopes    string
}

DeviceAuthConfig holds parameters for the device authorization flow.

type DeviceCodeResult

type DeviceCodeResult struct {
	DeviceCode              string
	UserCode                string
	VerificationURI         string
	VerificationURIComplete string
	TokenEndpoint           string
	ClientID                string
	Interval                int
	ExpiresIn               int
}

DeviceCodeResult holds the result of requesting a device code (non-blocking step 1).

func RequestDeviceCode

func RequestDeviceCode(cfg DeviceAuthConfig) (*DeviceCodeResult, error)

RequestDeviceCode performs step 1 of the device auth flow: requests a device code without blocking. Returns the result for the caller to present to the user.

type OIDCDiscoveryDocument

type OIDCDiscoveryDocument struct {
	Issuer                           string   `json:"issuer"`
	AuthorizationEndpoint            string   `json:"authorization_endpoint,omitempty"`
	TokenEndpoint                    string   `json:"token_endpoint"`
	UserinfoEndpoint                 string   `json:"userinfo_endpoint,omitempty"`
	JwksURI                          string   `json:"jwks_uri,omitempty"`
	RegistrationEndpoint             string   `json:"registration_endpoint,omitempty"`
	ScopesSupported                  []string `json:"scopes_supported,omitempty"`
	ResponseTypesSupported           []string `json:"response_types_supported,omitempty"`
	GrantTypesSupported              []string `json:"grant_types_supported,omitempty"`
	SubjectTypesSupported            []string `json:"subject_types_supported,omitempty"`
	IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported,omitempty"`
	TokenEndpointAuthMethods         []string `json:"token_endpoint_auth_methods_supported,omitempty"`
	RevocationEndpoint               string   `json:"revocation_endpoint,omitempty"`
	IntrospectionEndpoint            string   `json:"introspection_endpoint,omitempty"`
	DeviceAuthorizationEndpoint      string   `json:"device_authorization_endpoint,omitempty"`
}

OIDCDiscoveryDocument represents the OpenID Connect discovery response.

func FetchOIDCDiscoveryDocument

func FetchOIDCDiscoveryDocument(idpDomain string) (*OIDCDiscoveryDocument, error)

FetchOIDCDiscoveryDocument fetches and caches the OIDC discovery document.

type TokenResponse

type TokenResponse struct {
	AccessToken      string
	RefreshToken     string
	ExpiresIn        int64
	Error            string
	ErrorDescription string
}

TokenResponse is the exported version of tokenResponse for use by meta-tools.

func PollDeviceTokenOnce

func PollDeviceTokenOnce(tokenEndpoint, deviceCode, clientID string) (*TokenResponse, error)

PollDeviceTokenOnce polls the token endpoint once (non-blocking). Returns the token response. Check .Error for "authorization_pending".

Jump to

Keyboard shortcuts

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