Skip to content
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

Add custom parameters to authorize and logout endpoints #480

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eva-mueller-coremedia
Copy link
Contributor

@eva-mueller-coremedia eva-mueller-coremedia commented Dec 14, 2024

This PR

query-params

Testing done

This change has been tested by unit tests as well as local testing agains AWS Cognito.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@eva-mueller-coremedia eva-mueller-coremedia requested a review from a team as a code owner December 14, 2024 23:08
Copy link

codecov bot commented Dec 14, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 74.38%. Comparing base (13300b6) to head (4ceb342).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...insci/plugins/oic/AbstractKeyValueDescribable.java 86.36% 2 Missing and 1 partial ⚠️
...va/org/jenkinsci/plugins/oic/OicSecurityRealm.java 94.28% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #480      +/-   ##
============================================
+ Coverage     72.55%   74.38%   +1.83%     
- Complexity      248      282      +34     
============================================
  Files            20       24       +4     
  Lines          1115     1183      +68     
  Branches        154      169      +15     
============================================
+ Hits            809      880      +71     
+ Misses          210      207       -3     
  Partials         96       96              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eva-mueller-coremedia eva-mueller-coremedia changed the title Add custom parameters to authorize and logout endpoint Add custom parameters to authorize and logout endpoints Dec 15, 2024
Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eva-mueller-coremedia thanks for this.

I have had a quick look and have a few comments around the UX side.

The extra parameters would IIUC not be needed in the majority of conformant IDPs, as such do you thing they should be hidden behind an advanced section?

the use of a single string for multiple keyvalue pairs (and the encoding /splitting shenaningans) would seem to be error prone (and it lacks good warnings on invalid input). (a value may need to encode & and then you need to escape it)
Would making the KeyValue a Describable and using a repeatable option using repeatableProperty or the like (which can then perform individual valuation of the key and the value). NB not sur how this would look in CasC.

@eva-mueller-coremedia
Copy link
Contributor Author

@jtnord Thanks for the feedback, will try to follow a key value pair pattern.

If you don't mind, I would like to remove the UI at all - only provide it to be set via CasC resp. Java/Groovy code. Any objections?

@jtnord
Copy link
Member

jtnord commented Dec 24, 2024

@jtnord Thanks for the feedback, will try to follow a key value pair pattern.

If you don't mind, I would like to remove the UI at all - only provide it to be set via CasC resp. Java/Groovy code. Any objections?

it's generally considered bad to have something exposed in the UI and not CasC and vice versa. Not exposing in the UI can lead to it getting overridden if someone saves the Jenkins form in the UI (which I say you should never do as if you manage by code you should have a read only system UI, but it is useful on test systems where you want to make changes in the UI and then export the config for applying to a different server).

@eva-mueller-coremedia
Copy link
Contributor Author

@jtnord Thanks for the feedback, will try to follow a key value pair pattern.
If you don't mind, I would like to remove the UI at all - only provide it to be set via CasC resp. Java/Groovy code. Any objections?

it's generally considered bad to have something exposed in the UI and not CasC and vice versa. Not exposing in the UI can lead to it getting overridden if someone saves the Jenkins form in the UI (which I say you should never do as if you manage by code you should have a read only system UI, but it is useful on test systems where you want to make changes in the UI and then export the config for applying to a different server).

Understood. 👍 I will have a look to implement it the way you described initially. Thanks for the explanation!

@eva-mueller-coremedia eva-mueller-coremedia force-pushed the query-params branch 2 times, most recently from 418804d to dce7676 Compare December 24, 2024 21:59
@eva-mueller-coremedia eva-mueller-coremedia force-pushed the query-params branch 2 times, most recently from 01a48ec to bf28327 Compare December 25, 2024 11:55
@eva-mueller-coremedia
Copy link
Contributor Author

@jtnord Thanks for the review. Will take care after my 1 week vacation.

@eva-mueller-coremedia
Copy link
Contributor Author

@jtnord How to re-trigger the failed Jenkins run - there has been a java.net.SocketTimeoutException: Read timed out when downloading artifacts from azure...

@jtnord
Copy link
Member

jtnord commented Jan 20, 2025

@jtnord How to re-trigger the failed Jenkins run - there has been a java.net.SocketTimeoutException: Read timed out when downloading artifacts from azure...

