feat: add optional userExpand parameter for ms graph
Signed-off-by: Jonah Back <jonah@jonahback.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-msgraph': patch
|
||||
---
|
||||
|
||||
Add userExpand option to allow users to expand fields retrieved from the Graph API - for use in custom transformers
|
||||
@@ -52,6 +52,12 @@ export type MicrosoftGraphProviderConfig = {
|
||||
* E.g. "accountEnabled eq true and userType eq 'member'"
|
||||
*/
|
||||
userFilter?: string;
|
||||
/**
|
||||
* The expand argument to apply to users.
|
||||
*
|
||||
* E.g. "manager"
|
||||
*/
|
||||
userExpand?: string[];
|
||||
/**
|
||||
* The filter to apply to extract users by groups memberships.
|
||||
*
|
||||
|
||||
@@ -85,6 +85,7 @@ export async function readMicrosoftGraphUsers(
|
||||
client: MicrosoftGraphClient,
|
||||
options: {
|
||||
userFilter?: string;
|
||||
userExpand?: string[];
|
||||
transformer?: UserTransformer;
|
||||
logger: Logger;
|
||||
},
|
||||
@@ -99,6 +100,7 @@ export async function readMicrosoftGraphUsers(
|
||||
|
||||
for await (const user of client.getUsers({
|
||||
filter: options.userFilter,
|
||||
expand: options.userExpand,
|
||||
})) {
|
||||
// Process all users in parallel, otherwise it can take quite some time
|
||||
promises.push(
|
||||
@@ -500,6 +502,7 @@ export async function readMicrosoftGraphOrg(
|
||||
client: MicrosoftGraphClient,
|
||||
tenantId: string,
|
||||
options: {
|
||||
userExpand?: string[];
|
||||
userFilter?: string;
|
||||
userGroupMemberFilter?: string;
|
||||
groupFilter?: string;
|
||||
@@ -524,6 +527,7 @@ export async function readMicrosoftGraphOrg(
|
||||
} else {
|
||||
const { users: usersWithFilter } = await readMicrosoftGraphUsers(client, {
|
||||
userFilter: options.userFilter,
|
||||
userExpand: options.userExpand,
|
||||
transformer: options.userTransformer,
|
||||
logger: options.logger,
|
||||
});
|
||||
|
||||
+1
@@ -102,6 +102,7 @@ export class MicrosoftGraphOrgReaderProcessor implements CatalogProcessor {
|
||||
client,
|
||||
provider.tenantId,
|
||||
{
|
||||
userExpand: provider.userExpand,
|
||||
userFilter: provider.userFilter,
|
||||
userGroupMemberFilter: provider.userGroupMemberFilter,
|
||||
groupFilter: provider.groupFilter,
|
||||
|
||||
Reference in New Issue
Block a user