oidc

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthorizationError

func IsAuthorizationError(err error) bool

IsAuthorizationError asserts authorizationError.

func IsRefreshError

func IsRefreshError(err error) bool

IsRefreshError asserts refreshError.

func IsTokenInvalidError

func IsTokenInvalidError(err error) bool

IsTokenInvalidError asserts tokenInvalidError.

func IsTokenIssuedAtError

func IsTokenIssuedAtError(err error) bool

IsTokenIssuedAtError asserts tokenIssuedAtError.

Types

type CallbackResult

type CallbackResult struct {
	Interface interface{}
	Error     error
}

CallbackResult is used by our channel to store callback results.

type IDToken

type IDToken struct {
	// Email claim.
	Email string
}

IDToken is our custom representation of the details of a JWT we care about.

func ParseIDToken

func ParseIDToken(tokenString string) (token *IDToken, err error)

ParseIDToken takes a jwt token and returns an IDToken, which is just a custom struct with only the email claim in it. Since that is all that gsctl cares about for now.

type JSONWebKeys

type JSONWebKeys struct {
	Kty string   `json:"kty"`
	Kid string   `json:"kid"`
	Use string   `json:"use"`
	N   string   `json:"n"`
	E   string   `json:"e"`
	X5c []string `json:"x5c"`
}

JSONWebKeys represents one JWS web key.

type Jwks

type Jwks struct {
	Keys []JSONWebKeys `json:"keys"`
}

Jwks holds JSON web keys.

type PKCEResponse

type PKCEResponse struct {
	AccessToken      string `json:"access_token"`
	ExpiresIn        int    `json:"expires_in"`
	IDToken          string `json:"id_token"`
	Scope            string `json:"scope"`
	TokenType        string `json:"token_type"`
	RefreshToken     string `json:"refresh_token"`
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

PKCEResponse represents the result we get from the PKCE flow.

func RunPKCE

func RunPKCE(audience string) (PKCEResponse, error)

RunPKCE starts the Authorization Code Grant Flow with PKCE. It does roughly the following steps: 1. Craft the authorization URL and open the users browser. 2. Starting a callback server to wait for the redirect with the code. 3. Exchanging the code for an access token and id token.

type RefreshRequest

type RefreshRequest struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	GrantType    string `json:"grant_type"`
	RefreshToken string `json:"refresh_token"`
}

RefreshRequest represents the request that the token refresh endpoint expects in the JSON body. It gets marshalled to JSON.

type RefreshResponse

type RefreshResponse struct {
	AccessToken      string `json:"access_token"`
	ExpiresIn        int    `json:"expires_in"`
	IDToken          string `json:"id_token"`
	Scope            string `json:"scope"`
	TokenType        string `json:"token_type"`
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

RefreshResponse represents the result we get when we use a refersh token to get a new access token.

func RefreshToken

func RefreshToken(refreshToken string) (refreshResponse RefreshResponse, err error)

RefreshToken performs a POST call to the auth0 token endpoint with a refresh token and returns a RefreshToken response, which includes a new access token.

Jump to

Keyboard shortcuts

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