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

Adds saml auth header to differentiate saml requests and prevents auto login as anonymous user when basic authentication fails #4152

Merged

Conversation

DarshitChanpura
Copy link
Member

@DarshitChanpura DarshitChanpura commented Mar 21, 2024

Description

This PR fixes a bug where SAML and Anonymous auth cannot co-exist. At present, enabling SAML along with anonymous auth causes SAML Login to fail before it hits the IdP because both SAML and anonymous auth are wired to not have credentials on the first login attempt, causing the authn check against the auth domains to be skipped (see here). This, eventually, results in setting the default user as anonymous (see here) since anonymous auth is enabled.

This PR also resolves another bug involving anonymous auth where a user would be automatically logged in as anonymous user upon failed basic authentication if anonymous auth is enabled.

  • Category: Bug fix
  • Why these changes are required?
    • To allow SAML auth to work when anonymous auth is enabled
    • To prevent auto login as anonymous user upon failed basic authentication

Security-dashboards companion PR: opensearch-project/security-dashboards-plugin#1839

Issues Resolved

Testing

  • Automated

Check List

  • New functionality includes testing
    - [ ] New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
@DarshitChanpura DarshitChanpura changed the title Adds saml auth header to differentiate saml requests Adds saml auth header to differentiate saml requests and prevents auto login as anonymous user when basic authentication fails Mar 21, 2024
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 53.84615% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 66.20%. Comparing base (4e8297a) to head (4a6dff7).
Report is 4 commits behind head on main.

❗ Current head 4a6dff7 differs from pull request most recent head 5174654. Consider uploading reports for the commit 5174654 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4152   +/-   ##
=======================================
  Coverage   66.19%   66.20%           
=======================================
  Files         301      301           
  Lines       21709    21712    +3     
  Branches     3505     3505           
=======================================
+ Hits        14371    14375    +4     
+ Misses       5580     5578    -2     
- Partials     1758     1759    +1     
Files Coverage Δ
.../org/opensearch/security/auth/BackendRegistry.java 61.58% <53.84%> (-0.96%) ⬇️

... and 5 files with indirect coverage changes

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Copy link
Collaborator

@derek-ho derek-ho left a comment

Choose a reason for hiding this comment

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

I don't have any concerns with the implementation of this change, since I think it preserves functionality, but trying to understand more about @peternied's concern with the headers

peternied
peternied previously approved these changes Mar 29, 2024
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
cwperks
cwperks previously approved these changes Apr 2, 2024
peternied
peternied previously approved these changes Apr 3, 2024
Copy link
Contributor

@stephen-crawford stephen-crawford left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
@DarshitChanpura
Copy link
Member Author

DarshitChanpura commented Apr 9, 2024

All failures caused by:

java.lang.NoSuchMethodError: 'void org.opensearch.transport.TcpTransport.inboundMessage(org.opensearch.transport.TcpChannel, org.opensearch.transport.ProtocolInboundMessage)'

Root-cause is likely this upstream change: opensearch-project/OpenSearch#12967.

Update: This issue has been resolved.

Copy link
Contributor

@stephen-crawford stephen-crawford left a comment

Choose a reason for hiding this comment

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

Looks good to me

@cwperks cwperks added the backport 2.x backport to 2.x branch label Apr 9, 2024
@DarshitChanpura DarshitChanpura merged commit d87ab3f into opensearch-project:main Apr 9, 2024
78 of 79 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 9, 2024
…o login as anonymous user when basic authentication fails (#4152)

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
(cherry picked from commit d87ab3f)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
dlin2028 pushed a commit to dlin2028/security that referenced this pull request May 1, 2024
…o login as anonymous user when basic authentication fails (opensearch-project#4152)

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants