Skip to content

Commit

Permalink
fix(core): Use lower cased email for SAML email attribute (#6663)
Browse files Browse the repository at this point in the history
lower case saml email attribute
  • Loading branch information
flipswitchingmonkey authored Jul 13, 2023
1 parent 0c47be2 commit eedde24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/cli/src/sso/saml/saml.service.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ export class SamlService {
}> {
const attributes = await this.getAttributesFromLoginResponse(req, binding);
if (attributes.email) {
const lowerCasedEmail = attributes.email.toLowerCase();
const user = await Db.collections.User.findOne({
where: { email: attributes.email },
where: { email: lowerCasedEmail },
relations: ['globalRole', 'authIdentities'],
});
if (user) {
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/sso/saml/samlHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export function generatePassword(): string {
export async function createUserFromSamlAttributes(attributes: SamlUserAttributes): Promise<User> {
const user = new User();
const authIdentity = new AuthIdentity();
user.email = attributes.email;
const lowerCasedEmail = attributes.email?.toLowerCase() ?? '';
user.email = lowerCasedEmail;
user.firstName = attributes.firstName;
user.lastName = attributes.lastName;
user.globalRole = await Container.get(RoleRepository).findGlobalMemberRoleOrFail();
Expand Down

0 comments on commit eedde24

Please sign in to comment.