Skip to content
This repository has been 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

Open
Mohsinfistix opened this issue Jan 26, 2022 · 4 comments
Open

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

Mohsinfistix opened this issue Jan 26, 2022 · 4 comments

Comments

@Mohsinfistix
Copy link

"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;
@BigBallard
Copy link
Contributor

@Mohsinfistix you need to provide more context and explanation than just posting code if you expect any help.

@proftom
Copy link

proftom commented Mar 28, 2022

Agreed @Mohsinfistix needs to provide more context, however, I want to ask, if I passes a Bearer token in an authorization header, should I expect accessToken to equal that bearer token?

@BigBallard
Copy link
Contributor

@proftom that is my understanding. I haven not checked myself but would be easy enough to test in isolation.

@okanji
Copy link

okanji commented Apr 18, 2022

I am having a similar issue, the access token is not defined but I do have a bearer token in the header

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants