Skip to content

Commit

Permalink
fix: allow noauthentication destinations with proxytype “OnPremise” (#…
Browse files Browse the repository at this point in the history
…4354)

* fix: allow noauthentication destinations with proxytype “OnPremise”

* Apply suggestions from code review

Co-authored-by: Deeksha Sinha <88374536+deekshas8@users.noreply.github.com>

---------

Co-authored-by: Deeksha Sinha <88374536+deekshas8@users.noreply.github.com>
  • Loading branch information
marikaner and deekshas8 committed Dec 13, 2023
1 parent 4d2b49b commit 28c9cb7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-ads-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-cloud-sdk/connectivity': minor
---

[Fixed Issue] Allow the use of authentication type `NoAuthentication` with proxy type `OnPremise` without requiring the `SAP-Connectivity-Authentication` header.
5 changes: 5 additions & 0 deletions .changeset/witty-suns-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-cloud-sdk/connectivity': minor
---

[Compatibility Note] Using Principal Propagation through authentication type `NoAuthentication` is no longer supported. This resulted in erroneous behavior for destinations with authentication type `NoAuthentication`. If you need to use Principal Propagation use authentication type `PrincipalPropagation`.
27 changes: 1 addition & 26 deletions packages/connectivity/src/scp-cf/authorization-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('buildAuthorizationHeaders', () => {
).resolves.not.toThrow();
});

it('defaults to NoAuthentication and does not create authentication headers when only url is defined', async () => {
it('defaults to NoAuthentication and does not create authentication headers when only URL is defined', async () => {
const spy = jest.spyOn(destinationImport, 'sanitizeDestination');
const headerPromise = buildAuthorizationHeaders({
url: 'https://example.com'
Expand All @@ -65,31 +65,6 @@ describe('buildAuthorizationHeaders', () => {
);
expect((await headerPromise).authorization).toBeUndefined();
});

it("does not add authentication headers for proxy type 'Internet'", async () => {
const headers = await buildAuthorizationHeaders({
url: defaultDestination.url,
proxyType: 'Internet'
});
expect(headers.authorization).toBeUndefined();
});

it("adds on premise related headers for authentication type 'NoAuthentication' combined with proxy type 'OnPremise'", async () => {
const destination = {
url: '',
authentication: 'NoAuthentication',
proxyType: 'OnPremise',
proxyConfiguration: {
headers: {
'SAP-Connectivity-Authentication': 'someValueDestination',
'Proxy-Authorization': 'someProxyValue'
}
}
} as Destination;

const headers = await buildAuthorizationHeaders(destination);
checkHeaders(headers);
});
});

describe('client credentials', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/connectivity/src/scp-cf/authorization-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ async function getAuthenticationRelatedHeaders(
);
return;
case 'NoAuthentication':
if (destination.proxyType === 'OnPremise') {
return headerForPrincipalPropagation(destination);
}
return;
case 'ClientCertificateAuthentication':
return;
Expand Down

0 comments on commit 28c9cb7

Please sign in to comment.