manage

package
v0.0.0-...-af57f77 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTokenCfg = &Config{AccessTokenExp: time.Hour * 24}
)

default configs

Functions

This section is empty.

Types

type Config

type Config struct {
	// access token expiration time, 0 means it doesn't expire
	AccessTokenExp time.Duration
}

Config authorization configuration parameters

type Manager

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

Manager provide authorization management

func NewManager

func NewManager() *Manager

NewManager create to authorization management instance

func (*Manager) CheckUserExists

func (m *Manager) CheckUserExists(userName string) (bool, error)

CheckUserExists get the user information

func (*Manager) CreateUser

func (m *Manager) CreateUser(user *models.UserCredentials) (*models.PublicUserInfo, error)

CreateUser get the user information

func (*Manager) GenerateAuthToken

func (m *Manager) GenerateAuthToken(tgr *TokenGenerateRequest) (*models.Token, error)

GenerateAuthToken generate the authorization token(code)

func (*Manager) GetAllUsers

func (m *Manager) GetAllUsers() ([]*models.PublicUserInfo, error)

GetAllUsers get the user information

func (*Manager) GetUser

func (m *Manager) GetUser(userName string) (user *models.UserCredentials, err error)

GetUser get the user information

func (*Manager) LoginUser

func (m *Manager) LoginUser(username string) error

LoginUser verifies user password

func (*Manager) LogoutUser

func (m *Manager) LogoutUser(username string) error

LogoutUser verifies user password

func (*Manager) MapAccessGenerate

func (m *Manager) MapAccessGenerate(gen *generates.JWTAccessGenerate)

MapAccessGenerate mapping the access token generate interface

func (*Manager) MustUserStorage

func (m *Manager) MustUserStorage(stor *store.UserStore, err error)

MustUserStorage mandatory mapping the user store interface

func (*Manager) ParseToken

func (m *Manager) ParseToken(tokenString string) (userInfo *models.PublicUserInfo, err error)

ParseToken validates the token

func (*Manager) UpdatePassword

func (m *Manager) UpdatePassword(reset bool, oldPassword, newPassword, userName string) (*models.PublicUserInfo, error)

UpdatePassword get the user information

func (*Manager) UpdateUserDetails

func (m *Manager) UpdateUserDetails(user *models.UserCredentials) (*models.PublicUserInfo, error)

UpdateUserDetails get the user information

func (*Manager) ValidateToken

func (m *Manager) ValidateToken(tokenString string) (valid bool, err error)

ValidateToken validates the token

func (*Manager) VerifyUserPassword

func (m *Manager) VerifyUserPassword(username, password string) (*models.PublicUserInfo, error)

VerifyUserPassword verifies user password

type TokenGenerateRequest

type TokenGenerateRequest struct {
	UserInfo       *models.PublicUserInfo
	AccessTokenExp time.Duration
}

TokenGenerateRequest provide to generate the token request parameters

Jump to

Keyboard shortcuts

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