oauth2

package
v1.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OAuth2TypeDefault = "oauth2"
)

Variables

View Source
var (
	OAuth2Infos = make(map[string]*OAuth2Info)
	OAutherMap  = make(map[string]OAuther)
)

Functions

func NewOAuth2Service

func NewOAuth2Service()

Types

type BasicUserInfo

type BasicUserInfo struct {
	Name    string `json:"name"`
	Email   string `json:"email"`
	Display string `json:"display"`
}

type OAuth2Default added in v1.1.0

type OAuth2Default struct {
	*oauth2.Config
	ApiUrl     string
	ApiMapping map[string]string
}

func (*OAuth2Default) UserInfo added in v1.1.0

func (o *OAuth2Default) UserInfo(token string) (*BasicUserInfo, error)

type OAuth2Info

type OAuth2Info struct {
	ClientId     string
	ClientSecret string
	Scopes       []string
	AuthUrl      string
	TokenUrl     string
	ApiUrl       string // get user info
	Enabled      bool
	ApiMapping   map[string]string
}

type OAuther

type OAuther interface {
	UserInfo(token string) (*BasicUserInfo, error)

	AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
	Exchange(ctx context.Context, code string) (*oauth2.Token, error)
	Client(ctx context.Context, t *oauth2.Token) *http.Client
}

Jump to

Keyboard shortcuts

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