KNOX-3424: Dynamic audience handling in the KNOXTOKEN service - #1356
KNOX-3424: Dynamic audience handling in the KNOXTOKEN service#1356hanicz wants to merge 2 commits into
Conversation
Test Results 4 files 4 suites 10s ⏱️ Results for commit f0962a3. ♻️ This comment has been updated with latest results. |
hsheinblatt
left a comment
There was a problem hiding this comment.
Thanks Tamás. See comment below, but I believe this logic needs to be moved to the filter. We'll need it there for knoxidf, and it would be confusing to have multiple audience request validation paths. We can discuss if that decision should be overruled and we are to put it in the token resource -- I had that plan too initially, but on retrospect, putting it in the filter is more consistent with the filter philosophy.
| setupPublicCertPEM(); | ||
| String jku = getJku(); | ||
|
|
||
| final List<String> audiences; |
There was a problem hiding this comment.
This makes sense, but for the RFC 8693 extension, we'll have to validate the audience in the filter. We're going to need it for this release of knoxidf, and we'll have to validate it against policy in the filter stage. For same-subject exchanges, there are conventions (it's optional, but vendors use it in somewhat standard ways). Most will try to validate it against some kind of policy, like a stored allowed list in the client_id registration, per subject allow list, or the subject token aud list. But these are the kinds of things we're planning to put in the filter logic. I had initially thought to put it in knoxidf TokenResource that overrides this class, but that path was argued against: though this is kind of a 'token exchange request authorization' step rather than a 'token authorization' step, it was still required to put in the filter.
I had more in mind setting a request parameter for the resolved audience to use that the token resource would read instead of the hardcoded targetAudience -- or that would be replaced by the dynamic value derived in the filter. I hadn't designed this in detail yet as I was recently informed the logic was to be in the filter.
So, for consistency, it would be better to put this logic in the same place. Then there's only one flow that validates the requested audience, and we just branch off that flow based on how we want to authorize it based on some config parameter -- whether to use delegation authz, or same-subject exchange authz, or the whitelist.
| for (String audience : requested) { | ||
| if (!targetAudiences.contains(audience)) { | ||
| throw new AudienceValidationException("The requested audience '" + audience + "' is not allowed.", | ||
| ErrorCode.INVALID_AUDIENCE); |
There was a problem hiding this comment.
For all these errors, they'll end up as invalid_request type errors for the RFC 8693 flows. So for consistency with #1354, we'll need to ensure the right error mapping happens in the response. See comment above, but if this logic moves to the filter, then that part will be easier.
KNOX-3424 - Dynamic audience handling in the KNOXTOKEN service
What changes were proposed in this pull request?
Callers can now request a token's aud claim per request via an audience query parameter, validated against the existing
knox.token.audienceswhitelist to prevent audience/token spoofing.Behavior
audienceparam → unchanged; the statically configuredknox.token.audiencesare used.audienceparam + no whitelist configured →400(secure by default — nothing to validate against).audienceparam + all values in the whitelist → only the requested audience(s) land inaud.audienceparam + any value not whitelisted →400.How was this patch tested?
Unit tests, local tests
Integration Tests
N/A
UI changes
N/A