oauth2server

package
v0.6.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultAppClient oauth2.ClientStore = NewClientStore(nil)
	Default                             = oauth2s.NewConfig()
)
View Source
var (
	// Debug 调试模式
	Debug bool
)
View Source
var (
	// RoutePrefix 路由前缀
	RoutePrefix string
)

Functions

func InternalErrorHandler

func InternalErrorHandler(err error) (re *errors.Response)

func NewClientStore

func NewClientStore(fn func(ctx echo.Context, appID string) (oauth2.ClientInfo, error)) oauth2.ClientStore

func PasswordAuthorizationHandler

func PasswordAuthorizationHandler(ctx context.Context, clientID, username, password string) (userID string, err error)

PasswordAuthorizationHandler 密码认证处理

func RefreshingScopeHandler

func RefreshingScopeHandler(tgr *oauth2.TokenGenerateRequest, oldScope string) (allowed bool, err error)

RefreshingScopeHandler check the scope of the refreshing token

func RefreshingValidationHandler

func RefreshingValidationHandler(ti oauth2.TokenInfo) (allowed bool, err error)

RefreshingValidationHandler check if refresh_token is still valid. eg no revocation or other

func ResponseErrorHandler

func ResponseErrorHandler(re *errors.Response)

func Route

func Route(g echo.RouteRegister, loginHandler func(echo.Context) error, logoutHandler func(echo.Context) error)

func UserAuthorizeHandler

func UserAuthorizeHandler(w http.ResponseWriter, r *http.Request) (userID string, err error)

UserAuthorizeHandler 查询用户授权信息

Types

type AgreedScopeStorer

type AgreedScopeStorer interface {
	IsAgreed(userID uint, appID string, scopes []string) (bool, error)
	Save(userID uint, appID string, scopes []string) error
}

type AppClient

type AppClient struct {
	GetByAppID func(ctx echo.Context, appID string) (oauth2.ClientInfo, error)
}

func (*AppClient) GetByID

func (a *AppClient) GetByID(stdCtx context.Context, appID string) (oauth2.ClientInfo, error)

type AuthCodeRequestData

type AuthCodeRequestData struct {
	ClientID     string   `json:"client_id" xml:"client_id"`
	RedirectURI  string   `json:"redirect_uri" xml:"redirect_uri"`
	ResponseType string   `json:"response_type" xml:"response_type"` // code|token
	Scope        []string `json:"scope" xml:"scope"`
	State        string   `json:"state" xml:"state"`
}

func (*AuthCodeRequestData) FromContext

func (a *AuthCodeRequestData) FromContext(ctx echo.Context) *AuthCodeRequestData

type TokenRequestData

type TokenRequestData struct {
	Code        string `json:"code" xml:"code"`
	GrantType   string `json:"grant_type" xml:"grant_type"`
	RedirectURI string `json:"redirect_uri" xml:"redirect_uri"`
}

func (*TokenRequestData) FromContext

func (a *TokenRequestData) FromContext(ctx echo.Context) *TokenRequestData

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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