-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
PermissionChecker method sometimes receives unaugmented SecurityIdentity even though augmentor did run successfully #44990
Comments
/cc @geoand (kotlin), @sberyozkin (security) |
@okarmazin OIDC Where is |
@sberyozkin That's just one of my helper extension functions (it's actually called object MyAttributes {
const val user = "my.user"
}
fun SecurityIdentity.getUser(): User? = getAttribute(MyAttributes.user)
fun SecurityIdentity.requireActiveUser(): User {
val user = getUser()
if (user == null) {
Log.error("SecurityIdentity does not contain User. Principal name: ${principal.name}")
throw UnauthorizedException()
}
if (!user.isActive) {
Log.error("SecurityIdentity contains User, but it's inactive. User: $user")
throw InactiveUserException()
}
return user
}
fun SecurityIdentity.oidcUserInfo(): UserInfo? = getAttribute("userinfo") When I post similar code in the future, I'll make sure to write it as |
Yeah, I'm not working with Kotlin so for someone like myself it can be confusing :-). |
/cc @michalvavrik for awareness. |
This sounds like a race between augmentors, we need to make sure that PermissionChecker is only applied when all the augmentors has finished. You don't need to spend time on the reproducer @okarmazin , we use internally augmentors as well an we need to make sure that it runs after all user-defined augmentors. Sounds alright? |
BTW you should be able to |
Describe the bug
I'm trying out the new
@PermissionChecker
mechanism on a method. Every once in a while something happens and the annotated method starts receiving an unaugmentedSecurityIdentity
argument from Quarkus for all future invocations of that method, even though previously (some minutes ago) it did receive the augmented identity.After the breakage, the
SecurityIdentity
received by the PermissionChecker contains the following attributes (as seen byidentity.attributes.forEach(::println)
:It's authenticated and contains OIDC
UserInfo
, but my custom attributes are missing.The behavior happens consistently, but I have not yet been able to find reproduction conditions. For some time after server starts, the secured method receives the correct, augmented identity. I have been able to observe the behavior when I come back to the server after yet-unknown amount of time passes.
In the same controller as this
@PermissionsAllowed
-annotated method, there are sibling request handlers which perform their own permission checks manually. For these checks they useSecurityIdentity
which is constructor-injected into the controller. This injected identity is always correctly augmented.So far logging shows that the augmentor does run for the affected requests and completes successfully, along with the entire authentication chain.
My current line of inquiry is OIDC userinfo cache expiration or something similar, related to OIDC. The one shared observation so far is that it happens after "some time" passes between consecutive requests made by an authenticated user using a still-valid Bearer token.
I'll keep investigating and will try to find a minimal shareable reproducer project, but I'm currently extremely busy.
Here's my general setup, maybe something can be gleaned from it:
Quarkus:
3.17.2
installed extensions:
OIDC config from
application.properties
:I will keep tinkering and looking for reproduction steps
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
Unfortunately I have not found reproduction steps as this doesn't happen immediately and involves real world 3rd party authentication. I'll post steps if and when I do.
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
3.17.2
Build tool (ie. output of
mvnw --version
orgradlew --version
)Additional information
No response
The text was updated successfully, but these errors were encountered: