mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix: check configuration id for auth token
This commit is contained in:
@@ -17,6 +17,7 @@ import { AUTH_PROVIDER_LOCAL_ID } from './AUTH_PROVIDER_LOCAL_ID.js';
|
||||
import { AuthProviderService } from './AuthProviderService.js';
|
||||
import type { ELMRole } from './ELMRole.js';
|
||||
import type { IAuthCredentials } from './IAuthCredentials.js';
|
||||
import { isNotNullDefined } from '@dbeaver/js-helpers';
|
||||
|
||||
export type UserLogoutInfo = AuthLogoutQuery['result'];
|
||||
|
||||
@@ -89,7 +90,7 @@ export class UserInfoResource extends CachedDataResource<UserInfo | null, void>
|
||||
return this.data?.userId || ANONYMOUS_USER_ID;
|
||||
}
|
||||
|
||||
hasToken(providerId: string): boolean {
|
||||
hasToken(providerId: string, configurationId?: string): boolean {
|
||||
if (providerId === AUTH_PROVIDER_LOCAL_ID) {
|
||||
return true;
|
||||
}
|
||||
@@ -99,7 +100,9 @@ export class UserInfoResource extends CachedDataResource<UserInfo | null, void>
|
||||
}
|
||||
|
||||
// TODO: will be changed due wrong origin in authTokens
|
||||
return this.data.authTokens.some(token => token.authProvider === providerId);
|
||||
return this.data.authTokens.some(token =>
|
||||
token.authProvider === providerId && isNotNullDefined(configurationId) ? token.authConfiguration === configurationId : true,
|
||||
);
|
||||
}
|
||||
|
||||
async login(provider: string, { credentials, configurationId, linkUser, forceSessionsLogout }: ILoginOptions): Promise<AuthInfo> {
|
||||
|
||||
@@ -247,11 +247,11 @@ export class AuthenticationService extends Bootstrap {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.userInfoResource.hasToken(data.providerId)) {
|
||||
if (!this.userInfoResource.hasToken(data.providerId, data.configurationId)) {
|
||||
await this.auth(false, { providerId: data.providerId, configurationId: data.configurationId });
|
||||
}
|
||||
|
||||
if (this.userInfoResource.hasToken(data.providerId)) {
|
||||
if (this.userInfoResource.hasToken(data.providerId, data.configurationId)) {
|
||||
const provider = contexts.getContext(AuthProviderContext);
|
||||
provider.auth();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user