auth

package
v0.0.0-...-d92562b Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const AccessTokenExpirationMinutes = 300

AccessTokenExpirationMinutes is the expiry time for the token

View Source
const TokenHeader = "x-access-token"

TokenHeader token for auth

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

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

Auth keeps the auth and a secret key

func NewAuth

func NewAuth(repo repo.IAppRepo, jwtKey string) *Auth

NewAuth create a new auth instance

func (*Auth) AuthenticateUser

func (auth *Auth) AuthenticateUser(ctx *gin.Context, accessToken string) (string, error)

AuthenticateUser will auth user and returns a access token with expiry

func (*Auth) GetJWTKey

func (auth *Auth) GetJWTKey() []byte

GetJWTKey returns the current key

type Claims

type Claims struct {
	UserId int64  `json:"userId"`
	Email  string `json:"email"`
	Name   string `json:"name"`
	jwt.StandardClaims
}

Claims is used for auth

type IAuth

type IAuth interface {
	AuthenticateUser(ctx *gin.Context, accessToken string) (string, error)
	GetJWTKey() []byte
}

IAuth is an interface for handling auth

Jump to

Keyboard shortcuts

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