user

package
v0.0.0-...-520f1c6 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateScopes

func ValidateScopes(claims jwt.MapClaims, scheme *JWTScheme) error

ValidateScopes takes user scopes and checks if it has the scope which is required for accessing the api

Types

type JWTScheme

type JWTScheme struct {
	// Name is the scheme name defined in the design.
	Name string
	// Scopes holds a list of scopes for the scheme.
	Scopes []string
	// RequiredScopes holds a list of scopes which are required
	// by the scheme. It is a subset of Scopes field.
	RequiredScopes []string
}

func (*JWTScheme) Validate

func (s *JWTScheme) Validate(scopes []string) error

Validate returns a non-nil error if scopes does not contain all of JWT scheme's required scopes.

type Service

type Service interface {
	Info(res http.ResponseWriter, req *http.Request)
	RefreshAccessToken(res http.ResponseWriter, req *http.Request)
	NewRefreshToken(res http.ResponseWriter, req *http.Request)
}

func New

func New(api app.Config) Service

New returns the auth service implementation.

type UserService

type UserService struct {
	app.Service

	JwtConfig *app.JWTConfig
	// contains filtered or unexported fields
}

func (*UserService) Info

func (s *UserService) Info(res http.ResponseWriter, req *http.Request)

Get the user Info

func (*UserService) JWTAuth

func (s *UserService) JWTAuth(handler http.HandlerFunc) http.HandlerFunc

JWTAuth acts as middleware and implements the authorization logic for services.

func (*UserService) NewRefreshToken

func (s *UserService) NewRefreshToken(res http.ResponseWriter, req *http.Request)

func (*UserService) RefreshAccessToken

func (s *UserService) RefreshAccessToken(res http.ResponseWriter, req *http.Request)

Refreshes the access token of User

Jump to

Keyboard shortcuts

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