Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

accessToken is undefined and roles are also not coming in auth  #134

@Mohsinfistix

Description

@Mohsinfistix

"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 isAuthorizedByRole(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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions