service

package
v0.0.0-...-587968e Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticateWithPassword

func AuthenticateWithPassword(user *User) (int, error)

func CreateNewUser

func CreateNewUser(user *User)

func DeleteUser

func DeleteUser(user *User)

func GenerateNewToken

func GenerateNewToken(userID int) string

GenerateNewToken will generate jwt token for given user id

func ValidateToken

func ValidateToken(tokenString string) (*jwt.Token, error)

ValidateToken will validate token string and return When token string is valid

Types

type AuthContext

type AuthContext struct {
	Status string   `json:"status"`
	JWT    JWTToken `json:"jwt"`
}

AuthContext is authentication information

func GetAuthContextByID

func GetAuthContextByID(authContextID string) *AuthContext

GetAuthContextByID will check token existence in redis and valid

type JWTToken

type JWTToken struct {
	Secret string `json:"secret"`
	Token  string `json:"token"`
}

type Token

type Token struct {
	AuthContextID string `json:"auth_context_id"`
	*jwt.StandardClaims
}

Token is play load part of JWT token

func ParseTokenString

func ParseTokenString(tokenString string) (*Token, error)

ParseTokenString will parse given token and return Token struct

type User

type User struct {
	ID       int    `json:"user_id"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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