Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Role-based access #99

Open
rmeissn opened this issue Jun 12, 2023 · 0 comments
Open

Role-based access #99

rmeissn opened this issue Jun 12, 2023 · 0 comments

Comments

@rmeissn
Copy link

rmeissn commented Jun 12, 2023

I'm not really an oidc pro, so this might be a simple to answer question.

I got a frontend application and only users associated with a specific role - role-a - shall be allowed to login. Some users got the role, others don't.

My current implementation:

mainOidc.events.addUserLoaded(() => {
  if (mainOidc.userProfile.roles === undefined || !mainOidc.userProfile.roles.includes('rola-a')) {
    window.alert('Not Allowed')
    mainOidc.signOut()
    return
  }
  // successfull login path ...
})

Problem with this approach: I can leave the current browser tab in a pending state and open another one with a protected route - I'm displayed as successfully logged in and got access. I guess the issue comes from a user entry in the userStore.

How can I prevent someone without a specific role to being added to the useStore or logged in at all?

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

No branches or pull requests

1 participant