token

package
v0.0.0-...-e212f3b Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SessionAuthorizationClaimsKey - the session key storing the authorization claims.
	SessionAuthorizationClaimsKey = "authorizationClaims"
)

Variables

This section is empty.

Functions

func AuthenticationInterceptor

func AuthenticationInterceptor(r *ghttp.Request)

AuthenticationInterceptor - the interceptor for all need authorization APIs.

func CreateTokenForUser

func CreateTokenForUser(phone string) string

CreateTokenForUser - creates the token of specific user, by their phone. Since we don't support multi-login, we will replace the existing cached token of the phone when this function called.

func RemoveUserToken

func RemoveUserToken(phone string)

RemoveUserToken - remove the user token in the token cache.

Types

type AuthorizationClaims

type AuthorizationClaims struct {
	Generated int64  `json:"generated"`
	Phone     string `json:"phone"`
	jwt.StandardClaims
}

AuthorizationClaims - the customized JWT claims for type-safe type. More details are available at https://github.com/dgrijalva/jwt-go/issues/287

Jump to

Keyboard shortcuts

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