This repository was archived by the owner on Apr 17, 2023. It is now read-only.
This repository was archived by the owner on Apr 17, 2023. It is now read-only.
Open
Description
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAuthorizedByRole = void 0;
const KeycloakContext_1 = require("../KeycloakContext");
/**
*
- @param roles the list of roles the user should match against
- @param context the graphql context that contains the user info
*/
function is 518A AuthorizedByRole(roles, context) {
if (!(context && context[KeycloakContext_1.CONTEXT_KEY])) {
console.error(context.${KeycloakContext_1.CONTEXT_KEY} is missing. Keycloak integration is probably misconfigured
);
return false;
}
for (const role of roles) {
if (context[KeycloakContext_1.CONTEXT_KEY].hasRole(role)) {
return true;
}
}
return false;
}
exports.isAuthorizedByRole = isAuthorizedByRole;
Metadata
Metadata
Assignees
Labels
No labels