client

package
v0.0.0-...-461217a Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractClaims

func ExtractClaims(t *oidc.IDToken) (map[string]interface{}, error)

ExtractClaims returns claims for a given IDToken

func GenerateState

func GenerateState(r *http.Request, secret string) string

GenerateState performs a base64 encoded hash of the client user agent This is a poor way to permform CSRF protection, but better than a hardcoded value.

func VerifyState

func VerifyState(r *http.Request, s string, secret string) bool

VerifyState performs verification for CSRF

Types

type Client

type Client struct {
	Config     *config.OIDC
	Provider   *oidc.Provider
	Verifier   *oidc.IDTokenVerifier
	Scopes     []string
	HTTPClient *http.Client
}

Client is an OpenID client, it handles all OIDC/OAuth2 interactions between the provider and the creator of this Client

func New

func New(cfg *config.OIDC) *Client

func (*Client) AuthCodeToIDToken

func (c *Client) AuthCodeToIDToken(ctx context.Context, authCode string) (*oauth2.Token, string, *oidc.IDToken, error)

AuthCodeToToken converts an authorization code into a IDToken

func (*Client) AuthCodeURL

func (c *Client) AuthCodeURL(r *http.Request, secret string) string

AuthCodeURL generate an authorisation code URL based on the application name. The function uses also extra auth code options configured for this client

func (*Client) Context

func (c *Client) Context() context.Context

Context returns Client context

func (*Client) Healthz

func (c *Client) Healthz() bool

Healthz reports if the client is ready to perform requests to the issuer

func (*Client) OAuth2Config

func (c *Client) OAuth2Config() *oauth2.Config

OAuth2Config return the OAuth2Config for the client

func (*Client) PrepareScopes

func (c *Client) PrepareScopes()

PrepareScopes setup scopes slice based on the client configuration

func (*Client) ProviderSetup

func (c *Client) ProviderSetup() error

ProviderSetup setup Client's provider

func (*Client) Setup

func (c *Client) Setup() error

Setup setups Client

func (*Client) TLSSetup

func (c *Client) TLSSetup() error

TLSSetup setup tls transport for the client

func (*Client) VerifierSetup

func (c *Client) VerifierSetup()

VerifierSetup setup Client's verifier

Jump to

Keyboard shortcuts

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