made vendor config optional
Signed-off-by: Kashish Mittal <kmittal@redhat.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-ldap': minor
|
||||
---
|
||||
|
||||
Add support for optional configuration of `dnAttributeName` and `uuidAttributeName` in LDAP vendor settings
|
||||
@@ -226,12 +226,47 @@ export class LdapClient {
|
||||
*
|
||||
* @see https://ldapwiki.com/wiki/Determine%20LDAP%20Server%20Vendor
|
||||
*/
|
||||
async getVendor(vendorConfig: VendorConfig): Promise<LdapVendor> {
|
||||
async getVendor(vendorConfig: VendorConfig | undefined): Promise<LdapVendor> {
|
||||
if (this.vendor) {
|
||||
return this.vendor;
|
||||
}
|
||||
this.vendor = this.getRootDSE()
|
||||
.then(root => {
|
||||
if (!vendorConfig) {
|
||||
if (root && root.raw?.forestFunctionality) {
|
||||
// ActiveDirectoryVendor
|
||||
return CreateLdapVendor(
|
||||
{
|
||||
dnAttributeName: 'distinguishedName',
|
||||
uuidAttributeName: 'objectGUID',
|
||||
},
|
||||
true,
|
||||
);
|
||||
} else if (root && root.raw?.ipaDomainLevel) {
|
||||
// FreeIpaVendor
|
||||
return CreateLdapVendor(
|
||||
{
|
||||
dnAttributeName: 'dn',
|
||||
uuidAttributeName: 'ipaUniqueID',
|
||||
},
|
||||
false,
|
||||
);
|
||||
} else if (root && 'aeRoot' in root.raw) {
|
||||
// AEDirVendor
|
||||
return CreateLdapVendor(
|
||||
{ dnAttributeName: 'dn', uuidAttributeName: 'entryUUID' },
|
||||
false,
|
||||
);
|
||||
}
|
||||
// DefaultLdapVendor
|
||||
return CreateLdapVendor(
|
||||
{
|
||||
dnAttributeName: 'entryDN',
|
||||
uuidAttributeName: 'entryUUID',
|
||||
},
|
||||
!!(root && root.raw?.forestFunctionality),
|
||||
);
|
||||
}
|
||||
return CreateLdapVendor(
|
||||
vendorConfig,
|
||||
!!(root && root.raw?.forestFunctionality),
|
||||
|
||||
@@ -78,10 +78,6 @@ describe('readLdapConfig', () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
vendor: {
|
||||
dnAttributeName: 'entryDN',
|
||||
uuidAttributeName: 'entryUUID',
|
||||
},
|
||||
},
|
||||
];
|
||||
expect(actual).toEqual(expected);
|
||||
@@ -155,10 +151,6 @@ describe('readLdapConfig', () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
vendor: {
|
||||
dnAttributeName: 'entryDN',
|
||||
uuidAttributeName: 'entryUUID',
|
||||
},
|
||||
},
|
||||
];
|
||||
expect(actual).toEqual(expected);
|
||||
@@ -299,10 +291,6 @@ describe('readLdapConfig', () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
vendor: {
|
||||
dnAttributeName: 'entryDN',
|
||||
uuidAttributeName: 'entryUUID',
|
||||
},
|
||||
},
|
||||
];
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
@@ -50,7 +50,7 @@ export type LdapProviderConfig = {
|
||||
// Configuration for LDAP vendor-specific attributes. If not specified, the default values will be used:
|
||||
// - `dnAttributeName`: `entryDN`
|
||||
// - `uuidAttributeName`: `entryUUID`
|
||||
vendor: VendorConfig;
|
||||
vendor?: VendorConfig;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -253,10 +253,7 @@ function readVendorConfig(
|
||||
c: Config | undefined,
|
||||
): LdapProviderConfig['vendor'] | undefined {
|
||||
if (!c) {
|
||||
return {
|
||||
dnAttributeName: `entryDN`,
|
||||
uuidAttributeName: `entryUUID`,
|
||||
};
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
dnAttributeName: c.getString('dn'),
|
||||
|
||||
@@ -105,7 +105,7 @@ export async function defaultUserTransformer(
|
||||
export async function readLdapUsers(
|
||||
client: LdapClient,
|
||||
userConfig: UserConfig[],
|
||||
vendorConfig: VendorConfig,
|
||||
vendorConfig: VendorConfig | undefined,
|
||||
opts?: { transformer?: UserTransformer },
|
||||
): Promise<{
|
||||
users: UserEntity[]; // With all relations empty
|
||||
@@ -212,7 +212,7 @@ export async function defaultGroupTransformer(
|
||||
export async function readLdapGroups(
|
||||
client: LdapClient,
|
||||
groupConfig: GroupConfig[],
|
||||
vendorConfig: VendorConfig,
|
||||
vendorConfig: VendorConfig | undefined,
|
||||
opts?: {
|
||||
transformer?: GroupTransformer;
|
||||
},
|
||||
@@ -277,7 +277,7 @@ export async function readLdapOrg(
|
||||
client: LdapClient,
|
||||
userConfig: UserConfig[],
|
||||
groupConfig: GroupConfig[],
|
||||
vendorConfig: VendorConfig,
|
||||
vendorConfig: VendorConfig | undefined,
|
||||
options: {
|
||||
groupTransformer?: GroupTransformer;
|
||||
userTransformer?: UserTransformer;
|
||||
|
||||
Reference in New Issue
Block a user