oauth2

package
v2.0.0-jwt-proto-refactor Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamClientID = "client_id"
	// ParamNonce             = "nonce"
	// ParamClientAuthMessage = "auth_message"
	ParamResponseType     = "response_type"
	ParamState            = "state"
	ParamScope            = "scope"
	ParamRedirectURI      = "redirect_uri"
	ParamCode             = "code"
	ParamProvider         = "provider"
	ParamAlg              = "algorithm"
	ParamError            = "error"
	ParamErrorDescription = "error_description"
	// ParamErrorUri          = "error_uri"
	ParamGrantType = "grant_type"
	ParamToken     = "token"

	ResponseTypeCode = "code"

	ErrorInvalidRequest = "invalid_request"
	// ErrorUnauthorizedClient      = "unauthorized_client"
	ErrorAccessDenied            = "access_denied"
	ErrorUnsupportedResponseType = "unsupported_response_type"
	// ErrorInvalidScope            = "invalid_scope"
	ErrorServerError            = "server_error"
	ErrorTemporarilyUnavailable = "temporarily_unavailable"

	GrantTypeAuthorizationCode = "authorization_code"

	KeyAccessToken = "access_token"
	KeyTokenType   = "token_type"
	KeyExpiresIn   = "expires_in"
	KeyIdToken     = "id_token"
	// KeyRefreshToken = "refresh_token"
	KeyScope = "scope"
)

Variables

This section is empty.

Functions

func BearerHeaderDecoder

func BearerHeaderDecoder(codecs ...securecookie.Codec) *bearerDecoder

func ContextWithToken

func ContextWithToken(parent context.Context, t *Token) context.Context

func CreateAuth

func CreateAuth(secret string) (string, string, error)

func OpenBrowserCMD

func OpenBrowserCMD(url string) *exec.Cmd

func VerifyAuth

func VerifyAuth(secret, nonce, authMessage string) (bool, error)

func Workflow

func Workflow(callbackURI string, configProvider ConfigProvider, authRequiredFunc AuthenticationRequiredFunc, handlerFunc AuthorizedHandleFunc) (mux.MiddlewareFunc, error)

Types

type AuthenticationRequiredFunc

type AuthenticationRequiredFunc func(r *http.Request) bool

type AuthorizeParams

type AuthorizeParams struct {
	ClientID     string
	ResponseType string
	State        string
	Scope        string
	RedirectURI  string
	Missing      []string
}

Params

func (*AuthorizeParams) FromURL

func (p *AuthorizeParams) FromURL(u *url.URL) bool

func (*AuthorizeParams) Has

func (p *AuthorizeParams) Has(param string) bool

func (*AuthorizeParams) ToMap

func (p *AuthorizeParams) ToMap() map[string]string

type AuthorizedHandleFunc

type AuthorizedHandleFunc func(t *Token, continueURL string, w http.ResponseWriter, r *http.Request)

type Client

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

Client

func NewClient

func NewClient(cfg *Config) *Client

func (*Client) GetAccessToken

func (c *Client) GetAccessToken(code string) (*Token, error)

func (*Client) GetURLAuthorizationURL

func (c *Client) GetURLAuthorizationURL() (string, error)

type CodeChallenge

type CodeChallenge struct {
	Alg           string
	EncryptedCode string
}

CodeChallenge

func CreateCodeChallenge

func CreateCodeChallenge(secret string) (*CodeChallenge, string, error)

func (*CodeChallenge) ProcessChallenge

func (c *CodeChallenge) ProcessChallenge(secret string) ([]byte, error)

type CodeChallengeResult

type CodeChallengeResult struct {
	Alg           string
	ClientID      string
	EncryptedCode string
}

CodeChallengeResult

func (*CodeChallengeResult) FromURL

func (c *CodeChallengeResult) FromURL(u *url.URL) error

func (*CodeChallengeResult) GetCode

func (c *CodeChallengeResult) GetCode(secret string) ([]byte, error)

type Config

type Config struct {
	ClientID              string `json:"client_id"`
	Secret                string `json:"secret"`
	Scope                 string `json:"scope"`
	State                 string `json:"state"`
	CallbackURL           string `json:"callback_url"`
	AuthorizationEndpoint string `json:"authorize_endpoint"`
	TokenEndpoint         string `json:"token_endpoint"`
	AuthorityCertFilename string `json:"authority_certificate"`
}

type ConfigProvider

type ConfigProvider func() (*Config, error)

type GetAccessTokenParams

type GetAccessTokenParams struct {
	ClientID string
	Code     string
}

func (*GetAccessTokenParams) FromURL

func (p *GetAccessTokenParams) FromURL(u *url.URL) error

type Provider

type Provider interface {
	AuthorizeURL() string
	AccessTokenURL() string
	EncodedCertificate() string
	SignatureAlg() string
	JWK() string
}

type RedirectURIHandler

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

RedirectURIHandler

func NewRedirectURIHandler

func NewRedirectURIHandler(redirectURI string, tc *tls.Config) *RedirectURIHandler

func (*RedirectURIHandler) GetCode

func (h *RedirectURIHandler) GetCode() (string, error)

type Token

type Token struct {
	IdToken     string `json:"id_token"`
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int64  `json:"expires_in"`
	Scope       string `json:"scope"`
}

func TokenFromContext

func TokenFromContext(ctx context.Context) *Token

Jump to

Keyboard shortcuts

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