goath

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: MIT Imports: 4 Imported by: 0

README

goath

This package is an attempt to provide nice OAuth2 / OpenID Connect (OIDC) interface.

The primarly goal is to nicely integrate with https://github.com/volatiletech/authboss.

OAuth2 integration is provided in the base package. For OpenID Connect (OIDC) providers, please have a look at the subpackages.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OAuth2

type OAuth2 struct {
	Config           *oauth2.Config
	UserInfoEndpoint string
	HTTPClient       *http.Client // will use http.DefaultClient if let nil
}

OAuth2 implements a Provider for the OAuth2 flow.

func (*OAuth2) AuthCodeURL

func (o *OAuth2) AuthCodeURL(state string) (string, error)

AuthCodeURL returns the Auth-URL to redirect the user to

func (*OAuth2) Exchange

func (o *OAuth2) Exchange(_state, code string) (token *oauth2.Token, unmarshalUser func(interface{}) error, err error)

Exchange exchanges the code and provides a way to unmarshal the user info

func (*OAuth2) SetRedirectURL

func (o *OAuth2) SetRedirectURL(url string)

SetRedirectURL sets the local callback URL.

type Provider

type Provider interface {
	// SetRedirectURL sets the local callback URL.
	SetRedirectURL(url string)
	// AuthCodeURL returns the Provider URL to redirect the user to.
	AuthCodeURL(state string) (string, error)
	// Exchange exchanges the code and provides a way to unmarshal the user info.
	// state might be useful to link to the previous call of AuthCodeURL,
	// but its the caller responsibility to check its value for CSRF protection.
	//
	//      var user struct {
	//      	ID    string `json:"sub"`
	//      	Email string `json:"email"`
	//      	Name  string `json:"name"`
	//      }
	//      err = unmarshalUser(&user)
	Exchange(state, code string) (token *oauth2.Token, unmarshalUser func(interface{}) error, err error)
}

Provider is an interface suitable for OAuth2 and OIDC flows.

Directories

Path Synopsis
package caos is a WIP (not working yet) to provides a Provider for OpenID Connect (oidc), backed by the github.com/caos/oidc module.
package caos is a WIP (not working yet) to provides a Provider for OpenID Connect (oidc), backed by the github.com/caos/oidc module.
package coreos provides a Provider for OpenID Connect (oidc), backed by the github.com/coreos/go-oidc module.
package coreos provides a Provider for OpenID Connect (oidc), backed by the github.com/coreos/go-oidc module.
package goauthboss provides an Init method to integrate with authboss.
package goauthboss provides an Init method to integrate with authboss.

Jump to

Keyboard shortcuts

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