oauth2client

package
v0.22.187 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client of OAuth2

func Load

func Load(cfgfile string) ([]*Client, error)

Load returns new Provider

func LoadClient

func LoadClient(file string) (*Client, error)

LoadClient returns a single `Client` loaded from config

func New

func New(cfg *ClientConfig) (*Client, error)

New returns new Provider

func (*Client) Config

func (p *Client) Config() *ClientConfig

Config returns OAuth2 configuration

func (*Client) CreateTokenRequest

func (p *Client) CreateTokenRequest(v url.Values, authStyle oauth2.AuthStyle) (*http.Request, error)

CreateTokenRequest returns a new *http.Request to retrieve a new token from tokenURL using the provided clientID, clientSecret, and POST body parameters.

func (*Client) SetClientSecret

func (p *Client) SetClientSecret(s string) *Client

SetClientSecret sets Client Secret

func (*Client) SetPubKey

func (p *Client) SetPubKey(newPubKey *rsa.PublicKey)

SetPubKey replaces the OAuth public signing key loaded from configuration During normal operation, identity provider's public key is read from config on start-up.

type ClientConfig

type ClientConfig struct {
	// ProviderID specifies Auth.Provider ID
	ProviderID string `json:"provider_id" yaml:"provider_id"`
	// ClientID specifies client ID
	ClientID string `json:"client_id" yaml:"client_id"`
	// ClientSecret specifies client secret
	ClientSecret string `json:"client_secret" yaml:"client_secret"`
	// Scopes specifies the list of scopes
	Scopes []string `json:"scopes" yaml:"scopes"`
	// ResponseType specifies the response type, default is "code"
	ResponseType string `json:"response_type" yaml:"response_type"`
	// JwksURL specifies JWKS URL
	JwksURL string `json:"jwks_url" yaml:"jwks_url"`
	// AuthURL specifies auth URL
	AuthURL string `json:"auth_url" yaml:"auth_url"`
	// TokenURL specifies token URL
	TokenURL string `json:"token_url"  yaml:"token_url"`
	// UserinfoURL specifies userinfo URL
	UserinfoURL string `json:"userinfo_url"  yaml:"userinfo_url"`
	// WellknownURL specifies URL for wellknown info
	WellknownURL string `json:"wellknown"  yaml:"wellknown"`
	// RedirectURL specifies redirect URL
	RedirectURL string `json:"redirect_url"  yaml:"redirect_url"`
	// PubKey specifies PEM encoded Public Key of the JWT issuer
	PubKey string `json:"pubkey" yaml:"pubkey"`
	// Prompt parameter, such as `consent`
	Prompt string `json:"prompt" yaml:"prompt"`
	// Audience of JWT token
	Audience string `json:"audience" yaml:"audience"`
	// Issuer of JWT token
	Issuer string `json:"issuer" yaml:"issuer"`
	// IDPParam specifies the IDP parameters
	IDPParam *IDPParam `json:"idp_param" yaml:"idp_param"`
	// Domains specifies the list of domains to filter by
	Domains []string `json:"domains" yaml:"domains"`
	// Emails specifies the list of emails to filter by
	Emails []string `json:"emails" yaml:"emails"`
}

ClientConfig provides OAuth2 configuration

type Config

type Config struct {
	// Clients provides a list of supported clients
	Clients []*ClientConfig `json:"clients" yaml:"clients"`
}

Config provides OAuth2 configuration for supported clients

func LoadConfig

func LoadConfig(file string) (*Config, error)

LoadConfig returns configuration loaded from a file

type IDPParam added in v0.9.0

type IDPParam struct {
	// Name specifies the name of the IDP parameter: idpuser.email|identity_provider
	Name string `json:"name" yaml:"name"`
	// Value specifies the value the IDP parameter: email|domain|{value}
	Value string `json:"value" yaml:"value"`
}

IDPParam is a struct for IDP parameter

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider of OAuth2 clients

func LoadProvider

func LoadProvider(location string) (*Provider, error)

LoadProvider returns Provider

func NewProvider added in v0.9.0

func NewProvider(cfg *Config) (*Provider, error)

NewProvider returns Provider

func (*Provider) Client

func (p *Provider) Client(provider string) *Client

Client returns Client by provider

func (*Provider) ClientForDomain added in v0.9.0

func (p *Provider) ClientForDomain(domain string) *Client

ClientForDomain returns Client by domain

func (*Provider) ClientForEmail added in v0.10.0

func (p *Provider) ClientForEmail(email string) *Client

ClientForEmail returns Client by email

func (*Provider) ClientForProvider added in v0.9.0

func (p *Provider) ClientForProvider(provider string) *Client

ClientForDomain returns Client by domain

func (*Provider) ClientNames added in v0.5.0

func (p *Provider) ClientNames() []string

ClientNames returns list of supported clients

func (*Provider) Domains added in v0.9.0

func (p *Provider) Domains() []string

Domains returns list of supported domains

func (*Provider) Emails added in v0.10.0

func (p *Provider) Emails() []string

Emails returns list of configured emails

func (*Provider) RegisterClient added in v0.9.0

func (p *Provider) RegisterClient(c *ClientConfig, override bool) error

RegisterClient registers new client

Jump to

Keyboard shortcuts

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