Skip to content

Commit d381697

Browse files
committed
Make username case-insensitive in authentication provider
1 parent c398ef1 commit d381697

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/authenticationProvider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export class ServerManagerAuthenticationProvider implements AuthenticationProvid
2323
public static label = AUTHENTICATION_PROVIDER_LABEL;
2424
public static secretKeyPrefix = "credentialProvider:";
2525
public static sessionId(serverName: string, userName: string): string {
26-
return `${serverName}/${userName}`;
26+
const canonicalUserName = userName.toLowerCase();
27+
return `${serverName}/${canonicalUserName}`;
2728
}
2829
public static credentialKey(sessionId: string): string {
2930
return `${ServerManagerAuthenticationProvider.secretKeyPrefix}${sessionId}`;
@@ -56,9 +57,9 @@ export class ServerManagerAuthenticationProvider implements AuthenticationProvid
5657
await this._ensureInitialized();
5758
let sessions = this._sessions;
5859

59-
// Filter to return only those that match all supplied scopes, which are positional.
60+
// Filter to return only those that match all supplied scopes, which are positional and case-insensitive.
6061
for (let index = 0; index < scopes.length; index++) {
61-
sessions = sessions.filter((session) => session.scopes[index] === scopes[index]);
62+
sessions = sessions.filter((session) => session.scopes[index] === scopes[index].toLowerCase());
6263
}
6364
return sessions;
6465
}

src/authenticationSession.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export class ServerManagerAuthenticationSession implements AuthenticationSession
1111
public readonly userName: string,
1212
password: string,
1313
) {
14+
const canonicalUserName = userName.toLowerCase();
1415
this.id = ServerManagerAuthenticationProvider.sessionId(serverName, userName);
1516
this.accessToken = password;
16-
this.account = {id: userName, label: `${userName} on ${serverName}`};
17-
this.scopes = [serverName, userName];
17+
this.account = {id: canonicalUserName, label: `${userName} on ${serverName}`};
18+
this.scopes = [serverName, canonicalUserName];
1819
}
1920
}

0 commit comments

Comments
 (0)