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

fix: DwC Auth Token not available #337

Merged
merged 7 commits into from
Mar 7, 2024
Merged

Conversation

MatKuhr
Copy link
Member

@MatKuhr MatKuhr commented Feb 29, 2024

Context

SAP/cloud-sdk-java-backlog#424.

I think we just forgot to implement this earlier. This change makes our AuthTokenAccessor actually return a token in the DwC case. Without this change, one always gets an exception (unless using CAP).

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

@MatKuhr MatKuhr added bug Something isn't working please merge Request to merge a pull request please review Request to review a pull request labels Feb 29, 2024
@@ -1 +0,0 @@
com.sap.cloud.sdk.cloudplatform.security.secret.ScpCfSecretStoreFacade
Copy link
Member Author

Choose a reason for hiding this comment

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

driveby cleanup of dead code

@@ -1 +0,0 @@
com.sap.cloud.sdk.cloudplatform.security.DefaultAuthTokenFacade
Copy link
Member Author

Choose a reason for hiding this comment

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

removing this should be fine because the Accessor uses this facade regardless by default (without classloading)

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't if the DwcAuthTokenFacade is class loaded

Copy link
Contributor

@CharlesDuboisSAP CharlesDuboisSAP left a comment

Choose a reason for hiding this comment

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

Should this be E2E tested?

Copy link
Member Author

@MatKuhr MatKuhr left a comment

Choose a reason for hiding this comment

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

currently drafting an E2E test here based on this test code.

@MatKuhr MatKuhr enabled auto-merge (squash) March 6, 2024 13:39
Comment on lines +23 to +27
@Test
void testFacadeIsPickedUpAutomatically()
{
assertThat(AuthTokenAccessor.getAuthTokenFacade()).isInstanceOf(DwcAuthTokenFacade.class);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

private static AuthToken extractAuthTokenFromDwcHeaders()
{
try {
final String token = DwcHeaderUtils.getDwcTokenOrThrow();
Copy link
Contributor

Choose a reason for hiding this comment

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

[question]

Can you remind me what we decided regarding "DwC header injection" attacks (i.e. someone somehow calls the app and injects their own dwc-* headers)?
I know we discussed this topic a while back but cannot quite recall what we decided.

Copy link
Member Author

Choose a reason for hiding this comment

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

we figured not an issue for various reasons, including for example:

  • the dwc dependencies don't come in automatically and it's decently unlikely that they can come transitively outside of DwC
  • even if they are present, the multi tenancy would not work at all without the dwc headers, so any multi-tenant app should detect this during development

MatKuhr and others added 2 commits March 7, 2024 14:59
Copy link
Contributor

@Johannes-Schneider Johannes-Schneider left a comment

Choose a reason for hiding this comment

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

LGTM

@MatKuhr MatKuhr merged commit 78c1f60 into main Mar 7, 2024
16 checks passed
@MatKuhr MatKuhr deleted the fix/dwc-authtoken-accessor branch March 7, 2024 14:18
jingweiz2017 pushed a commit to jingweiz2017/cloud-sdk-java that referenced this pull request Aug 28, 2024
… enhancement on top of SAP#337 to include dwc-ias-jwt in header as auth token as well. dwc-ias-jwt is the key used for auth token when dwc is integrated with ias for authentication.
jingweiz2017 pushed a commit to jingweiz2017/cloud-sdk-java that referenced this pull request Aug 29, 2024
… enhancement on top of SAP#337 to include dwc-ias-jwt in header as auth token as well. dwc-ias-jwt is the key used for auth token when dwc is integrated with ias for authentication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working please merge Request to merge a pull request please review Request to review a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants