diff --git a/.changeset/lemon-chefs-grab.md b/.changeset/lemon-chefs-grab.md new file mode 100644 index 0000000000..6c020b7863 --- /dev/null +++ b/.changeset/lemon-chefs-grab.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-msgraph': patch +--- + +Read `queryMode` from the `microsoftGraphOrg` config diff --git a/plugins/catalog-backend-module-msgraph/config.d.ts b/plugins/catalog-backend-module-msgraph/config.d.ts index df41b581f9..9fe1cb81c9 100644 --- a/plugins/catalog-backend-module-msgraph/config.d.ts +++ b/plugins/catalog-backend-module-msgraph/config.d.ts @@ -144,6 +144,15 @@ export interface Config { */ clientSecret?: string; + /** + * By default, the Microsoft Graph API only provides the basic feature set + * for querying. Certain features are limited to advanced query capabilities + * (see https://docs.microsoft.com/en-us/graph/aad-advanced-queries) + * and need to be enabled. + * + * Some features like `$expand` are not available for advanced queries, though. + */ + queryMode?: string; user?: { /** * The "expand" argument to apply to users. @@ -230,6 +239,15 @@ export interface Config { */ clientSecret: string; + /** + * By default, the Microsoft Graph API only provides the basic feature set + * for querying. Certain features are limited to advanced query capabilities + * (see https://docs.microsoft.com/en-us/graph/aad-advanced-queries) + * and need to be enabled. + * + * Some features like `$expand` are not available for advanced queries, though. + */ + queryMode?: string; user?: { /** * The filter to apply to extract users. diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.test.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.test.ts index 8e2866df65..3331e3609d 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.test.ts @@ -162,6 +162,7 @@ describe('readProviderConfigs', () => { clientId: 'clientId', clientSecret: 'clientSecret', authority: 'https://login.example.com/', + queryMode: 'advanced', user: { expand: 'manager', filter: 'accountEnabled eq true', @@ -185,6 +186,7 @@ describe('readProviderConfigs', () => { clientId: 'clientId', clientSecret: 'clientSecret', authority: 'https://login.example.com/', + queryMode: 'advanced', userExpand: 'manager', userFilter: 'accountEnabled eq true', groupExpand: 'member', diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.ts index 2429b67c89..b8565e0d72 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/config.ts @@ -261,6 +261,15 @@ export function readProviderConfig( const groupSearch = config.getOptionalString('group.search'); const groupSelect = config.getOptionalStringArray('group.select'); + const queryMode = config.getOptionalString('queryMode'); + if ( + queryMode !== undefined && + queryMode !== 'basic' && + queryMode !== 'advanced' + ) { + throw new Error(`queryMode must be one of: basic, advanced`); + } + const userGroupMemberFilter = config.getOptionalString( 'userGroupMember.filter', ); @@ -300,6 +309,7 @@ export function readProviderConfig( groupFilter, groupSearch, groupSelect, + queryMode, userGroupMemberFilter, userGroupMemberSearch, };