Documentation
¶
Index ¶
- Variables
- type OidcClient
- func (o *OidcClient) Do(req *http.Request) (*http.Response, error)
- func (o *OidcClient) FetchNewIncusTokenURL(req *http.Request) (string, *oidc.DeviceAuthorizationResponse, rp.RelyingParty, error)
- func (o *OidcClient) GetAccessToken() string
- func (o *OidcClient) GetOIDCTokens() *oidc.Tokens[*oidc.IDTokenClaims]
- func (o *OidcClient) WaitForToken(resp *oidc.DeviceAuthorizationResponse, provider rp.RelyingParty) error
Constants ¶
This section is empty.
Variables ¶
var ErrOIDCExpired = fmt.Errorf("OIDC token expired, please re-try the request")
ErrOIDCExpired is returned when the token is expired and we can't retry the request ourselves.
Functions ¶
This section is empty.
Types ¶
type OidcClient ¶
type OidcClient struct {
// contains filtered or unexported fields
}
OidcClient is a structure encapsulating an HTTP client, OIDC transport, and a token for OpenID Connect (OIDC) operations.
func NewOIDCClient ¶
func NewOIDCClient(tokensFile string, serverCert *x509.Certificate) *OidcClient
NewOIDCClient constructs a new OidcClient, ensuring the token field is non-nil to prevent panics during authentication.
func (*OidcClient) Do ¶
Do function executes an HTTP request using the OidcClient's http client, and manages authorization by refreshing or authenticating as needed. If the request fails with an HTTP Unauthorized status, it attempts to refresh the access token, or perform an OIDC authentication if refresh fails.
func (*OidcClient) FetchNewIncusTokenURL ¶
func (o *OidcClient) FetchNewIncusTokenURL(req *http.Request) (string, *oidc.DeviceAuthorizationResponse, rp.RelyingParty, error)
func (*OidcClient) GetAccessToken ¶
func (o *OidcClient) GetAccessToken() string
GetAccessToken returns the Access Token from the OidcClient's tokens, or an empty string if no tokens are present.
func (*OidcClient) GetOIDCTokens ¶
func (o *OidcClient) GetOIDCTokens() *oidc.Tokens[*oidc.IDTokenClaims]
GetOIDCTokens returns the current OIDC tokens, if any.
func (*OidcClient) WaitForToken ¶
func (o *OidcClient) WaitForToken(resp *oidc.DeviceAuthorizationResponse, provider rp.RelyingParty) error