Skip to content

AuthorityAuthorizationManager never using defined role hierarchy #12473

@davidvelasco-lk

Description

@davidvelasco-lk

Describe the bug
Defined role hierarchy is not picked up by AuthorityAuthorizationManager.

  • Role hierarchy: ROLE_SUPERUSER > ROLE_USER
  • endpoint GET /greet is authorized to role USER
  • User user is configured as SUPERUSER. According to defined role hierarchy, access to resource should be granted.

After debugging I found that AuthorityAuthorizationManager is always using NullRoleHierarchy. This setter is never being assigned to the one I created.

Env: spring boot 3.0.0 / spring security 6.0.0
Context: Upgrading from spring boot 2.7.x to spring boot 3.0.0

To Reproduce

  1. Start the example
  2. Go to localhost:8080/greet
  3. log in should be shown
    user: user
    password: pass
  4. response code is 403, forbidden.

Expected behavior
Should return "hello world" string

Sample

Example project.

Metadata

Metadata

Assignees

Labels

in: configAn issue in spring-security-configstatus: ideal-for-contributionAn issue that we actively are looking for someone to help us withtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions