oauth2

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const AuthName = "oauth2"

AuthName is the auth style

View Source
const Random = "random"

Random is a state value

Variables

View Source
var (
	ErrInvalidState = errors.New("invalid state")
	ErrInvalidCode  = errors.New("invalid code")
	ErrInvalidToken = errors.New("invalid authorization")
	ErrInvalidAuth  = errors.New("invalid authentication")
	ErrExpiredToken = errors.New("expired token")
)

errors

Functions

func NewOAuth2

func NewOAuth2() handler.Handler

NewOAuth2 returns new auth handler

func Use

func Use(middleware *OAuth2)

Use put a custom oauth2 logic then register handler to chassis

func WriteBackErr

func WriteBackErr(err error, status int, cb invocation.ResponseCallBack)

WriteBackErr write err and callback

Types

type Handler

type Handler struct {
}

Handler is is a oauth2 pre process raw data in handler

func (*Handler) Handle

func (oa *Handler) Handle(chain *handler.Chain, inv *invocation.Invocation, cb invocation.ResponseCallBack)

Handle is provider

func (*Handler) Name

func (oa *Handler) Name() string

Name returns router string

type OAuth2

type OAuth2 struct {
	GrantType    string                                            // required
	UseConfig    *oauth2.Config                                    // required
	Authenticate func(accessToken string, req *http.Request) error // optional
}

OAuth2 should implement oauth2 server side logic it is singleton

Jump to

Keyboard shortcuts

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