-
Notifications
You must be signed in to change notification settings - Fork 245
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
fix: Add missing audience validation when accessing management api with oauth #4784
base: main
Are you sure you want to change the base?
fix: Add missing audience validation when accessing management api with oauth #4784
Conversation
6c55097
to
2063bb3
Compare
cc6d2fb
to
994b0c5
Compare
Not sure about the use of the context and key value of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally OK, but some problems with code consistency
@@ -96,6 +102,15 @@ public void initialize(ServiceExtensionContext context) { | |||
throw new EdcException(message); | |||
} | |||
|
|||
if (audience == null) { | |||
context.getMonitor().warning("No audience configured for delegated authentication, defaulting to the participantId"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: re-use monitor
from line 95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also replaced the previous context.monitor by the one form line 95.
...gated/src/main/java/org/eclipse/edc/api/auth/delegated/DelegatedAuthenticationExtension.java
Outdated
Show resolved
Hide resolved
...d/src/test/java/org/eclipse/edc/api/auth/delegated/DelegatedAuthenticationExtensionTest.java
Outdated
Show resolved
Hide resolved
...d/src/test/java/org/eclipse/edc/api/auth/delegated/DelegatedAuthenticationExtensionTest.java
Outdated
Show resolved
Hide resolved
@@ -57,4 +73,34 @@ public void delegatedProvider(DelegatedAuthenticationExtension extension) { | |||
verify(config).getLong(AUTH_CACHE_VALIDITY_MS, DEFAULT_CACHE_TIME_TO_LIVE); | |||
|
|||
} | |||
|
|||
@Test | |||
void initializeWithAudience(ServiceExtensionContext context, ObjectFactory factory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of using the objectfactory, you can directly inject the DelegatedAuthExtension
into the test method, c.f. the previous test method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I have done at first but if I do that the audience value is already injected with a null value before I can set it in the test.
d2dcca6
to
2e40ac1
Compare
2e40ac1
to
595a377
Compare
595a377
to
95217df
Compare
What this PR changes/adds
This PR add the audience Validation for the API management context
Why it does that
Not validating audience is a security risk.
Further notes
I have added some tests to validate the modification in the extension. But I could not find a way to change the value of an injected configuration field annotated by
@Settings
. So I can't unit test that when I set an audience, everything works as expected.I have validated the code manually though.
Who will sponsor this feature?
@paullatzelsperger
Linked Issue(s)
Closes #4768
Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.