auth

package
v0.0.0-...-3d95c69 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const APIPath = "/auth/"

APIPath is path prefix

Variables

View Source
var (
	// ErrInvalidPassword is occurred when invalid user password
	ErrInvalidPassword = errors.New("Invalid user password")

	// ErrInvalidRefreshToken is occurred when invalid refresh token
	ErrInvalidRefreshToken = errors.New("Invalid refresh token")
)

Functions

func RefreshTokenRedisStorageKey

func RefreshTokenRedisStorageKey(userID int64) string

RefreshTokenRedisStorageKey return key that stored on redis

Types

type AccessTokenByRefreshRequest

type AccessTokenByRefreshRequest struct {
	Token string `json:"token" example:"<refresh token>" binding:"required"`
}

AccessTokenByRefreshRequest is request model

type Controller

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

Controller is auth controller

func NewController

func NewController(conf config.Configuration, service Service) *Controller

NewController return new auth controller instance.

func (*Controller) RegisterRoutes

func (controller *Controller) RegisterRoutes(router gin.IRouter)

RegisterRoutes register handler routes.

type CreateAccessTokenRequest

type CreateAccessTokenRequest struct {
	UserName string `json:"username" example:"<username>" binding:"required"`
	Password string `json:"password" example:"<password>" binding:"required"`
}

CreateAccessTokenRequest is request model for creating todo

type Service

type Service interface {
	VerifyAuthentication(username, password string) (user.User, error)
	GenerateAccessToken(userID int64) (string, error)
	IssueRefreshToken(userID int64) (string, error)
	VerifyRefreshToken(userID int64, refreshToken string) bool
	ExtractTokenClaims(token string) (jwt.MapClaims, error)
}

Service is auth authService.

func NewService

func NewService(
	conf config.Configuration,
	userRepo user.Repository,
	passport service.Passport,
	redisConn db.RedisConn) Service

NewService return new auth authService instance.

type TokenResponse

type TokenResponse struct {
	Type         string `json:"type"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token,omitempty"`
	ExpiresIn    int64  `json:"expires_in"`
}

TokenResponse is token model

Jump to

Keyboard shortcuts

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