authentication

package
v0.0.0-...-fc325db Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired() gin.HandlerFunc

AuthRequired is middleware that validates whether or not the current request has been authenticated by a JWT. If the request is not authenticated, a 401 HTTP code will be returned.

func Authenticate

func Authenticate(c *gin.Context)

Authenticate authenticates a user by providing a JWT if the provided email and password match with the information from the database.

func GetUserID

func GetUserID(c *gin.Context) (int64, error)

GetUserID gets the user ID of the current request. It will return 0 and an error when something went wrong.

func ParseToken

func ParseToken(encodedToken string) (*jwt.Token, error)

ParseToken parses the encoded token by verifying if it contains 'Bearer {token}'. The token will be validated as well.

Types

This section is empty.

Jump to

Keyboard shortcuts

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