common

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyMap

func CopyMap(source map[string]interface{}) map[string]interface{}

CopyMap extends common

Types

type User

type User struct {
	Origin   string
	Username string
	Name     string
	Email    string
	Roles    []string
	Token    *jwt.Token
}

User represents a user who has been logged in

func CreateUserFromToken

func CreateUserFromToken(token *jwt.Token) (*User, error)

CreateUserFromToken convers a Jwt into a User struct

func CreateUserFromTokenString

func CreateUserFromTokenString(tokenString string, verifyKey *rsa.PublicKey) (*User, error)

CreateUserFromTokenString parses a Jwt token string and returns a User struct

func (*User) GetJwt

func (u *User) GetJwt(signingKey *rsa.PrivateKey, expiration time.Duration) (string, error)

GetJwt creates a sign Jwt

func (User) HasRole

func (u User) HasRole(role string) bool

HasRole returns true if the User has the specified role

func (*User) RefreshJwt

func (u *User) RefreshJwt(signingKey *rsa.PrivateKey, expirationDuration time.Duration) (string, error)

RefreshJwt refreshes the token if needed

Jump to

Keyboard shortcuts

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