pacj4: add UserProfile attributes to AuthenticationResult context#16109
pacj4: add UserProfile attributes to AuthenticationResult context#16109abhishekagarwal87 merged 6 commits intoapache:masterfrom
Conversation
|
Can you describe the authorization flow that uses these attributes? |
77f164c to
14e85ae
Compare
Sorry, I was still working on this change for druid 28.0.1, code should compile now. |
|
+1 to storing all attributes in the authentication context, and thanks @jakubmatyszewski for the tag! For our use case, we rely on some of the claims (such as group, role etc.) to perform fine grain access control on different types of resources. At the moment, the pac4j oidc extension only supports binary yes/no decision, which might work for basic scenarios but definitely not adequate for more advanced use cases. |
| true, false, false, null); | ||
| } else { | ||
| Object uid = securityLogic.perform( | ||
| OidcProfile profile = (OidcProfile) securityLogic.perform( |
There was a problem hiding this comment.
can you use UserProfile interface that the iterator is returning?
There was a problem hiding this comment.
I'm not certain, I don't know java, but I think it's useful in here - since we use OIDC config here, the UserProfiles should always be complient with OidcProfile anyway. And later OidcProfile is more convenient to pass the context - UserProfile doesn't have explicit function to return all attributes at once, which is the goal here.
I'm eager to learn if what I've wrote is not correct, let me know.
There was a problem hiding this comment.
profiles.iterator().next() is returning UserProfile which is an interface. I was thinking that you use that but it doesn't have getAttributes method. But now I am wondering why not pass the whole profile itself.
AuthenticationResult authenticationResult = new AuthenticationResult(profile.getId(), authorizerName, name, ImmutableMap.of("profile", profile))
There was a problem hiding this comment.
let's do the above and cast the result of .perform to UserProfile.
There was a problem hiding this comment.
Hm, okay. That sounds reasonable.
Need to think about possible security implications of this change
abhishekagarwal87
left a comment
There was a problem hiding this comment.
can you please add a unit test to verify that the profile is populated in the context?
Um, I've added a test, but I'm not sure if it's any good. Let me know if that's ok, or I should seek guidance on this. |
|
I guess it's not possible to add one. It's best to remove the one you added as that one doesn't look useful. |
This reverts commit 79a6dfe.
Description
I'm adding OIDC context to the
AuthenticationResultreturned by pac4j extension. I wanted to use this context as input in OpenPolicyAgent authorization. SinceAuthenticationResultalready acceptscontextas a parameter it felt okay to pass the profile attributes there.Release note
pac4j: Add OIDC context to the authentication result
Key changed/added classes in this PR
org.apache.druid.security.pac4j.Pac4jFilter.doFilter()This PR has: