Giter Site home page Giter Site logo

Roles about vue-keycloak-js HOT 8 CLOSED

dsb-norge avatar dsb-norge commented on May 20, 2024
Roles

from vue-keycloak-js.

Comments (8)

nlien avatar nlien commented on May 20, 2024 3

Exposed hasRealmRole and hasResourceRole in v1.0.9

from vue-keycloak-js.

nlien avatar nlien commented on May 20, 2024

In the onReady callback, you have access to the keycloak object. You could maybe get the roles by accessing keycloak.tokenParsed['authorities'] ? Or just call the hasRealmRole function directly?

from vue-keycloak-js.

alfreema avatar alfreema commented on May 20, 2024

Okay, is there a way to access the underlying keycloak object using this.$keycloak?

from vue-keycloak-js.

nlien avatar nlien commented on May 20, 2024

Not yet, I'm afraid. There are certain callback functions, like onAuth*, on the keycloak object, which we'd rather not expose. Because overriding them would break the plugin's behavior. Maybe we'll expose more of the underlying object in the near future... In the meantime go for my suggestion above, or use the token from this.$keycloak.token and parse it yourself.

from vue-keycloak-js.

alfreema avatar alfreema commented on May 20, 2024

I don't think I can use onReady, because no authentication has taken place at that point. I'll look into parsing this.$keycloak.token though.

from vue-keycloak-js.

nlien avatar nlien commented on May 20, 2024

Hi again... keycloak.tokenParsed['authorities'] may not be what you want, I realize. Behind the scenes, Keycloak's hasRealmRole function inspects the keycloak.realmAccess.roles array for the given role. If you'd still like to have the hasReamRole() exposed on the $keycloak object, I'll ship a new version with this added. Just let me know by replying here.

from vue-keycloak-js.

anderius avatar anderius commented on May 20, 2024

I vote for exposing both hasRealmRole and hasResourceRole.

from vue-keycloak-js.

alfreema avatar alfreema commented on May 20, 2024

Sorry for delayed responses, I am not in front of a computer as much as I'd like to be these days. :) I'll leave that up to you gurus, I just need a somewhat future-proof way to authorize using roles. Implementing a function that maps to hasRealmRole seems to be the easiest in my pea-sized brain.

from vue-keycloak-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.