Skip to content

Commit

Permalink
fix: Mail multi-tenancy token exchange (#4831)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfrenken authored Jul 15, 2024
1 parent 432fef7 commit 86f4158
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/ninety-lobsters-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sap-cloud-sdk/connectivity': patch
'@sap-cloud-sdk/mail-client': patch
---

[Fixed Issue] Fix token fetching for mail multi-tenancy scenarios.
12 changes: 9 additions & 3 deletions packages/connectivity/src/scp-cf/connectivity-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createLogger, ErrorWithCause } from '@sap-cloud-sdk/util';
import { JwtPayload } from 'jsonwebtoken';
import { Protocol } from './protocol';
import {
ProxyConfiguration,
Expand Down Expand Up @@ -31,7 +32,9 @@ export async function addProxyConfigurationOnPrem(
if (destination.type === 'MAIL') {
return {
...destination,
proxyConfiguration: await socksProxyHostAndPort(subscriberToken)
proxyConfiguration: await socksProxyHostAndPort(
subscriberToken?.userJwt.decoded
)
};
}

Expand Down Expand Up @@ -67,13 +70,16 @@ export function httpProxyHostAndPort(): HostAndPort {

/**
* @internal
* @param userJwt - The user JWT
* @returns Socks Proxy Configuration
*/
export async function socksProxyHostAndPort(
jwt?: Required<SubscriberToken>
userJwt?: JwtPayload
): Promise<ProxyConfiguration> {
const service = readConnectivityServiceBinding();
const connectivityServiceToken = await serviceToken(service, { jwt });
const connectivityServiceToken = await serviceToken(service, {
jwt: userJwt
});
return {
host: service.credentials.onpremise_proxy_host,
port: parseInt(service.credentials.onpremise_socks5_proxy_port),
Expand Down

0 comments on commit 86f4158

Please sign in to comment.