@open-mercato/enterprise 0.10.1-develop.7827.1.5c631908e4 → 0.10.1-develop.7836.1.0ef0f453c6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/sso/lib/deactivation.js +7 -10
- package/dist/modules/sso/lib/deactivation.js.map +2 -2
- package/dist/modules/sso/services/ssoAuthService.js +8 -3
- package/dist/modules/sso/services/ssoAuthService.js.map +2 -2
- package/package.json +9 -9
- package/src/modules/sso/lib/deactivation.ts +10 -13
- package/src/modules/sso/services/ssoAuthService.ts +9 -4
|
@@ -1,53 +1,50 @@
|
|
|
1
1
|
import { findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
2
2
|
import { Organization } from "@open-mercato/core/modules/directory/data/entities";
|
|
3
3
|
import { SsoConfig, SsoUserDeactivation } from "../data/entities.js";
|
|
4
|
+
const NONMATCHING_ID = "00000000-0000-0000-0000-000000000000";
|
|
4
5
|
async function isSsoUserDeactivated(em, scope) {
|
|
5
|
-
|
|
6
|
+
const organizationId = scope.organizationId ?? NONMATCHING_ID;
|
|
6
7
|
const deactivation = await findOneWithDecryption(
|
|
7
8
|
em,
|
|
8
9
|
SsoUserDeactivation,
|
|
9
10
|
{
|
|
10
11
|
userId: scope.userId,
|
|
11
12
|
tenantId: scope.tenantId,
|
|
12
|
-
organizationId
|
|
13
|
+
organizationId,
|
|
13
14
|
reactivatedAt: null,
|
|
14
15
|
...scope.ssoConfigId ? { ssoConfigId: scope.ssoConfigId } : {}
|
|
15
16
|
},
|
|
16
17
|
{},
|
|
17
18
|
{ tenantId: scope.tenantId, organizationId: scope.organizationId }
|
|
18
19
|
);
|
|
19
|
-
if (deactivation) return true;
|
|
20
|
-
if (!scope.tenantId) return false;
|
|
21
20
|
const legacyDeactivation = await findOneWithDecryption(
|
|
22
21
|
em,
|
|
23
22
|
SsoUserDeactivation,
|
|
24
23
|
{
|
|
25
24
|
userId: scope.userId,
|
|
26
25
|
tenantId: null,
|
|
27
|
-
organizationId
|
|
26
|
+
organizationId,
|
|
28
27
|
reactivatedAt: null,
|
|
29
28
|
...scope.ssoConfigId ? { ssoConfigId: scope.ssoConfigId } : {}
|
|
30
29
|
},
|
|
31
30
|
{},
|
|
32
31
|
{ tenantId: scope.tenantId, organizationId: scope.organizationId }
|
|
33
32
|
);
|
|
34
|
-
if (!legacyDeactivation) return false;
|
|
35
33
|
const organization = await findOneWithDecryption(
|
|
36
34
|
em,
|
|
37
35
|
Organization,
|
|
38
|
-
{ id:
|
|
36
|
+
{ id: organizationId, tenant: scope.tenantId ?? NONMATCHING_ID },
|
|
39
37
|
{ fields: ["id"] },
|
|
40
38
|
{ tenantId: scope.tenantId, organizationId: scope.organizationId }
|
|
41
39
|
);
|
|
42
|
-
if (!organization) return false;
|
|
43
40
|
const config = await findOneWithDecryption(
|
|
44
41
|
em,
|
|
45
42
|
SsoConfig,
|
|
46
|
-
{ id: legacyDeactivation
|
|
43
|
+
{ id: legacyDeactivation?.ssoConfigId ?? NONMATCHING_ID, organizationId, tenantId: null },
|
|
47
44
|
{ fields: ["id"] },
|
|
48
45
|
{ tenantId: null, organizationId: scope.organizationId }
|
|
49
46
|
);
|
|
50
|
-
return
|
|
47
|
+
return Boolean(scope.organizationId && (deactivation || scope.tenantId && legacyDeactivation && organization && config));
|
|
51
48
|
}
|
|
52
49
|
export {
|
|
53
50
|
isSsoUserDeactivated
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/sso/lib/deactivation.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { Organization } from '@open-mercato/core/modules/directory/data/entities'\nimport { SsoConfig, SsoUserDeactivation } from '../data/entities'\n\ntype DeactivationScope = {\n userId: string\n tenantId: string | null\n organizationId: string | null\n ssoConfigId?: string\n}\n\nexport async function isSsoUserDeactivated(em: EntityManager, scope: DeactivationScope): Promise<boolean> {\n
|
|
5
|
-
"mappings": "AACA,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,WAAW,2BAA2B;AAS/C,eAAsB,qBAAqB,IAAmB,OAA4C;AACxG,
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { Organization } from '@open-mercato/core/modules/directory/data/entities'\nimport { SsoConfig, SsoUserDeactivation } from '../data/entities'\n\ntype DeactivationScope = {\n userId: string\n tenantId: string | null\n organizationId: string | null\n ssoConfigId?: string\n}\n\nconst NONMATCHING_ID = '00000000-0000-0000-0000-000000000000'\n\nexport async function isSsoUserDeactivated(em: EntityManager, scope: DeactivationScope): Promise<boolean> {\n const organizationId = scope.organizationId ?? NONMATCHING_ID\n\n const deactivation = await findOneWithDecryption(\n em,\n SsoUserDeactivation,\n {\n userId: scope.userId,\n tenantId: scope.tenantId,\n organizationId,\n reactivatedAt: null,\n ...(scope.ssoConfigId ? { ssoConfigId: scope.ssoConfigId } : {}),\n },\n {},\n { tenantId: scope.tenantId, organizationId: scope.organizationId },\n )\n const legacyDeactivation = await findOneWithDecryption(\n em, SsoUserDeactivation,\n {\n userId: scope.userId,\n tenantId: null,\n organizationId,\n reactivatedAt: null,\n ...(scope.ssoConfigId ? { ssoConfigId: scope.ssoConfigId } : {}),\n },\n {},\n { tenantId: scope.tenantId, organizationId: scope.organizationId },\n )\n const organization = await findOneWithDecryption(\n em, Organization,\n { id: organizationId, tenant: scope.tenantId ?? NONMATCHING_ID },\n { fields: ['id'] },\n { tenantId: scope.tenantId, organizationId: scope.organizationId },\n )\n const config = await findOneWithDecryption(\n em, SsoConfig,\n { id: legacyDeactivation?.ssoConfigId ?? NONMATCHING_ID, organizationId, tenantId: null },\n { fields: ['id'] },\n { tenantId: null, organizationId: scope.organizationId },\n )\n return Boolean(scope.organizationId && (deactivation || (\n scope.tenantId && legacyDeactivation && organization && config\n )))\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,WAAW,2BAA2B;AAS/C,MAAM,iBAAiB;AAEvB,eAAsB,qBAAqB,IAAmB,OAA4C;AACxG,QAAM,iBAAiB,MAAM,kBAAkB;AAE/C,QAAM,eAAe,MAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,MAAM;AAAA,MACd,UAAU,MAAM;AAAA,MAChB;AAAA,MACA,eAAe;AAAA,MACf,GAAI,MAAM,cAAc,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;AAAA,IAChE;AAAA,IACA,CAAC;AAAA,IACD,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe;AAAA,EACnE;AACA,QAAM,qBAAqB,MAAM;AAAA,IAC/B;AAAA,IAAI;AAAA,IACJ;AAAA,MACE,QAAQ,MAAM;AAAA,MACd,UAAU;AAAA,MACV;AAAA,MACA,eAAe;AAAA,MACf,GAAI,MAAM,cAAc,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;AAAA,IAChE;AAAA,IACA,CAAC;AAAA,IACD,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe;AAAA,EACnE;AACA,QAAM,eAAe,MAAM;AAAA,IACzB;AAAA,IAAI;AAAA,IACJ,EAAE,IAAI,gBAAgB,QAAQ,MAAM,YAAY,eAAe;AAAA,IAC/D,EAAE,QAAQ,CAAC,IAAI,EAAE;AAAA,IACjB,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe;AAAA,EACnE;AACA,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IAAI;AAAA,IACJ,EAAE,IAAI,oBAAoB,eAAe,gBAAgB,gBAAgB,UAAU,KAAK;AAAA,IACxF,EAAE,QAAQ,CAAC,IAAI,EAAE;AAAA,IACjB,EAAE,UAAU,MAAM,gBAAgB,MAAM,eAAe;AAAA,EACzD;AACA,SAAO,QAAQ,MAAM,mBAAmB,gBACtC,MAAM,YAAY,sBAAsB,gBAAgB,OACxD;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,6 +4,11 @@ import { AuthSessionRejectedError } from "@open-mercato/core/modules/auth/lib/se
|
|
|
4
4
|
import { lockAuthorizationUserRows } from "@open-mercato/core/modules/auth/lib/authorizationStateLocks";
|
|
5
5
|
import { findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
6
6
|
import { isSsoUserDeactivated } from "../lib/deactivation.js";
|
|
7
|
+
const UNRESOLVED_PASSWORD_SCOPE = {
|
|
8
|
+
userId: "00000000-0000-0000-0000-000000000000",
|
|
9
|
+
tenantId: "00000000-0000-0000-0000-000000000000",
|
|
10
|
+
organizationId: "00000000-0000-0000-0000-000000000000"
|
|
11
|
+
};
|
|
7
12
|
class SsoAuthService extends AuthService {
|
|
8
13
|
constructor(ssoEm) {
|
|
9
14
|
super(ssoEm);
|
|
@@ -11,12 +16,12 @@ class SsoAuthService extends AuthService {
|
|
|
11
16
|
}
|
|
12
17
|
async verifyPassword(user, password) {
|
|
13
18
|
const verified = await super.verifyPassword(user, password);
|
|
14
|
-
|
|
15
|
-
return !await isSsoUserDeactivated(this.ssoEm, {
|
|
19
|
+
const deactivated = await isSsoUserDeactivated(this.ssoEm, user ? {
|
|
16
20
|
userId: user.id,
|
|
17
21
|
tenantId: user.tenantId ?? null,
|
|
18
22
|
organizationId: user.organizationId ?? null
|
|
19
|
-
});
|
|
23
|
+
} : UNRESOLVED_PASSWORD_SCOPE);
|
|
24
|
+
return verified && !deactivated;
|
|
20
25
|
}
|
|
21
26
|
async createSession(user, expiresAt, scope) {
|
|
22
27
|
return this.ssoEm.transactional(async (txEm) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/sso/services/ssoAuthService.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { User, type Session } from '@open-mercato/core/modules/auth/data/entities'\nimport { AuthService } from '@open-mercato/core/modules/auth/services/authService'\nimport { AuthSessionRejectedError } from '@open-mercato/core/modules/auth/lib/sessionEligibility'\nimport { lockAuthorizationUserRows } from '@open-mercato/core/modules/auth/lib/authorizationStateLocks'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { isSsoUserDeactivated } from '../lib/deactivation'\n\ntype SsoSessionScope = {\n tenantId: string | null\n organizationId: string\n ssoConfigId: string\n}\n\nexport class SsoAuthService extends AuthService {\n constructor(private ssoEm: EntityManager) {\n super(ssoEm)\n }\n\n override async verifyPassword(user: User | null, password: string): Promise<boolean> {\n const verified = await super.verifyPassword(user, password)\n
|
|
5
|
-
"mappings": "AACA,SAAS,YAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { User, type Session } from '@open-mercato/core/modules/auth/data/entities'\nimport { AuthService } from '@open-mercato/core/modules/auth/services/authService'\nimport { AuthSessionRejectedError } from '@open-mercato/core/modules/auth/lib/sessionEligibility'\nimport { lockAuthorizationUserRows } from '@open-mercato/core/modules/auth/lib/authorizationStateLocks'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { isSsoUserDeactivated } from '../lib/deactivation'\n\ntype SsoSessionScope = {\n tenantId: string | null\n organizationId: string\n ssoConfigId: string\n}\n\nconst UNRESOLVED_PASSWORD_SCOPE = {\n userId: '00000000-0000-0000-0000-000000000000',\n tenantId: '00000000-0000-0000-0000-000000000000',\n organizationId: '00000000-0000-0000-0000-000000000000',\n}\n\nexport class SsoAuthService extends AuthService {\n constructor(private ssoEm: EntityManager) {\n super(ssoEm)\n }\n\n override async verifyPassword(user: User | null, password: string): Promise<boolean> {\n const verified = await super.verifyPassword(user, password)\n const deactivated = await isSsoUserDeactivated(this.ssoEm, user ? {\n userId: user.id,\n tenantId: user.tenantId ?? null,\n organizationId: user.organizationId ?? null,\n } : UNRESOLVED_PASSWORD_SCOPE)\n return verified && !deactivated\n }\n\n override async createSession(\n user: User,\n expiresAt: Date,\n scope?: SsoSessionScope,\n ): Promise<{ session: Session; token: string }> {\n return this.ssoEm.transactional(async (txEm) => {\n await lockAuthorizationUserRows(txEm, [user.id])\n const currentUser = await findOneWithDecryption(\n txEm, User,\n { id: user.id, tenantId: user.tenantId ?? null, organizationId: user.organizationId ?? null, deletedAt: null },\n { refresh: true },\n { tenantId: user.tenantId ?? null, organizationId: user.organizationId ?? null },\n )\n if (!currentUser || await isSsoUserDeactivated(txEm, {\n userId: user.id,\n tenantId: scope ? scope.tenantId : currentUser.tenantId ?? null,\n organizationId: scope ? scope.organizationId : currentUser.organizationId ?? null,\n ...(scope ? { ssoConfigId: scope.ssoConfigId } : {}),\n })) {\n throw new AuthSessionRejectedError()\n }\n return this.createSessionWithEntityManager(txEm, currentUser, expiresAt)\n })\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,YAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AAQrC,MAAM,4BAA4B;AAAA,EAChC,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,gBAAgB;AAClB;AAEO,MAAM,uBAAuB,YAAY;AAAA,EAC9C,YAAoB,OAAsB;AACxC,UAAM,KAAK;AADO;AAAA,EAEpB;AAAA,EAEA,MAAe,eAAe,MAAmB,UAAoC;AACnF,UAAM,WAAW,MAAM,MAAM,eAAe,MAAM,QAAQ;AAC1D,UAAM,cAAc,MAAM,qBAAqB,KAAK,OAAO,OAAO;AAAA,MAChE,QAAQ,KAAK;AAAA,MACb,UAAU,KAAK,YAAY;AAAA,MAC3B,gBAAgB,KAAK,kBAAkB;AAAA,IACzC,IAAI,yBAAyB;AAC7B,WAAO,YAAY,CAAC;AAAA,EACtB;AAAA,EAEA,MAAe,cACb,MACA,WACA,OAC8C;AAC9C,WAAO,KAAK,MAAM,cAAc,OAAO,SAAS;AAC9C,YAAM,0BAA0B,MAAM,CAAC,KAAK,EAAE,CAAC;AAC/C,YAAM,cAAc,MAAM;AAAA,QACxB;AAAA,QAAM;AAAA,QACN,EAAE,IAAI,KAAK,IAAI,UAAU,KAAK,YAAY,MAAM,gBAAgB,KAAK,kBAAkB,MAAM,WAAW,KAAK;AAAA,QAC7G,EAAE,SAAS,KAAK;AAAA,QAChB,EAAE,UAAU,KAAK,YAAY,MAAM,gBAAgB,KAAK,kBAAkB,KAAK;AAAA,MACjF;AACA,UAAI,CAAC,eAAe,MAAM,qBAAqB,MAAM;AAAA,QACnD,QAAQ,KAAK;AAAA,QACb,UAAU,QAAQ,MAAM,WAAW,YAAY,YAAY;AAAA,QAC3D,gBAAgB,QAAQ,MAAM,iBAAiB,YAAY,kBAAkB;AAAA,QAC7E,GAAI,QAAQ,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;AAAA,MACpD,CAAC,GAAG;AACF,cAAM,IAAI,yBAAyB;AAAA,MACrC;AACA,aAAO,KAAK,+BAA+B,MAAM,aAAa,SAAS;AAAA,IACzE,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/enterprise",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
"@dnd-kit/core": "^6.3.1",
|
|
71
71
|
"@dnd-kit/sortable": "^10.0.0",
|
|
72
72
|
"@dnd-kit/utilities": "^3.2.2",
|
|
73
|
-
"@open-mercato/ai-assistant": "0.10.1-develop.
|
|
74
|
-
"@open-mercato/core": "0.10.1-develop.
|
|
75
|
-
"@open-mercato/queue": "0.10.1-develop.
|
|
76
|
-
"@open-mercato/scheduler": "0.10.1-develop.
|
|
77
|
-
"@open-mercato/ui": "0.10.1-develop.
|
|
78
|
-
"@open-mercato/web-research": "0.10.1-develop.
|
|
73
|
+
"@open-mercato/ai-assistant": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
74
|
+
"@open-mercato/core": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
75
|
+
"@open-mercato/queue": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
76
|
+
"@open-mercato/scheduler": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
77
|
+
"@open-mercato/ui": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
78
|
+
"@open-mercato/web-research": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
79
79
|
"@simplewebauthn/browser": "^13.3.0",
|
|
80
80
|
"@simplewebauthn/server": "^13.3.2",
|
|
81
81
|
"@simplewebauthn/types": "^12.0.0",
|
|
@@ -87,13 +87,13 @@
|
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"@mikro-orm/core": "^7.0.14",
|
|
90
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
90
|
+
"@open-mercato/shared": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
91
91
|
"react": "^19.0.0",
|
|
92
92
|
"react-dom": "^19.0.0",
|
|
93
93
|
"zod": ">=3.23.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
96
|
+
"@open-mercato/shared": "0.10.1-develop.7836.1.0ef0f453c6",
|
|
97
97
|
"@types/jest": "^30.0.0",
|
|
98
98
|
"@types/react": "^19.2.18",
|
|
99
99
|
"@types/react-dom": "^19.2.5",
|
|
@@ -10,8 +10,10 @@ type DeactivationScope = {
|
|
|
10
10
|
ssoConfigId?: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const NONMATCHING_ID = '00000000-0000-0000-0000-000000000000'
|
|
14
|
+
|
|
13
15
|
export async function isSsoUserDeactivated(em: EntityManager, scope: DeactivationScope): Promise<boolean> {
|
|
14
|
-
|
|
16
|
+
const organizationId = scope.organizationId ?? NONMATCHING_ID
|
|
15
17
|
|
|
16
18
|
const deactivation = await findOneWithDecryption(
|
|
17
19
|
em,
|
|
@@ -19,43 +21,38 @@ export async function isSsoUserDeactivated(em: EntityManager, scope: Deactivatio
|
|
|
19
21
|
{
|
|
20
22
|
userId: scope.userId,
|
|
21
23
|
tenantId: scope.tenantId,
|
|
22
|
-
organizationId
|
|
24
|
+
organizationId,
|
|
23
25
|
reactivatedAt: null,
|
|
24
26
|
...(scope.ssoConfigId ? { ssoConfigId: scope.ssoConfigId } : {}),
|
|
25
27
|
},
|
|
26
28
|
{},
|
|
27
29
|
{ tenantId: scope.tenantId, organizationId: scope.organizationId },
|
|
28
30
|
)
|
|
29
|
-
if (deactivation) return true
|
|
30
|
-
if (!scope.tenantId) return false
|
|
31
|
-
|
|
32
31
|
const legacyDeactivation = await findOneWithDecryption(
|
|
33
32
|
em, SsoUserDeactivation,
|
|
34
33
|
{
|
|
35
34
|
userId: scope.userId,
|
|
36
35
|
tenantId: null,
|
|
37
|
-
organizationId
|
|
36
|
+
organizationId,
|
|
38
37
|
reactivatedAt: null,
|
|
39
38
|
...(scope.ssoConfigId ? { ssoConfigId: scope.ssoConfigId } : {}),
|
|
40
39
|
},
|
|
41
40
|
{},
|
|
42
41
|
{ tenantId: scope.tenantId, organizationId: scope.organizationId },
|
|
43
42
|
)
|
|
44
|
-
if (!legacyDeactivation) return false
|
|
45
|
-
|
|
46
43
|
const organization = await findOneWithDecryption(
|
|
47
44
|
em, Organization,
|
|
48
|
-
{ id:
|
|
45
|
+
{ id: organizationId, tenant: scope.tenantId ?? NONMATCHING_ID },
|
|
49
46
|
{ fields: ['id'] },
|
|
50
47
|
{ tenantId: scope.tenantId, organizationId: scope.organizationId },
|
|
51
48
|
)
|
|
52
|
-
if (!organization) return false
|
|
53
|
-
|
|
54
49
|
const config = await findOneWithDecryption(
|
|
55
50
|
em, SsoConfig,
|
|
56
|
-
{ id: legacyDeactivation
|
|
51
|
+
{ id: legacyDeactivation?.ssoConfigId ?? NONMATCHING_ID, organizationId, tenantId: null },
|
|
57
52
|
{ fields: ['id'] },
|
|
58
53
|
{ tenantId: null, organizationId: scope.organizationId },
|
|
59
54
|
)
|
|
60
|
-
return
|
|
55
|
+
return Boolean(scope.organizationId && (deactivation || (
|
|
56
|
+
scope.tenantId && legacyDeactivation && organization && config
|
|
57
|
+
)))
|
|
61
58
|
}
|
|
@@ -12,6 +12,12 @@ type SsoSessionScope = {
|
|
|
12
12
|
ssoConfigId: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const UNRESOLVED_PASSWORD_SCOPE = {
|
|
16
|
+
userId: '00000000-0000-0000-0000-000000000000',
|
|
17
|
+
tenantId: '00000000-0000-0000-0000-000000000000',
|
|
18
|
+
organizationId: '00000000-0000-0000-0000-000000000000',
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
export class SsoAuthService extends AuthService {
|
|
16
22
|
constructor(private ssoEm: EntityManager) {
|
|
17
23
|
super(ssoEm)
|
|
@@ -19,13 +25,12 @@ export class SsoAuthService extends AuthService {
|
|
|
19
25
|
|
|
20
26
|
override async verifyPassword(user: User | null, password: string): Promise<boolean> {
|
|
21
27
|
const verified = await super.verifyPassword(user, password)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return !await isSsoUserDeactivated(this.ssoEm, {
|
|
28
|
+
const deactivated = await isSsoUserDeactivated(this.ssoEm, user ? {
|
|
25
29
|
userId: user.id,
|
|
26
30
|
tenantId: user.tenantId ?? null,
|
|
27
31
|
organizationId: user.organizationId ?? null,
|
|
28
|
-
})
|
|
32
|
+
} : UNRESOLVED_PASSWORD_SCOPE)
|
|
33
|
+
return verified && !deactivated
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
override async createSession(
|