oauth2s

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: Apache-2.0 Imports: 10 Imported by: 4

README

oauth2s

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RequestFormDataCacheKey = `oauth2RequestForm`

	PasswordAuthorizationHandler = func(ctx context.Context, username, password string) (userID string, err error) {
		return
	}

	UserAuthorizeHandler = func(w http.ResponseWriter, r *http.Request) (userID string, err error) {
		ctx := r.Context().(echo.Context)
		v := ctx.Session().Get(`uid`)
		if v == nil {
			ctx.Session().Set(RequestFormDataCacheKey, ctx.Forms())
			err = ctx.Redirect(`/oauth2/login`)
			return
		}
		userID = v.(string)
		return
	}

	InternalErrorHandler = func(err error) (re *errors.Response) {
		return
	}

	ResponseErrorHandler = func(re *errors.Response) {
	}
)
View Source
var Default = NewConfig()

Functions

func NewManager

func NewManager(config *Config) (*manage.Manager, error)

func NewServer

func NewServer(config *Config) (*server.Server, error)

Types

type Config

type Config struct {
	JWTKeyID    string
	JWTKey      []byte
	JWTMethod   jwt.SigningMethod
	Store       oauth2.TokenStore
	ClientStore oauth2.ClientStore
	HandlerInfo *HandlerInfo
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

func (*Config) Init

func (c *Config) Init(options ...OptionsSetter) error

func (*Config) InitConfig

func (c *Config) InitConfig(options ...OptionsSetter) *Config

func (*Config) Manager

func (c *Config) Manager() *manage.Manager

func (*Config) Server

func (c *Config) Server() *server.Server

type HandlerInfo

type HandlerInfo struct {
	PasswordAuthorization func(ctx context.Context, username, password string) (userID string, err error)
	UserAuthorize         func(w http.ResponseWriter, r *http.Request) (userID string, err error)
	InternalError         func(error) *errors.Response
	ResponseError         func(*errors.Response)
}

type OptionsSetter

type OptionsSetter func(*Config)

func ClientStore

func ClientStore(store oauth2.ClientStore) OptionsSetter

func JWTKey

func JWTKey(key []byte) OptionsSetter

func JWTKeyID

func JWTKeyID(keyID string) OptionsSetter

func JWTMethod

func JWTMethod(method jwt.SigningMethod) OptionsSetter

func SetHandler

func SetHandler(handlerInfo *HandlerInfo) OptionsSetter

func SetStore

func SetStore(store oauth2.TokenStore) OptionsSetter

Directories

Path Synopsis
client
goth/providers/alipay
Package alipay implements the OAuth2 protocol for authenticating users through Alipay.
Package alipay implements the OAuth2 protocol for authenticating users through Alipay.
goth/providers/qq
Package qq implements the OAuth2 protocol for authenticating users through QQ.
Package qq implements the OAuth2 protocol for authenticating users through QQ.
goth/providers/wechat
Package wechat implements the OAuth2 protocol for authenticating users through Wechat.
Package wechat implements the OAuth2 protocol for authenticating users through Wechat.
goth/providers/weibo
Package weibo implements the OAuth2 protocol for authenticating users through Weibo.
Package weibo implements the OAuth2 protocol for authenticating users through Weibo.
store

Jump to

Keyboard shortcuts

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