auth

package
v0.0.0-...-765978f Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlacklistToken

func BlacklistToken(token []byte, expireAt int64) error

BlacklistToken adds the token to a ledis database

func ClearAllTokens

func ClearAllTokens() (int64, error)

func IsBlacklisted

func IsBlacklisted(token []byte) (bool, error)

IsBlackListed checks if a token is in the blacklist list

func RequireTokenAuthentication

func RequireTokenAuthentication(w http.ResponseWriter, req *http.Request,
	next http.HandlerFunc)

func ValidateTokenAuthentication

func ValidateTokenAuthentication(w http.ResponseWriter, req *http.Request,
	next http.HandlerFunc)

Types

type JwtAuthBackend

type JwtAuthBackend struct {
	PublicKey *rsa.PublicKey
	// contains filtered or unexported fields
}

func InitJwtAuthBackend

func InitJwtAuthBackend() (*JwtAuthBackend, error)

InitJwtAuthBackend instantiate a thread-safe JwtAuthBackend instance if it has not been started.

func (*JwtAuthBackend) Authenticate

func (authBackend *JwtAuthBackend) Authenticate(u *user.User) bool

Authenticate authenticate the provided user login credentials

func (*JwtAuthBackend) GenerateToken

func (authBackend *JwtAuthBackend) GenerateToken(u *user.User) (string, error)

GenerateToken creates an encrypted token including the user's ID using signing method RS512 and the public/private key

func (*JwtAuthBackend) IsTerminated

func (authBackend *JwtAuthBackend) IsTerminated(tokenstr string) bool

IsTerminated check if the token has been terminated before its expiration

func (*JwtAuthBackend) TerminateToken

func (authBackend *JwtAuthBackend) TerminateToken(tokenstr string, token *jwt.Token) error

TerminateToken invalidates the token before its expiration time. This function is invoked when the user logged out.

Jump to

Keyboard shortcuts

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