Azure / Azure/static-web-apps

Changing user roles does not reflect on /.auth/me

Open
#985 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

I think I've found an edge-case (and maybe bug) in SWA auth.

We're working on a workshop ([newpatiente2e/Contoso-New-Patient-App (github.com)](https://github.com/newpatiente2e/Contoso-New-Patient-App), docs: [Workshop Introduction | New Patient Registration Demo (newpatiente2e.github.io)](https://newpatiente2e.github.io/docs/)) which we need to have at least two different accounts (but they can do up to three).

My partner on the project was testing but using the same account (a GitHub account) and in the Azure Portal they'd change the role name from admin to nurse.

When logging out, then logging back in, they'd still be listed as `admin`, and the `/.auth/me` endpoint would return `admin` in their roles, not `nurse` which the Azure Portal said they should have.

So, the bug seems to be that the auth endpoints are not updated to reflect the roles in the portal immediately.

I tried getting them to do a purge, but that deletes the account from role assignments completely, so I guess it works, but you have to then re-add them, which isn't an ideal workflow.

**To Reproduce**
Steps to reproduce the behavior:
1. Provision a SWA resource and add a user with a custom role (eg: `admin`)
2. Authenticate the user and verify they had the `admin` role assigned
3. Via the Azure Portal, change the role assignment (eg: remove `admin` and add `nurse`)
4. Refresh the user profile from `/.auth/me` and observe they still have the original role
5. Logout and login the user, and observe they still have the original role

**Expected behavior**

Changed roles in the Azure Portal are reflected for the user.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.