-
Notifications
You must be signed in to change notification settings - Fork 64
feat: [DO NOT MERGE] IAS App-To-App Auth #6185
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
base: main
Are you sure you want to change the base?
Changes from all commits
90a2f9a
b2d80f4
0ed94aa
5ec4657
a541e18
24cd0a7
1348182
2f2cbf6
f9ce3a5
9990c6f
a146af2
6ab8a1f
e5e67eb
cd8e736
34b83be
fdb3d35
af1d0bd
62d4023
437fd87
de930e4
fbcca4b
e71c268
738d697
4f925f5
4157094
e60cd48
41dde3c
a3a8b5e
7c166fe
714623c
5fdc97e
08313ba
5cda06c
51129d6
67e7d13
7778cd0
41cac51
6514dcd
87c7a9f
ac48d3a
8dbc043
83ff890
0a0d661
651882b
005e875
5418c33
0c67544
189a529
74e8bbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@sap-cloud-sdk/connectivity': minor | ||
| --- | ||
|
|
||
| [New Functionality] Support IAS (App-to-App) authentication (experimental). Use `transformServiceBindingToDestination()` function or `getDestinationFromServiceBinding()` function to create a destination targeting an IAS application. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import type { Destination } from './destination-service-types'; | |
| import type { CachingOptions } from '../cache'; | ||
| import type { Service } from '../environment-accessor'; | ||
| import type { JwtPayload } from '../jsonwebtoken-type'; | ||
| import type { IasOptions } from './ias-types'; | ||
|
|
||
| const logger = createLogger({ | ||
| package: 'connectivity', | ||
|
|
@@ -31,15 +32,25 @@ export async function getDestinationFromServiceBinding( | |
| DestinationFetchOptions, | ||
| 'jwt' | 'iss' | 'useCache' | 'destinationName' | ||
| > & | ||
| DestinationFromServiceBindingOptions | ||
| DestinationFromServiceBindingOptions & { iasOptions?: IasOptions } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [q] Why do we need the extra
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ): Promise<Destination> { | ||
| const decodedJwt = options.iss | ||
| ? { iss: options.iss } | ||
| : options.jwt | ||
| ? decodeJwt(options.jwt) | ||
| : undefined; | ||
|
|
||
| const retrievalOptions = { ...options, jwt: decodedJwt }; | ||
| // If using business user authentication with IAS and no assertion provided, use the JWT from options | ||
| let iasOptions = options.iasOptions; | ||
| if ( | ||
| iasOptions?.authenticationType === 'OAuth2JWTBearer' && | ||
| options.jwt && | ||
| !iasOptions.assertion | ||
| ) { | ||
| iasOptions = { ...iasOptions, assertion: options.jwt }; | ||
| } | ||
|
|
||
| const retrievalOptions = { ...options, jwt: decodedJwt, iasOptions }; | ||
| const destination = await retrieveDestination(retrievalOptions); | ||
|
|
||
| const destWithProxy = | ||
|
|
@@ -60,14 +71,17 @@ async function retrieveDestination({ | |
| useCache, | ||
| jwt, | ||
| destinationName, | ||
| iasOptions, | ||
| serviceBindingTransformFn | ||
| }: Pick<DestinationFetchOptions, 'useCache' | 'destinationName'> & { | ||
| jwt?: JwtPayload; | ||
| iasOptions?: IasOptions; | ||
| } & DestinationFromServiceBindingOptions) { | ||
| const service = getServiceBindingByInstanceName(destinationName); | ||
| const destination = await (serviceBindingTransformFn || transform)(service, { | ||
| useCache, | ||
| jwt | ||
| jwt, | ||
| ...(iasOptions ? { iasOptions } : {}) | ||
| }); | ||
|
|
||
| return { name: destinationName, ...destination }; | ||
|
|
@@ -91,6 +105,10 @@ export type ServiceBindingTransformOptions = { | |
| * The JWT payload used to fetch destinations. | ||
| */ | ||
| jwt?: JwtPayload; | ||
| /** | ||
| * The options for IAS token retrieval. | ||
| */ | ||
| iasOptions?: IasOptions; | ||
| } & CachingOptions; | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.