Support profile of groups in LdapOrgReaderProcessor
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Support `profile` of groups including `displayName`, `email`, and `picture` in
|
||||
`LdapOrgReaderProcessor`. The source fields for them can be configured in the
|
||||
`ldapOrg` provider.
|
||||
@@ -66,6 +66,7 @@ describe('readLdapConfig', () => {
|
||||
name: 'cn',
|
||||
description: 'description',
|
||||
type: 'groupType',
|
||||
displayName: 'cn',
|
||||
memberOf: 'memberOf',
|
||||
members: 'member',
|
||||
},
|
||||
@@ -114,6 +115,9 @@ describe('readLdapConfig', () => {
|
||||
name: 'v',
|
||||
description: 'd',
|
||||
type: 't',
|
||||
displayName: 'c',
|
||||
email: 'm',
|
||||
picture: 'p',
|
||||
memberOf: 'm',
|
||||
members: 'n',
|
||||
},
|
||||
@@ -161,6 +165,9 @@ describe('readLdapConfig', () => {
|
||||
name: 'v',
|
||||
description: 'd',
|
||||
type: 't',
|
||||
displayName: 'c',
|
||||
email: 'm',
|
||||
picture: 'p',
|
||||
memberOf: 'm',
|
||||
members: 'n',
|
||||
},
|
||||
|
||||
@@ -109,6 +109,15 @@ export type GroupConfig = {
|
||||
// The name of the attribute that shall be used for the value of the
|
||||
// spec.type field of the entity. Defaults to "groupType".
|
||||
type: string;
|
||||
// The name of the attribute that shall be used for the value of the
|
||||
// spec.profile.displayName field of the entity. Defaults to "cn".
|
||||
displayName: string;
|
||||
// The name of the attribute that shall be used for the value of the
|
||||
// spec.profile.email field of the entity.
|
||||
email?: string;
|
||||
// The name of the attribute that shall be used for the value of the
|
||||
// spec.profile.picture field of the entity.
|
||||
picture?: string;
|
||||
// The name of the attribute that shall be used for the values of the
|
||||
// spec.parent field of the entity. Defaults to "memberOf".
|
||||
memberOf: string;
|
||||
@@ -141,6 +150,7 @@ const defaultConfig = {
|
||||
rdn: 'cn',
|
||||
name: 'cn',
|
||||
description: 'description',
|
||||
displayName: 'cn',
|
||||
type: 'groupType',
|
||||
memberOf: 'memberOf',
|
||||
members: 'member',
|
||||
@@ -220,6 +230,9 @@ export function readLdapConfig(config: Config): LdapProviderConfig[] {
|
||||
name: c.getOptionalString('name'),
|
||||
description: c.getOptionalString('description'),
|
||||
type: c.getOptionalString('type'),
|
||||
displayName: c.getOptionalString('displayName'),
|
||||
email: c.getOptionalString('email'),
|
||||
picture: c.getOptionalString('picture'),
|
||||
memberOf: c.getOptionalString('memberOf'),
|
||||
members: c.getOptionalString('members'),
|
||||
};
|
||||
|
||||
@@ -138,6 +138,8 @@ describe('readLdapGroups', () => {
|
||||
cn: ['cn-value'],
|
||||
description: ['description-value'],
|
||||
tt: ['type-value'],
|
||||
mail: ['mail-value'],
|
||||
avatarUrl: ['avatarUrl-value'],
|
||||
memberOf: ['x', 'y', 'z'],
|
||||
member: ['e', 'f', 'g'],
|
||||
entryDN: ['dn-value'],
|
||||
@@ -151,6 +153,9 @@ describe('readLdapGroups', () => {
|
||||
rdn: 'cn',
|
||||
name: 'cn',
|
||||
description: 'description',
|
||||
displayName: 'cn',
|
||||
email: 'mail',
|
||||
picture: 'avatarUrl',
|
||||
type: 'tt',
|
||||
memberOf: 'memberOf',
|
||||
members: 'member',
|
||||
@@ -173,6 +178,11 @@ describe('readLdapGroups', () => {
|
||||
},
|
||||
spec: {
|
||||
type: 'type-value',
|
||||
profile: {
|
||||
displayName: 'cn-value',
|
||||
email: 'mail-value',
|
||||
picture: 'avatarUrl-value',
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -150,6 +150,7 @@ export async function readLdapGroups(
|
||||
},
|
||||
spec: {
|
||||
type: 'unknown',
|
||||
profile: {},
|
||||
children: [],
|
||||
},
|
||||
};
|
||||
@@ -178,6 +179,15 @@ export async function readLdapGroups(
|
||||
mapStringAttr(attributes, map.type, v => {
|
||||
entity.spec.type = v;
|
||||
});
|
||||
mapStringAttr(attributes, map.displayName, v => {
|
||||
entity.spec.profile!.displayName = v;
|
||||
});
|
||||
mapStringAttr(attributes, map.email, v => {
|
||||
entity.spec.profile!.email = v;
|
||||
});
|
||||
mapStringAttr(attributes, map.picture, v => {
|
||||
entity.spec.profile!.picture = v;
|
||||
});
|
||||
|
||||
mapReferencesAttr(attributes, map.memberOf, (myDn, vs) => {
|
||||
ensureItems(groupMemberOf, myDn, vs);
|
||||
|
||||
Reference in New Issue
Block a user