using Okta principal groups and metadata in Spring Boot with Okta Spring Boot - Stack Overflow
I have an OIDC app in Okta that I am using to authenticate and authorize my webapp where I am using:
- spring-boot-starter-parent 3.3.3
- okta-spring-boot-starter 3.0.7
- thymeleaf-extras-springsecurity6 3.1.2.RELEASE
This comment lead me to believe that adding a groups claim to my Authorization Server in Okta would result in groups being turned into roles automatically when using okta-spring-boot-starter. That is not what I am experiencing.
I was under the impression that requesting the authorities from the principal would result in a list of groups prepended by ROLE_
My user belongs to a single group in Okta called App-User. If I ask for:
<div sec:authentication="principal.authorities">Roles</div>
what I get back is:
[App-User, Everyone, OIDC_USER, SCOPE_email, SCOPE_openid, SCOPE_profile]
This does not work:
<div sec:authorize="hasRole('App-User')">You have the role</div>
but this does:
<div sec:authorize="hasAuthority('App-User')">You have the authority</div>
I also find it strange that this works:
<div sec:authentication="principal.email"></div>
but doing this:
<div sec:authentication="principal.name"></div>
returns what appears to be the client ID of the app in Okta instead of the user's name
00umarbvfdDvDofPu5d7
trying to get principal.firstName throws an error claiming it doesn't exist.
I have an OIDC app in Okta that I am using to authenticate and authorize my webapp where I am using:
- spring-boot-starter-parent 3.3.3
- okta-spring-boot-starter 3.0.7
- thymeleaf-extras-springsecurity6 3.1.2.RELEASE
This comment lead me to believe that adding a groups claim to my Authorization Server in Okta would result in groups being turned into roles automatically when using okta-spring-boot-starter. That is not what I am experiencing.
I was under the impression that requesting the authorities from the principal would result in a list of groups prepended by ROLE_
My user belongs to a single group in Okta called App-User. If I ask for:
<div sec:authentication="principal.authorities">Roles</div>
what I get back is:
[App-User, Everyone, OIDC_USER, SCOPE_email, SCOPE_openid, SCOPE_profile]
This does not work:
<div sec:authorize="hasRole('App-User')">You have the role</div>
but this does:
<div sec:authorize="hasAuthority('App-User')">You have the authority</div>
I also find it strange that this works:
<div sec:authentication="principal.email"></div>
but doing this:
<div sec:authentication="principal.name"></div>
returns what appears to be the client ID of the app in Okta instead of the user's name
00umarbvfdDvDofPu5d7
trying to get principal.firstName throws an error claiming it doesn't exist.
Share Improve this question edited 22 hours ago dur 16.9k26 gold badges88 silver badges141 bronze badges asked yesterday Steve MaringSteve Maring 1751 gold badge4 silver badges11 bronze badges1 Answer
Reset to default 0I found that this will give me a list of all the attributes available on the principal:
<div sec:authentication="principal.attributes">Attributes</div>
From that, I found that I could do all of these:
<div th:text="${#authentication.getPrincipal().getAttribute('name')}"></div>
<div th:text="${#authentication.getPrincipal().getAttribute('given_name')}"></div>
<div th:text="${#authentication.getPrincipal().getAttribute('family_name')}"></div>
<div th:text="${#authentication.getPrincipal().getAttribute('email')}"></div>
<div th:text="${#authentication.getPrincipal().getAttribute('groups')}"></div>
That serves my purpose and I can live with using hasAuthority() instead of hasRole() for display purposes
- 微软服软涉足iOS、安卓背后:以开发者为重
- Google如今是一家硬件公司了 迫不得已还是顺应时代?
- 只是为文艺? 专业工作室为何钟情苹果
- How to remove internal padding to the right of SwiftUI Picker - Stack Overflow
- browser cache - window.fetch not using cached data from <img src= - Stack Overflow
- go - How do I implement session timeout in kafka between 2 apis - Stack Overflow
- i need help troubleshooting issues with plugins, i am using gradle 8.12 - Stack Overflow
- Google Translate Widget Only Works in Chrome – Why? - Stack Overflow
- python - Sympy: Define custom derivative on symbol - Stack Overflow
- android - No recomposition called when State Holder class modified - Stack Overflow
- google colaboratory - Load a Kaggle dataset into Colab notebook without extracting it - Stack Overflow
- linker - Appending to an ELF file - Cortex MGCC - Stack Overflow
- Symfony 7 - Autocomplete form field - Stack Overflow
- augmented reality - Applying 2d image to a 3d object in xcode tutorials? - Stack Overflow
- flutter - How to write LOGs in an APP made in fletpython, which appear in the DDMS? - Stack Overflow
- python - Call function from macos framework (e.g. IntelPowerGadget) - Stack Overflow
- c++ - Pointer of an object which has static storage as template non-type parameter, Clang and GCC agrees, MSVC doesn't -