Overview
Working with tokens
Leaf provides you with the $jwt object which includes various methods for creating and parsing token data....but we do not advice directly using the $jwt object. For this reason, a special $authentication object has been created to work with all the $jwt data. To use $authentication,
Authentication methods:
generateSimpleToken()
This method generates a new JSON Web Token. It takes 2 arguments. check out JWT for more info on JWT params
- (int) - A user id to encode
- (string) - A secret phrase to encode with the token
generateToken()
This method generates a new JSON Web Token: the same as generateSimpleToken()
, the only difference is that this method gives you more control over the token
i.e. expiry time..... In v1.3, this method takes in 2 params, the entire payload of your JWT and a secret phrase. check out JWT for more info on JWT payload params.
- (array) - JWT payload
- (string) - A secret phrase to encode with the token
validateToken()
This method is used to confirm the identity of a token from an authorization header
getBearerToken()
This method is used to get the bearer token from an authorization header
getAuthorizationHeader()
This method is used to an authorization header
Next Steps
SessionSimple Routing
Request
Response