Azure-Samples / Azure-Samples/ms-identity-msal-java-samples

Spring Tutorial-4/Auth-II - Group PreAuthorization mysteriously fails with valid Group ID claims in ID Token.

Open
#27 3 comments 0 reactions 0 assignees View on GitHub
untriaged
Dominant language
Java
Stars
79
Forks
82
PR merge metrics
No merged PRs in 30d

Description

> Please provide us with the following information:
> ---------------------------------------------------------------

### This issue is for a: (mark with an `x`)
```
- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
```

### Minimal steps to reproduce
> 4. Spring Framework Web App Tutorial/3-Authorization-II -
1. Run application and log in.
2. Observe ID Token Details and confirm that groups claim contains the AdminGroupId and the UserGroupId.
3. Confirm that PreAuthorization annotations have the 'correct' Group IDs
4. Click Admins Only.

### Any log messages given by the failure
> None observed

### Expected/desired behavior
> Expected: "Excellent! ..."
> Observed: "Sorry! ..."

### OS and Version?
> macOS Big Sur

### Versions
> Java version 11

### Mention any other details that might be useful
@GetMapping(path = "/admin_only")
@PreAuthorize("hasAuthority('48ca69cc-8f4f-4bd2-b12f-xxxxxxxxxxxx')")
Does not work.

Changing the PreAuthorization to hasRole() and Prefixing the group id with "ROLE_" as documented [here](https://microsoft.github.io/spring-cloud-azure/docs/4.0.0-beta.2/reference/html/index.html) appears to be working:

The roles example works as expected.

> ---------------------------------------------------------------
> Thanks! We'll be in touch soon.

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.