For non maintainers, adding a new commit.

@eva-mueller-coremedia eva-mueller-coremedia force-pushed the query-params branch 3 times, most recently from 2c20523 to e933a1c Compare January 22, 2025 21:52
@eva-mueller-coremedia
Copy link
Contributor Author

eva-mueller-coremedia commented Jan 22, 2025

@jtnord The PR is now ready for a re-review.

I also extracted the FormValidation fix to #507

@eva-mueller-coremedia eva-mueller-coremedia force-pushed the query-params branch 3 times, most recently from 3e7c8cd to 219bd26 Compare February 4, 2025 20:44
@eva-mueller-coremedia
Copy link
Contributor Author

Sorry for nudging again - @jtnord @michael-doubez would be great if you could have a look.

Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks reasonable but some things look a little weird and I am wondering if thebUX can be improved at all.
I wanted to try and get some time to see if this can be improved and submit a PR to the PR as doing so after merging would possibly require even more data migration that we already have.realistically this is not going to happen this week.

@eva-mueller-coremedia
Copy link
Contributor Author

realistically this is not going to happen this week.

Thanks for this estimate. Would be great to see this feature in the (near) future since AWS Cognito requires some additional query parameters.

It would be great if you could keep me/subscribers posted about the state of this PR from time to time. Thanks in advance.

@jtnord
Copy link
Member

jtnord commented Feb 17, 2025

@eva-mueller-coremedia I filed
eva-mueller-coremedia#1 against your PR.

Moves the parameters to their own types and added validation for them so it's validated in the UI. Also ensures the config can never be invalid.
Tidies up the jelly slightly.

public static class DescriptorImpl extends AbstractKeyValueDescribable.DescriptorImpl<LoginQueryParameter> {

@Override
public FormValidation doCheckKey(@QueryParameter String key) {

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing permission check Warning

Potential missing permission check in DescriptorImpl#doCheckKey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing sensitive here.
Whilst we could add a permission check we are only doing string comparisons

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtnord Unfortunately, I do not know how to resolve all the problems found by the github-advanced-security. Can you help me here or step in? That would be great.

Also there is already one dismissed problem. Dunno who or how this got dismissed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can take a look.
I dismissed one as a false positive. (key was not sensitive in that context)

public static class DescriptorImpl extends AbstractKeyValueDescribable.DescriptorImpl<LoginQueryParameter> {

@Override
public FormValidation doCheckKey(@QueryParameter String key) {

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing POST/RequirePOST annotation Warning

Potential CSRF vulnerability: If DescriptorImpl#doCheckKey connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST
public static class DescriptorImpl extends AbstractKeyValueDescribable.DescriptorImpl<LogoutQueryParameter> {

@Override
public FormValidation doCheckKey(@QueryParameter String key) {

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing permission check Warning

Potential missing permission check in DescriptorImpl#doCheckKey
public static class DescriptorImpl extends AbstractKeyValueDescribable.DescriptorImpl<LogoutQueryParameter> {

@Override
public FormValidation doCheckKey(@QueryParameter String key) {

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing POST/RequirePOST annotation Warning

Potential CSRF vulnerability: If DescriptorImpl#doCheckKey connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST
@eva-mueller-coremedia
Copy link
Contributor Author

eva-mueller-coremedia commented Feb 17, 2025

@eva-mueller-coremedia I filed eva-mueller-coremedia#1 against your PR.

Moves the parameters to their own types and added validation for them so it's validated in the UI. Also ensures the config can never be invalid. Tidies up the jelly slightly.

Thank you for the PR. I additionally removed the commented out test.

@jtnord jtnord self-assigned this Feb 26, 2025
This allows us to add parameter validation in the UI as the validation
is now performed in the descriptor and prevents a bad describable from
being constructed.
throw new Descriptor.FormException(valueValidation.getMessage(), "value");
}
this.key = key.trim();
this.value = value == null ? "" : value.trim();
Copy link
Contributor Author

@eva-mueller-coremedia eva-mueller-coremedia Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jtnord - I added some more test cases and encountered for LogoutQueryParameters a NPE when the value is null.

Is this solution OK for you?

In case the this.value should then be null, then all getValue() needs to be covered as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants