authorization

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppHandler

type AppHandler func(w http.ResponseWriter, r *http.Request) error

AppHandler is handler that will fail if user is not authorized (based on token + required scope)

func (AppHandler) ServeHTTP

func (ah AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Satisfies the http.Handler interface

type AppHandlerWithUserInfo

type AppHandlerWithUserInfo func(userInfo *UserInfo, w http.ResponseWriter, r *http.Request) error

AppHandlerWithUserInfo is a handler that has extra *UserInfo as parameter

func (AppHandlerWithUserInfo) ServeHTTP

Satisfies the http.Handler interface

type AppHandlerWithUserInfoAllowAnonymous

type AppHandlerWithUserInfoAllowAnonymous func(userInfo *UserInfo, w http.ResponseWriter, r *http.Request) error

AppHandlerWithUserInfoAllowAnonymous is a handler that allows user also not to be authenticated. In this case userInfo is nil

func (AppHandlerWithUserInfoAllowAnonymous) ServeHTTP

Satisfies the http.Handler interface

type Authorization

type Authorization struct {
	// contains filtered or unexported fields
}

Authorization object

func New

func New(jwks jwk.Set, requiredScope string) (a *Authorization)

New create new AuthMiddleware object

func (*Authorization) Middleware

func (a *Authorization) Middleware(h http.Handler) http.Handler

Middleware returns middleware function that can be used in router.Use()

type UserInfo

type UserInfo struct {
	UserID string   `json:"uid,omitempty"`
	Email  string   `json:"email,omitempty"`
	Scopes []string `json:"scopes,omitempty"`
}

UserInfo information about authenticated user

func (*UserInfo) HasScope

func (ui *UserInfo) HasScope(scope string) bool

HasScope returns if given scope is included in user info

Jump to

Keyboard shortcuts

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