Skip to content

Commit cae30c7

Browse files
authored
regression(federation): LDAP using wrong federation settings and username (#37209)
1 parent 79c2a9b commit cae30c7

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

apps/meteor/server/lib/ldap/Manager.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,12 @@ export class LDAPManager {
197197
},
198198
},
199199
...(homeServer && {
200-
username: `${username}:${homeServer}`,
200+
username: `@${username}:${homeServer}`,
201201
federated: true,
202202
federation: {
203203
version: 1,
204+
mui: `@${username}:${homeServer}`,
205+
origin: homeServer,
204206
},
205207
}),
206208
};
@@ -488,7 +490,7 @@ export class LDAPManager {
488490
}
489491

490492
protected static getFederationHomeServer(ldapUser: ILDAPEntry): string | undefined {
491-
if (!settings.get<boolean>('Federation_Matrix_enabled')) {
493+
if (!settings.get<boolean>('Federation_Service_Enabled')) {
492494
return;
493495
}
494496

@@ -501,25 +503,14 @@ export class LDAPManager {
501503

502504
logger.debug({ msg: 'User has a federation home server', homeServer });
503505

504-
const localServer = settings.get<string>('Federation_Matrix_homeserver_domain');
506+
const localServer = settings.get<string>('Federation_Service_Domain');
505507
if (localServer === homeServer) {
506508
return;
507509
}
508510

509511
return homeServer;
510512
}
511513

512-
protected static getFederatedUsername(ldapUser: ILDAPEntry, requestUsername: string): string {
513-
const username = this.slugifyUsername(ldapUser, requestUsername);
514-
const homeServer = this.getFederationHomeServer(ldapUser);
515-
516-
if (homeServer) {
517-
return `${username}:${homeServer}`;
518-
}
519-
520-
return username;
521-
}
522-
523514
// This method will find existing users by LDAP id or by username.
524515
private static async findExistingUser(ldapUser: ILDAPEntry, slugifiedUsername: string): Promise<IUser | undefined | null> {
525516
const user = await this.findExistingLDAPUser(ldapUser);

0 commit comments

Comments
 (0)