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 ¶
- func GenerateToken(name string, privilege string, ipAddr string, signKey *rsa.PrivateKey) (string, error)
- func IsItTheSameUser(tokenString string, userName string, ipAddr string, verifyKey *rsa.PublicKey) (bool, error)
- func IsPrivilegeOk(tokenString string, privilege string, ipAddr string, verifyKey *rsa.PublicKey) (bool, error)
- func SetupAToken(privateKeyFilePath string) (*rsa.PrivateKey, *rsa.PublicKey)
- type SecureTokenData
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 ¶
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