Skip to content

Commit 9f8d51c

Browse files
Add Scope Support
Add the ability to request custom scopes (permissions) on token retrieval. Set data Gateway to default permissions to the global Entra ID app registration (SHI - Data Gateway).
1 parent 720166d commit 9f8d51c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/dataGateway/TypeScript/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ export type * from './sdk/models/index.js';
1111
* Function that initializes the Data Gateway SDK.
1212
* @param credential Configured authentication session.
1313
* @param baseUrl Root of the URL that should have endpoints appended to it by the query building system.
14+
* @param scopeList Specific audience and or list of permissions to request on the access token when retrieved. Defaults to the global data gateway enterprise app with whatever credentials the current principal has assigned.
1415
* @returns Configured API client that is able to make requests against SHI Data Gateway.
1516
*/
16-
export function dataGatewayClientFactory(credential: TokenCredential, baseUrl?: URL) {
17+
export function dataGatewayClientFactory(credential: TokenCredential, baseUrl?: URL, scopeList?: string[]) {
1718
// #region Input Validation
1819
assert(credential);
1920

2021
assertGuardEquals(baseUrl);
22+
23+
assertGuardEquals(scopeList);
2124
// #endregion Input Validation
2225

2326
/** List of hosts that are allowed when making API calls, this is used to prevent token leaks to threat actors. */
2427
const allowedHostList = new Set([baseUrl?.host ?? 'api.shilab.com']);
2528

2629
/** Authentication system that will be used to configure the SDK client. */
27-
const authProvider = new AzureIdentityAuthenticationProvider(credential, void 0, void 0, allowedHostList);
30+
const authProvider = new AzureIdentityAuthenticationProvider(credential, scopeList ?? ['4c40281b-a305-4aaf-90a4-d5bbee6eb8ed/.default'], void 0, allowedHostList);
2831

2932
/** Instance of the data gateway client initialization configuration. */
3033
const dataGatewayAdapter = new FetchRequestAdapter(authProvider);

src/shield/TypeScript/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ export type * from './sdk/models/index.js';
1111
* Function that initializes the SHIELD SDK.
1212
* @param credential Configured authentication session from Entra ID.
1313
* @param baseUrl Root of the URL that should have endpoints appended to it by the query building system.
14+
* @param scopeList Where each array item is a different Entra ID standard scope to request on token retrieval. E.g. `['313f3894-325a-4aae-ba2b-bbdfdc1f063b/.default']`
1415
* @returns Configured API client that is able to make requests against the specified SHIELD instance.
1516
*/
16-
export function shieldClientFactory(credential: TokenCredential, baseUrl: URL) {
17+
export function shieldClientFactory(credential: TokenCredential, baseUrl: URL, scopeList: string[]) {
1718
// #region Input Validation
1819
assert(credential);
1920

2021
assertGuardEquals(baseUrl);
22+
23+
assertGuardEquals(scopeList);
2124
// #endregion Input Validation
2225

2326
/** List of hosts that are allowed when making API calls, this is used to prevent token leaks to threat actors. */
2427
const allowedHostList = new Set([baseUrl.host]);
2528

2629
/** Authentication system that will be used to configure the SDK client. */
27-
const authProvider = new AzureIdentityAuthenticationProvider(credential, void 0, void 0, allowedHostList);
30+
const authProvider = new AzureIdentityAuthenticationProvider(credential, scopeList, void 0, allowedHostList);
2831

2932
/** Instance of the SHIELD SDK client initialization configuration. */
3033
const shieldAdapter = new FetchRequestAdapter(authProvider);

0 commit comments

Comments
 (0)