users

package
v0.0.0-...-0f5ba4b Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package classification of User API

Documentation for User API

Schemes: http
BasePath: /
Version: 1.0.0

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Index

Constants

View Source
const (
	LoginCookieName     = "token"
	LoginCookieMaxAge   = 3600
	LoginCookieSecure   = false
	LoginCookieHTTPOnly = true
)

token settings

View Source
const (
	UserIDFromContextKey = "loggedInUserID"
	UserIDFromParamsKey  = "paramUserID"
)

Keys used to retrieve values from gin.Context

Variables

View Source
var ErrInvalidUserID = "Invalid user ID"

Functions

func AuthenticateUser

func AuthenticateUser(user *models.User, credentials models.Credentails) (string, error)

func New

func New(db data.UserDB) (*user, error)

func RequireAuthorization

func RequireAuthorization() gin.HandlerFunc

TODO: authorization/permissions levels RequireAuthorization checks that the LoginCookie is set in the http request. If not found, sets StatusUnauthorized, else sets the token in the gin context.

func UserIDFromContext

func UserIDFromContext(c *gin.Context) (models.UserID, error)

func UserIDFromParams

func UserIDFromParams(c *gin.Context) (models.UserID, error)

Types

type Claims

type Claims struct {
	UserID models.UserID
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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