diff --git a/.changeset/heavy-phones-shave.md b/.changeset/heavy-phones-shave.md new file mode 100644 index 0000000000..4f268d81ac --- /dev/null +++ b/.changeset/heavy-phones-shave.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-ldap': minor +--- + +Add Support for Google LDAP Vendor diff --git a/plugins/catalog-backend-module-ldap/src/ldap/client.ts b/plugins/catalog-backend-module-ldap/src/ldap/client.ts index 48a3eedfb8..61dd05f437 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/client.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/client.ts @@ -25,6 +25,7 @@ import { AEDirVendor, ActiveDirectoryVendor, DefaultLdapVendor, + GoogleLdapVendor, FreeIpaVendor, LdapVendor, } from './vendors'; @@ -236,6 +237,7 @@ export class LdapClient { if (this.vendor) { return this.vendor; } + const clientHost = this.client?.host || ''; this.vendor = this.getRootDSE() .then(root => { if (root && root.raw?.forestFunctionality) { @@ -244,6 +246,8 @@ export class LdapClient { return FreeIpaVendor; } else if (root && 'aeRoot' in root.raw) { return AEDirVendor; + } else if (clientHost === 'ldap.google.com') { + return GoogleLdapVendor; } return DefaultLdapVendor; }) diff --git a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts index 8b84002c20..eac8481c3e 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts @@ -89,6 +89,16 @@ export const AEDirVendor: LdapVendor = { }, }; +export const GoogleLdapVendor: LdapVendor = { + dnAttributeName: 'dn', + uuidAttributeName: 'uid', + decodeStringAttribute: (entry, name) => { + return decode(entry, name, value => { + return value.toString(); + }); + }, +}; + // Decode an attribute to a consumer function decode( entry: SearchEntry,