Validation predicate or function that receives the jwt payload as parameter.
Error message to return if the validation fails.
Validation exceptions if the claim is not included or expected values are not in the claim value.
Function that validates if a claim's value is equal to an specific value in the jwt payload. It will return validation exceptions if something fail.
Since is agnostic to the framework, it needs to be called within a middleware.
Example:
function myFunction(req, res, next) {
const isEqual = claimEquals(scope, 'email');
if (isEqual(req.auth.payload)) {
// Do something
}
Claim name. eg: scope.
Expected claim value. eg: claimEquals('scope', 'email profile')
Validation exceptions if the claim is not included or expected values are not in the claim value.
Function that validate if a claim is included or not in the jwt payload and if the claim includes the values passed as parameters. It will return validation exceptions if something fail.
Since is agnostic to the framework, it needs to be called within a middleware.
Example:
function myFunction(req, res, next) {
const validate = claimIncludes('scope', 'email', 'profile');
if (validate(req.auth.payload)) {
// Do something
}
Claim name. eg: scope.
Claim values as parameters. eg: claimIncludes('scope', 'email', 'profile')
Validation exceptions if the claim is not included or expected values are not in the claim value.
Function that validates if permissions claim contains the required permissions in the jwt payload. It will return validation exceptions if something fail.
Since is agnostic to the framework, it needs to be called within a middleware.
Example:
function myFunction(req, res, next) {
const isAdmin = requiredPermissions('admin');
if (isAdmin(req.auth.payload)) {
// Do something
}
Single or multiple permissions to check.
Validation exceptions if the claim is not included or expected values are not in the claim value.
Function that validates if scope claim contains the required scopes in the jwt payload. It will return validation exceptions if something fail.
Since is agnostic to the framework, it needs to be called within a middleware.
Example:
function myFunction(req, res, next) {
const canReadUserInfo = requiredScopes(['email', 'profile']);
if (canReadUserInfo(req.auth.payload)) {
// Do something
}
Single or multiple scopes to check.
Validation exceptions if the claim is not included or expected values are not in the claim value.
Function that applies any validation predicate or function to the jwt payload. It will return validation exceptions if something fail.
Since is agnostic to the framework, it needs to be called within a middleware.
Example: