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 support of OAuth 2.0/OIDC 'code with PKCE' flow (back-end) #1792

Merged

Conversation

laminelam
Copy link
Contributor

@laminelam laminelam commented Jul 18, 2023

https://issues.apache.org/jira/browse/SOLR-16897

This is the "back-end" part of 'code with PKCE' contribution.

The back-end code is mainly for configuration. This is where the different options are configured.

This PR adds tokenEndpoint and authorizationFlow options.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

Copy link
Contributor

@janhoy janhoy left a comment

Choose a reason for hiding this comment

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

Looks overall good.

Please do a stab on RefGuide docs. The ref guide should encourage the use of code flow and warn that implicit flow support is deprecated.

Perhaps we can also print a WARN log in backend if implicit is in use (either explicitly or implicitly) so that users upgrading to 9.4 without reading the release notes will at least get a warn log that they should switch.

@laminelam laminelam force-pushed the feature/SOLR-16897-oautho20-oidc-pkce-back-end branch 15 times, most recently from ee18897 to 6437c1b Compare August 17, 2023 20:27
@laminelam laminelam closed this Aug 17, 2023
@laminelam laminelam force-pushed the feature/SOLR-16897-oautho20-oidc-pkce-back-end branch from 6437c1b to 9cdf0e4 Compare August 17, 2023 20:28
@HoustonPutman HoustonPutman reopened this Aug 17, 2023
@laminelam
Copy link
Contributor Author

Looks overall good.

Please do a stab on RefGuide docs. The ref guide should encourage the use of code flow and warn that implicit flow support is deprecated.

Perhaps we can also print a WARN log in backend if implicit is in use (either explicitly or implicitly) so that users upgrading to 9.4 without reading the release notes will at least get a warn log that they should switch.

Thank you @janhoy for the review.
I am planning to add a new entry to the ref guide.
BTW, I have added a WARN message.

@janhoy
Copy link
Contributor

janhoy commented Aug 22, 2023

BTW, I have added a WARN message.

Thanks, the validation and warn log looks good 👍

Will do a final review when refguide docs are in. Also remember CHANGES.txt.

Copy link
Contributor

@janhoy janhoy left a comment

Choose a reason for hiding this comment

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

  • Add refguide docs
  • CHANGES entry
  • Constant naming
  • Backend part of CSP header

@janhoy
Copy link
Contributor

janhoy commented Aug 29, 2023

Eager to get this into 9.4. Let me know if we can help finalizing these two PRs

@laminelam
Copy link
Contributor Author

laminelam commented Aug 29, 2023

Eager to get this into 9.4. Let me know if we can help finalizing these two PRs

@janhoy
I should push a new commit sometime today. I have changed little bit your CSP patch, I just need to add a test class for LoadAdminUiServlet.

@janhoy
Copy link
Contributor

janhoy commented Aug 29, 2023

Eager to get this into 9.4. Let me know if we can help finalizing these two PRs

@janhoy I should push a new commit sometime today. I have changed little bit your CSP patch, I just need to add a test class for LoadAdminUiServlet.

Cool. In my patch i completely disabled CSP response for all other endpoints than the AdminUIServlet. I cannot see a reason to return that header for other endpoints. The only I can think of is if you have a solr package that exposes another UI on some path, it could be nice to protect that UI with CSP rules, so if it would be possible to have some fallback CSP header for all other requests perhaps?

@laminelam
Copy link
Contributor Author

laminelam commented Aug 30, 2023

Eager to get this into 9.4. Let me know if we can help finalizing these two PRs

@janhoy I should push a new commit sometime today. I have changed little bit your CSP patch, I just need to add a test class for LoadAdminUiServlet.

Cool. In my patch i completely disabled CSP response for all other endpoints than the AdminUIServlet. I cannot see a reason to return that header for other endpoints. The only I can think of is if you have a solr package that exposes another UI on some path, it could be nice to protect that UI with CSP rules, so if it would be possible to have some fallback CSP header for all other requests perhaps?

Yes I was thinking the same thing, we don't need this header for non browser targeted servlets (API endpoint, etc.), it will be just ignored by other endpoints. Now, I am not sure of a scenario where we would need a different UI servlet exposed on a different path. Let me think about it and get back to you hopefully by tomorrow.

@laminelam
Copy link
Contributor Author

laminelam commented Aug 30, 2023

  • Add refguide docs
  • CHANGES entry
  • Constant naming
  • Backend part of CSP header

Will add the CHANGES entry.

Here are the main changes to the patch:

  • In line with the security best practice of granting minimal necessary permissions, adjusted the registerTokenEndpointForCsp() method to incorporate the precise URL for the /token endpoint rather than a more general host:port based URL.

  • Thought providing the capability of passing the URLs as a comma-separated list is less confusing for the end-user/operator compared to using a prefix-based system property name. This approach also enables more concise implementation.

@janhoy janhoy requested a review from rmuir August 31, 2023 08:20
@epugh
Copy link
Contributor

epugh commented Aug 31, 2023

We do have two packages "in the wild" that come with a UI, the YASA package https://github.com/yasa-org/yasa and Splainer, https://github.com/o19s/splainer/tree/main/solr-splainer-package. Will these packages need to be updated?

If we want to make this change, and that ripples down to packages, then we should do it now before more Packages are developed ;-).

We do have a test (commented out) that validates deploying Packages that might be useful: https://github.com/apache/solr/blob/main/solr/packaging/test/test_packages.bats#L69

@janhoy
Copy link
Contributor

janhoy commented Aug 31, 2023

We do have two packages "in the wild" that come with a UI

As stated anove, we never really needed to disable the old CSP header config in jetty.xml. Turns out the LoadAdminUiServlet simply replaces the header, which is nice.

@laminelam
Copy link
Contributor Author

THANK YOU @janhoy for your extensive review and contribution.
I think the PR is now good for a merge.

solr/CHANGES.txt Outdated Show resolved Hide resolved
solr/CHANGES.txt Show resolved Hide resolved
Copy link
Contributor

@janhoy janhoy left a comment

Choose a reason for hiding this comment

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

I fixed the merge conflict and CHANGES entry. Think this is good to go now. Great work!

@janhoy
Copy link
Contributor

janhoy commented Sep 1, 2023

I'm going to force-push a squashed git-history in order for full test suite to run. Will preserve you as commit author..

@janhoy janhoy force-pushed the feature/SOLR-16897-oautho20-oidc-pkce-back-end branch from f517f38 to 8264b15 Compare September 1, 2023 12:04
@janhoy janhoy merged commit 931de51 into apache:main Sep 3, 2023
janhoy pushed a commit to janhoy/solr that referenced this pull request Sep 3, 2023
…he#1792)

Co-authored-by: Lamine Idjeraoui <[email protected]>
Co-authored-by: Jan Høydahl <[email protected]>

(cherry picked from commit 931de51)
janhoy added a commit that referenced this pull request Sep 3, 2023
… (#1889)

Co-authored-by: Lamine Idjeraoui <[email protected]>
Co-authored-by: Jan Høydahl <[email protected]>

(cherry picked from commit 931de51)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants