token

package
v0.0.0-...-e11358b Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package token : The Token package: Enables the transfer of users' information between clients and servers using secure JSON Web Token (JWT) cookies

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(name string, privilege string, ipAddr string, signKey *rsa.PrivateKey) (string, error)

GenerateToken : Generate a new signed token

func IsItTheSameUser

func IsItTheSameUser(tokenString string, userName string, ipAddr string, verifyKey *rsa.PublicKey) (bool, error)

IsItTheSameUser : Verify that the user associated with the token is the same as the given one

func IsPrivilegeOk

func IsPrivilegeOk(tokenString string, privilege string, ipAddr string, verifyKey *rsa.PublicKey) (bool, error)

IsPrivilegeOk : Verify that the given privilege matches the one that is associated with the user defined in the token

func SetupAToken

func SetupAToken(privateKeyFilePath string) (*rsa.PrivateKey, *rsa.PublicKey)

SetupAToken : Read the given private key PEM file and extract an RSA private key (signing key) the corresponding RSA public key (verifying key)

Types

type SecureTokenData

type SecureTokenData struct {
	Token     *jwt.Token
	UserName  string
	Privilege string
	ID        string
}

SecureTokenData : The token information: token string, user name and privilege and ID

func ParseToken

func ParseToken(tokenString string, ipAddr string, verifyKey *rsa.PublicKey) (*SecureTokenData, error)

ParseToken : Parse the given token and verify that it holds the mandatory data

Jump to

Keyboard shortcuts

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