Help us shape the future of Go! Take the 2026 Go Developer Survey

oauth2client

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: Apache-2.0 Imports: 12 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"`
	// 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"`
	// Audience of JWT token
	Audience string `json:"audience" yaml:"audience"`
	// Issuer of JWT token
	Issuer string `json:"issuer" yaml:"issuer"`
}

ClientConfig provides OAuth2 configuration

type Config

type Config struct {
	// Clients provides a list of supported clients
	Clients []*ClientConfig
}

Config provides OAuth2 configuration for supported clients

func LoadConfig

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

LoadConfig returns configuration loaded from a file

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 (*Provider) Client

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

Client returns Client by provider

func (*Provider) ClientNames added in v0.5.0

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

ClientNames returns list of supported clients

Jump to

Keyboard shortcuts

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