@webiny/api-core 6.5.2-beta.1 → 6.5.2-beta.3
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/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +2 -0
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +2 -2
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js +7 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKey/abstractions.d.ts +3 -3
- package/features/security/apiKeys/GetApiKey/abstractions.js.map +1 -1
- package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.d.ts +2 -2
- package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js +4 -1
- package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js.map +1 -1
- package/features/security/apiKeys/ListApiKeys/abstractions.d.ts +3 -4
- package/features/security/apiKeys/ListApiKeys/abstractions.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +2 -0
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/shared/hideToken.d.ts +8 -0
- package/features/security/apiKeys/shared/hideToken.js +11 -0
- package/features/security/apiKeys/shared/hideToken.js.map +1 -0
- package/features/security/apiKeys/shared/types.d.ts +7 -0
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +6 -0
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/DeleteRole/DeleteRoleUseCase.js +2 -1
- package/features/security/roles/DeleteRole/DeleteRoleUseCase.js.map +1 -1
- package/features/security/roles/DeleteRole/abstractions.d.ts +2 -1
- package/features/security/roles/DeleteRole/abstractions.js.map +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +10 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/abstractions.d.ts +2 -1
- package/features/security/roles/UpdateRole/abstractions.js.map +1 -1
- package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.d.ts +5 -2
- package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.js +16 -3
- package/features/security/roles/shared/decorators/RolesRepositoryCachingDecorator.js.map +1 -1
- package/features/security/roles/shared/errors.d.ts +8 -0
- package/features/security/roles/shared/errors.js +15 -1
- package/features/security/roles/shared/errors.js.map +1 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +17 -2
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -2
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/utils/canAssignRolesAndTeams.d.ts +16 -0
- package/features/security/utils/canAssignRolesAndTeams.js +31 -0
- package/features/security/utils/canAssignRolesAndTeams.js.map +1 -0
- package/features/security/utils/canGrantPermissions.d.ts +53 -0
- package/features/security/utils/canGrantPermissions.js +122 -0
- package/features/security/utils/canGrantPermissions.js.map +1 -0
- package/features/security/utils/verifyJwtUsingJwk.d.ts +16 -1
- package/features/security/utils/verifyJwtUsingJwk.js +22 -4
- package/features/security/utils/verifyJwtUsingJwk.js.map +1 -1
- package/features/system/InstallSystem/InstallSystemUseCase.d.ts +1 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/task/TaskService/abstractions.js.map +1 -1
- package/features/tenancy/CreateTenant/CreateTenantRepository.js +1 -0
- package/features/tenancy/CreateTenant/CreateTenantRepository.js.map +1 -1
- package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +5 -3
- package/features/tenancy/CreateTenant/CreateTenantUseCase.js +10 -3
- package/features/tenancy/CreateTenant/CreateTenantUseCase.js.map +1 -1
- package/features/tenancy/CreateTenant/abstractions.d.ts +2 -1
- package/features/tenancy/CreateTenant/abstractions.js.map +1 -1
- package/features/tenancy/CreateTenant/decorators/CreateTenantWithWcpIncrement.d.ts +1 -1
- package/features/tenancy/CreateTenant/errors.d.ts +6 -0
- package/features/tenancy/CreateTenant/errors.js +11 -1
- package/features/tenancy/CreateTenant/errors.js.map +1 -1
- package/features/tenancy/DeleteTenant/decorators/DeleteTenantWithWcpDecrement.js +1 -0
- package/features/tenancy/DeleteTenant/decorators/DeleteTenantWithWcpDecrement.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +2 -0
- package/features/tenancy/TenantContext/TenantContext.js +18 -21
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/tenancy/TenantContext/abstractions.d.ts +5 -0
- package/features/tenancy/TenantContext/abstractions.js.map +1 -1
- package/features/users/AdminUsersFeature.js +2 -0
- package/features/users/AdminUsersFeature.js.map +1 -1
- package/features/users/CreateUser/CreateUserUseCase.d.ts +5 -1
- package/features/users/CreateUser/CreateUserUseCase.js +18 -2
- package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
- package/features/users/DeleteUser/DeleteUserUseCase.d.ts +5 -1
- package/features/users/DeleteUser/DeleteUserUseCase.js +18 -2
- package/features/users/DeleteUser/DeleteUserUseCase.js.map +1 -1
- package/features/users/GetCurrentUser/GetCurrentUserUseCase.d.ts +13 -0
- package/features/users/GetCurrentUser/GetCurrentUserUseCase.js +29 -0
- package/features/users/GetCurrentUser/GetCurrentUserUseCase.js.map +1 -0
- package/features/users/GetCurrentUser/abstractions.d.ts +18 -0
- package/features/users/GetCurrentUser/abstractions.js +5 -0
- package/features/users/GetCurrentUser/abstractions.js.map +1 -0
- package/features/users/GetCurrentUser/feature.d.ts +4 -0
- package/features/users/GetCurrentUser/feature.js +11 -0
- package/features/users/GetCurrentUser/feature.js.map +1 -0
- package/features/users/GetCurrentUser/index.d.ts +1 -0
- package/features/users/GetCurrentUser/index.js +1 -0
- package/features/users/UpdateUser/UpdateUserUseCase.d.ts +5 -1
- package/features/users/UpdateUser/UpdateUserUseCase.js +24 -2
- package/features/users/UpdateUser/UpdateUserUseCase.js.map +1 -1
- package/graphql/security/apiKey.gql.js +1 -0
- package/graphql/security/apiKey.gql.js.map +1 -1
- package/graphql/users/user.gql.js +9 -12
- package/graphql/users/user.gql.js.map +1 -1
- package/idp/OidcJwtIdentityProvider.js +4 -1
- package/idp/OidcJwtIdentityProvider.js.map +1 -1
- package/package.json +22 -22
|
@@ -3,14 +3,20 @@ import { IdentityContext } from "../../security/IdentityContext/index.js";
|
|
|
3
3
|
import { EventPublisher } from "../../eventPublisher/index.js";
|
|
4
4
|
import { DeleteUserUseCase } from "./abstractions.js";
|
|
5
5
|
import { AdminUsersRepository } from "../shared/abstractions.js";
|
|
6
|
+
import { RolesRepository } from "../../security/roles/shared/abstractions.js";
|
|
7
|
+
import { TeamsRepository } from "../../security/teams/shared/abstractions.js";
|
|
8
|
+
import { canAssignRolesAndTeams } from "../../security/utils/canAssignRolesAndTeams.js";
|
|
9
|
+
import { CANNOT_GRANT_PERMISSIONS_MESSAGE } from "../../security/utils/canGrantPermissions.js";
|
|
6
10
|
import { NotAuthorizedError } from "../shared/errors.js";
|
|
7
11
|
import { UserAfterDeleteEvent, UserBeforeDeleteEvent } from "./events.js";
|
|
8
12
|
import { CannotDeleteOwnAccountError } from "./errors.js";
|
|
9
13
|
class DeleteUserUseCaseImpl {
|
|
10
|
-
constructor(identityContext, eventPublisher, repository){
|
|
14
|
+
constructor(identityContext, eventPublisher, repository, rolesRepository, teamsRepository){
|
|
11
15
|
this.identityContext = identityContext;
|
|
12
16
|
this.eventPublisher = eventPublisher;
|
|
13
17
|
this.repository = repository;
|
|
18
|
+
this.rolesRepository = rolesRepository;
|
|
19
|
+
this.teamsRepository = teamsRepository;
|
|
14
20
|
}
|
|
15
21
|
async execute(id) {
|
|
16
22
|
const permission = await this.identityContext.getPermission("adminUsers.user");
|
|
@@ -22,6 +28,14 @@ class DeleteUserUseCaseImpl {
|
|
|
22
28
|
const user = getUserResult.value;
|
|
23
29
|
const identity = this.identityContext.getIdentity();
|
|
24
30
|
if (user.id === identity.id) return Result.fail(new CannotDeleteOwnAccountError());
|
|
31
|
+
const canAssign = await canAssignRolesAndTeams({
|
|
32
|
+
identityContext: this.identityContext,
|
|
33
|
+
rolesRepository: this.rolesRepository,
|
|
34
|
+
teamsRepository: this.teamsRepository,
|
|
35
|
+
roles: user.roles ?? [],
|
|
36
|
+
teams: user.teams ?? []
|
|
37
|
+
});
|
|
38
|
+
if (!canAssign) return Result.fail(new NotAuthorizedError(CANNOT_GRANT_PERMISSIONS_MESSAGE));
|
|
25
39
|
await this.eventPublisher.publish(new UserBeforeDeleteEvent({
|
|
26
40
|
user
|
|
27
41
|
}));
|
|
@@ -39,7 +53,9 @@ const DeleteUserUseCase_DeleteUserUseCase = createImplementation({
|
|
|
39
53
|
dependencies: [
|
|
40
54
|
IdentityContext,
|
|
41
55
|
EventPublisher,
|
|
42
|
-
AdminUsersRepository
|
|
56
|
+
AdminUsersRepository,
|
|
57
|
+
RolesRepository,
|
|
58
|
+
TeamsRepository
|
|
43
59
|
]
|
|
44
60
|
});
|
|
45
61
|
export { DeleteUserUseCase_DeleteUserUseCase as DeleteUserUseCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/users/DeleteUser/DeleteUserUseCase.js","sources":["../../../../src/features/users/DeleteUser/DeleteUserUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { DeleteUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { NotAuthorizedError } from \"~/features/users/shared/errors.js\";\nimport { UserBeforeDeleteEvent, UserAfterDeleteEvent } from \"./events.js\";\nimport { CannotDeleteOwnAccountError } from \"./errors.js\";\n\nclass DeleteUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: AdminUsersRepository.Interface\n ) {}\n\n async execute(id: string): Promise<Result<void, UseCaseAbstraction.Error>> {\n // 1. Check permission\n const permission = await this.identityContext.getPermission(\"adminUsers.user\");\n if (!permission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n // 2. Get existing user\n const getUserResult = await this.repository.get({ id });\n if (getUserResult.isFail()) {\n return Result.fail(getUserResult.error);\n }\n\n const user = getUserResult.value;\n\n // 3. Check if trying to delete own account\n const identity = this.identityContext.getIdentity();\n if (user.id === identity.id) {\n return Result.fail(new CannotDeleteOwnAccountError());\n }\n\n // 4. Publish before event\n await this.eventPublisher.publish(new UserBeforeDeleteEvent({ user }));\n\n // 5. Delete user via repository\n const result = await this.repository.delete(user);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n // 6. Publish after event\n await this.eventPublisher.publish(new UserAfterDeleteEvent({ user }));\n\n return Result.ok();\n }\n}\n\nexport const DeleteUserUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: DeleteUserUseCaseImpl,\n dependencies: [IdentityContext
|
|
1
|
+
{"version":3,"file":"features/users/DeleteUser/DeleteUserUseCase.js","sources":["../../../../src/features/users/DeleteUser/DeleteUserUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { DeleteUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { RolesRepository } from \"~/features/security/roles/shared/abstractions.js\";\nimport { TeamsRepository } from \"~/features/security/teams/shared/abstractions.js\";\nimport { canAssignRolesAndTeams } from \"~/features/security/utils/canAssignRolesAndTeams.js\";\nimport { CANNOT_GRANT_PERMISSIONS_MESSAGE } from \"~/features/security/utils/canGrantPermissions.js\";\nimport { NotAuthorizedError } from \"~/features/users/shared/errors.js\";\nimport { UserBeforeDeleteEvent, UserAfterDeleteEvent } from \"./events.js\";\nimport { CannotDeleteOwnAccountError } from \"./errors.js\";\n\nclass DeleteUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: AdminUsersRepository.Interface,\n private rolesRepository: RolesRepository.Interface,\n private teamsRepository: TeamsRepository.Interface\n ) {}\n\n async execute(id: string): Promise<Result<void, UseCaseAbstraction.Error>> {\n // 1. Check permission\n const permission = await this.identityContext.getPermission(\"adminUsers.user\");\n if (!permission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n // 2. Get existing user\n const getUserResult = await this.repository.get({ id });\n if (getUserResult.isFail()) {\n return Result.fail(getUserResult.error);\n }\n\n const user = getUserResult.value;\n\n // 3. Check if trying to delete own account\n const identity = this.identityContext.getIdentity();\n if (user.id === identity.id) {\n return Result.fail(new CannotDeleteOwnAccountError());\n }\n\n /**\n * Security: the caller may only delete a user whose roles and teams they could assign\n * (same rule as updating a user). Otherwise they could remove a user with more access\n * than they have.\n */\n const canAssign = await canAssignRolesAndTeams({\n identityContext: this.identityContext,\n rolesRepository: this.rolesRepository,\n teamsRepository: this.teamsRepository,\n roles: user.roles ?? [],\n teams: user.teams ?? []\n });\n if (!canAssign) {\n return Result.fail(new NotAuthorizedError(CANNOT_GRANT_PERMISSIONS_MESSAGE));\n }\n\n // 4. Publish before event\n await this.eventPublisher.publish(new UserBeforeDeleteEvent({ user }));\n\n // 5. Delete user via repository\n const result = await this.repository.delete(user);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n // 6. Publish after event\n await this.eventPublisher.publish(new UserAfterDeleteEvent({ user }));\n\n return Result.ok();\n }\n}\n\nexport const DeleteUserUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: DeleteUserUseCaseImpl,\n dependencies: [\n IdentityContext,\n EventPublisher,\n AdminUsersRepository,\n RolesRepository,\n TeamsRepository\n ]\n});\n"],"names":["DeleteUserUseCaseImpl","identityContext","eventPublisher","repository","rolesRepository","teamsRepository","id","permission","Result","NotAuthorizedError","getUserResult","user","identity","CannotDeleteOwnAccountError","canAssign","canAssignRolesAndTeams","CANNOT_GRANT_PERMISSIONS_MESSAGE","UserBeforeDeleteEvent","result","UserAfterDeleteEvent","DeleteUserUseCase","createImplementation","UseCaseAbstraction","IdentityContext","EventPublisher","AdminUsersRepository","RolesRepository","TeamsRepository"],"mappings":";;;;;;;;;;;;AAcA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAwC,EACxCC,UAA0C,EAC1CC,eAA0C,EAC1CC,eAA0C,CACpD;aALUJ,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QAAQC,EAAU,EAAmD;QAEvE,MAAMC,aAAa,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC5D,IAAI,CAACA,YACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAI3B,MAAMC,gBAAgB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAEJ;QAAG;QACrD,IAAII,cAAc,MAAM,IACpB,OAAOF,OAAO,IAAI,CAACE,cAAc,KAAK;QAG1C,MAAMC,OAAOD,cAAc,KAAK;QAGhC,MAAME,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAID,KAAK,EAAE,KAAKC,SAAS,EAAE,EACvB,OAAOJ,OAAO,IAAI,CAAC,IAAIK;QAQ3B,MAAMC,YAAY,MAAMC,uBAAuB;YAC3C,iBAAiB,IAAI,CAAC,eAAe;YACrC,iBAAiB,IAAI,CAAC,eAAe;YACrC,iBAAiB,IAAI,CAAC,eAAe;YACrC,OAAOJ,KAAK,KAAK,IAAI,EAAE;YACvB,OAAOA,KAAK,KAAK,IAAI,EAAE;QAC3B;QACA,IAAI,CAACG,WACD,OAAON,OAAO,IAAI,CAAC,IAAIC,mBAAmBO;QAI9C,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIC,sBAAsB;YAAEN;QAAK;QAGnE,MAAMO,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACP;QAC5C,IAAIO,OAAO,MAAM,IACb,OAAOV,OAAO,IAAI,CAACU,OAAO,KAAK;QAInC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIC,qBAAqB;YAAER;QAAK;QAElE,OAAOH,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMY,sCAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBtB;IAChB,cAAc;QACVuB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "../../../features/security/IdentityContext/index.js";
|
|
3
|
+
import { GetCurrentUserUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
4
|
+
import { AdminUsersRepository } from "../../../features/users/shared/abstractions.js";
|
|
5
|
+
import type { AdminUser } from "../../../features/users/shared/types.js";
|
|
6
|
+
declare class GetCurrentUserUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
|
+
private identityContext;
|
|
8
|
+
private repository;
|
|
9
|
+
constructor(identityContext: IdentityContext.Interface, repository: AdminUsersRepository.Interface);
|
|
10
|
+
execute(): Promise<Result<AdminUser, UseCaseAbstraction.Error>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const GetCurrentUserUseCase: import("@webiny/di").Implementation<typeof GetCurrentUserUseCaseImpl>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Result, createImplementation } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "../../security/IdentityContext/index.js";
|
|
3
|
+
import { GetCurrentUserUseCase } from "./abstractions.js";
|
|
4
|
+
import { AdminUsersRepository } from "../shared/abstractions.js";
|
|
5
|
+
import { NotAuthorizedError } from "../shared/errors.js";
|
|
6
|
+
class GetCurrentUserUseCaseImpl {
|
|
7
|
+
constructor(identityContext, repository){
|
|
8
|
+
this.identityContext = identityContext;
|
|
9
|
+
this.repository = repository;
|
|
10
|
+
}
|
|
11
|
+
async execute() {
|
|
12
|
+
const identity = this.identityContext.getIdentity();
|
|
13
|
+
if (identity.isAnonymous() || !identity.isAdmin()) return Result.fail(new NotAuthorizedError());
|
|
14
|
+
return this.repository.get({
|
|
15
|
+
id: identity.id
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const GetCurrentUserUseCase_GetCurrentUserUseCase = createImplementation({
|
|
20
|
+
abstraction: GetCurrentUserUseCase,
|
|
21
|
+
implementation: GetCurrentUserUseCaseImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
IdentityContext,
|
|
24
|
+
AdminUsersRepository
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
export { GetCurrentUserUseCase_GetCurrentUserUseCase as GetCurrentUserUseCase };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=GetCurrentUserUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/GetCurrentUser/GetCurrentUserUseCase.js","sources":["../../../../src/features/users/GetCurrentUser/GetCurrentUserUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { GetCurrentUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { NotAuthorizedError } from \"~/features/users/shared/errors.js\";\nimport type { AdminUser } from \"~/features/users/shared/types.js\";\n\nclass GetCurrentUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private repository: AdminUsersRepository.Interface\n ) {}\n\n async execute(): Promise<Result<AdminUser, UseCaseAbstraction.Error>> {\n const identity = this.identityContext.getIdentity();\n if (identity.isAnonymous() || !identity.isAdmin()) {\n return Result.fail(new NotAuthorizedError());\n }\n\n /**\n * An admin may always load their own user record. The `adminUsers.user` permission,\n * which allows loading any user, is not required here.\n */\n return this.repository.get({ id: identity.id });\n }\n}\n\nexport const GetCurrentUserUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: GetCurrentUserUseCaseImpl,\n dependencies: [IdentityContext, AdminUsersRepository]\n});\n"],"names":["GetCurrentUserUseCaseImpl","identityContext","repository","identity","Result","NotAuthorizedError","GetCurrentUserUseCase","createImplementation","UseCaseAbstraction","IdentityContext","AdminUsersRepository"],"mappings":";;;;;AAQA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,UAA0C,CACpD;aAFUD,eAAe,GAAfA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,UAAgE;QAClE,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAIA,SAAS,WAAW,MAAM,CAACA,SAAS,OAAO,IAC3C,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAO3B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,IAAIF,SAAS,EAAE;QAAC;IACjD;AACJ;AAEO,MAAMG,8CAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgBR;IAChB,cAAc;QAACS;QAAiBC;KAAqB;AACzD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { AdminUser } from "../../../features/users/shared/types.js";
|
|
3
|
+
import { AdminUsersRepository } from "../../../features/users/shared/abstractions.js";
|
|
4
|
+
import { NotAuthorizedError } from "../../../features/users/shared/errors.js";
|
|
5
|
+
export interface IGetCurrentUserErrors {
|
|
6
|
+
notAuthorized: NotAuthorizedError;
|
|
7
|
+
}
|
|
8
|
+
type GetCurrentUserError = IGetCurrentUserErrors[keyof IGetCurrentUserErrors] | AdminUsersRepository.Error;
|
|
9
|
+
export interface IGetCurrentUser {
|
|
10
|
+
execute(): Promise<Result<AdminUser, GetCurrentUserError>>;
|
|
11
|
+
}
|
|
12
|
+
/** Retrieve the admin user of the current identity. */
|
|
13
|
+
export declare const GetCurrentUserUseCase: import("@webiny/di").Abstraction<IGetCurrentUser>;
|
|
14
|
+
export declare namespace GetCurrentUserUseCase {
|
|
15
|
+
type Interface = IGetCurrentUser;
|
|
16
|
+
type Error = GetCurrentUserError;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/GetCurrentUser/abstractions.js","sources":["../../../../src/features/users/GetCurrentUser/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { AdminUser } from \"~/features/users/shared/types.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { NotAuthorizedError } from \"~/features/users/shared/errors.js\";\n\n// Use case specific errors\nexport interface IGetCurrentUserErrors {\n notAuthorized: NotAuthorizedError;\n}\n\n// Combined error type (use case errors + repository errors)\ntype GetCurrentUserError =\n | IGetCurrentUserErrors[keyof IGetCurrentUserErrors]\n | AdminUsersRepository.Error;\n\n// Use case interface\nexport interface IGetCurrentUser {\n execute(): Promise<Result<AdminUser, GetCurrentUserError>>;\n}\n\n/** Retrieve the admin user of the current identity. */\nexport const GetCurrentUserUseCase = createAbstraction<IGetCurrentUser>(\"GetCurrentUserUseCase\");\n\n// Namespace exports\nexport namespace GetCurrentUserUseCase {\n export type Interface = IGetCurrentUser;\n export type Error = GetCurrentUserError;\n}\n"],"names":["GetCurrentUserUseCase","createAbstraction"],"mappings":";AAsBO,MAAMA,wBAAwBC,kBAAmC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { GetCurrentUserUseCase } from "./GetCurrentUserUseCase.js";
|
|
3
|
+
const GetCurrentUserFeature = createFeature({
|
|
4
|
+
name: "GetCurrentUser",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(GetCurrentUserUseCase);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { GetCurrentUserFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/GetCurrentUser/feature.js","sources":["../../../../src/features/users/GetCurrentUser/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetCurrentUserUseCase } from \"./GetCurrentUserUseCase.js\";\n\nexport const GetCurrentUserFeature = createFeature({\n name: \"GetCurrentUser\",\n register(container) {\n container.register(GetCurrentUserUseCase);\n }\n});\n"],"names":["GetCurrentUserFeature","createFeature","container","GetCurrentUserUseCase"],"mappings":";;AAGO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -3,13 +3,17 @@ import { IdentityContext } from "../../../features/security/IdentityContext/inde
|
|
|
3
3
|
import { EventPublisher } from "../../../features/eventPublisher/index.js";
|
|
4
4
|
import { UpdateUserUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
5
5
|
import { AdminUsersRepository } from "../../../features/users/shared/abstractions.js";
|
|
6
|
+
import { RolesRepository } from "../../../features/security/roles/shared/abstractions.js";
|
|
7
|
+
import { TeamsRepository } from "../../../features/security/teams/shared/abstractions.js";
|
|
6
8
|
import type { AdminUser } from "../../../features/users/shared/types.js";
|
|
7
9
|
import type { UpdateUserInput } from "../../../features/users/shared/types.js";
|
|
8
10
|
declare class UpdateUserUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
9
11
|
private identityContext;
|
|
10
12
|
private eventPublisher;
|
|
11
13
|
private repository;
|
|
12
|
-
|
|
14
|
+
private rolesRepository;
|
|
15
|
+
private teamsRepository;
|
|
16
|
+
constructor(identityContext: IdentityContext.Interface, eventPublisher: EventPublisher.Interface, repository: AdminUsersRepository.Interface, rolesRepository: RolesRepository.Interface, teamsRepository: TeamsRepository.Interface);
|
|
13
17
|
execute(id: string, input: UpdateUserInput): Promise<Result<AdminUser, UseCaseAbstraction.Error>>;
|
|
14
18
|
}
|
|
15
19
|
export declare const UpdateUserUseCase: import("@webiny/di").Implementation<typeof UpdateUserUseCaseImpl>;
|
|
@@ -3,14 +3,20 @@ import { IdentityContext } from "../../security/IdentityContext/index.js";
|
|
|
3
3
|
import { EventPublisher } from "../../eventPublisher/index.js";
|
|
4
4
|
import { UpdateUserUseCase } from "./abstractions.js";
|
|
5
5
|
import { AdminUsersRepository } from "../shared/abstractions.js";
|
|
6
|
+
import { RolesRepository } from "../../security/roles/shared/abstractions.js";
|
|
7
|
+
import { TeamsRepository } from "../../security/teams/shared/abstractions.js";
|
|
8
|
+
import { canAssignRolesAndTeams } from "../../security/utils/canAssignRolesAndTeams.js";
|
|
9
|
+
import { CANNOT_GRANT_PERMISSIONS_MESSAGE } from "../../security/utils/canGrantPermissions.js";
|
|
6
10
|
import { updateUserValidation } from "./schema.js";
|
|
7
11
|
import { EmailTakenError, NotAuthorizedError, UserValidationError } from "../shared/errors.js";
|
|
8
12
|
import { UserAfterUpdateEvent, UserBeforeUpdateEvent } from "./events.js";
|
|
9
13
|
class UpdateUserUseCaseImpl {
|
|
10
|
-
constructor(identityContext, eventPublisher, repository){
|
|
14
|
+
constructor(identityContext, eventPublisher, repository, rolesRepository, teamsRepository){
|
|
11
15
|
this.identityContext = identityContext;
|
|
12
16
|
this.eventPublisher = eventPublisher;
|
|
13
17
|
this.repository = repository;
|
|
18
|
+
this.rolesRepository = rolesRepository;
|
|
19
|
+
this.teamsRepository = teamsRepository;
|
|
14
20
|
}
|
|
15
21
|
async execute(id, input) {
|
|
16
22
|
const permission = await this.identityContext.getPermission("adminUsers.user");
|
|
@@ -30,6 +36,20 @@ class UpdateUserUseCaseImpl {
|
|
|
30
36
|
});
|
|
31
37
|
if (getUserResult.isFail()) return Result.fail(getUserResult.error);
|
|
32
38
|
const originalUser = getUserResult.value;
|
|
39
|
+
const canAssign = await canAssignRolesAndTeams({
|
|
40
|
+
identityContext: this.identityContext,
|
|
41
|
+
rolesRepository: this.rolesRepository,
|
|
42
|
+
teamsRepository: this.teamsRepository,
|
|
43
|
+
roles: [
|
|
44
|
+
...originalUser.roles ?? [],
|
|
45
|
+
...validation.data.roles ?? []
|
|
46
|
+
],
|
|
47
|
+
teams: [
|
|
48
|
+
...originalUser.teams ?? [],
|
|
49
|
+
...validation.data.teams ?? []
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
if (!canAssign) return Result.fail(new NotAuthorizedError(CANNOT_GRANT_PERMISSIONS_MESSAGE));
|
|
33
53
|
const updateData = structuredClone(validation.data);
|
|
34
54
|
await this.eventPublisher.publish(new UserBeforeUpdateEvent({
|
|
35
55
|
user: originalUser,
|
|
@@ -56,7 +76,9 @@ const UpdateUserUseCase_UpdateUserUseCase = createImplementation({
|
|
|
56
76
|
dependencies: [
|
|
57
77
|
IdentityContext,
|
|
58
78
|
EventPublisher,
|
|
59
|
-
AdminUsersRepository
|
|
79
|
+
AdminUsersRepository,
|
|
80
|
+
RolesRepository,
|
|
81
|
+
TeamsRepository
|
|
60
82
|
]
|
|
61
83
|
});
|
|
62
84
|
export { UpdateUserUseCase_UpdateUserUseCase as UpdateUserUseCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/users/UpdateUser/UpdateUserUseCase.js","sources":["../../../../src/features/users/UpdateUser/UpdateUserUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { UpdateUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { updateUserValidation } from \"./schema.js\";\nimport {\n NotAuthorizedError,\n EmailTakenError,\n UserValidationError\n} from \"~/features/users/shared/errors.js\";\nimport { UserBeforeUpdateEvent, UserAfterUpdateEvent } from \"./events.js\";\nimport type { AdminUser } from \"~/features/users/shared/types.js\";\nimport type { UpdateUserInput } from \"~/features/users/shared/types.js\";\n\nclass UpdateUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: AdminUsersRepository.Interface\n ) {}\n\n async execute(\n id: string,\n input: UpdateUserInput\n ): Promise<Result<AdminUser, UseCaseAbstraction.Error>> {\n // 1. Check permission\n const permission = await this.identityContext.getPermission(\"adminUsers.user\");\n if (!permission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n // 2. Validate input\n const validation = updateUserValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new UserValidationError(validation.error.issues[0].message));\n }\n\n // If the input contains email, check if it is free to use.\n if (input.email) {\n const existingUserResult = await this.repository.get({ email: input.email });\n if (existingUserResult.isOk()) {\n if (existingUserResult.value.id !== id) {\n return Result.fail(new EmailTakenError(input.email));\n }\n }\n }\n // 3. Get existing user\n const getUserResult = await this.repository.get({ id });\n if (getUserResult.isFail()) {\n return Result.fail(getUserResult.error);\n }\n\n const originalUser = getUserResult.value;\n\n // 4. Clone update data for event modification\n const updateData = structuredClone(validation.data);\n\n // 5. Publish before event\n await this.eventPublisher.publish(\n new UserBeforeUpdateEvent({ user: originalUser, updateData, input: validation.data })\n );\n\n // 6. Merge updates with existing user\n const updatedUser: AdminUser = {\n ...originalUser,\n ...updateData\n };\n\n // 7. Update user via repository\n const result = await this.repository.update(updatedUser);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n // 8. Publish after event\n await this.eventPublisher.publish(\n new UserAfterUpdateEvent({\n originalUser,\n updatedUser: result.value,\n input: validation.data\n })\n );\n\n return Result.ok(result.value);\n }\n}\n\nexport const UpdateUserUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: UpdateUserUseCaseImpl,\n dependencies: [IdentityContext
|
|
1
|
+
{"version":3,"file":"features/users/UpdateUser/UpdateUserUseCase.js","sources":["../../../../src/features/users/UpdateUser/UpdateUserUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { UpdateUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { RolesRepository } from \"~/features/security/roles/shared/abstractions.js\";\nimport { TeamsRepository } from \"~/features/security/teams/shared/abstractions.js\";\nimport { canAssignRolesAndTeams } from \"~/features/security/utils/canAssignRolesAndTeams.js\";\nimport { CANNOT_GRANT_PERMISSIONS_MESSAGE } from \"~/features/security/utils/canGrantPermissions.js\";\nimport { updateUserValidation } from \"./schema.js\";\nimport {\n NotAuthorizedError,\n EmailTakenError,\n UserValidationError\n} from \"~/features/users/shared/errors.js\";\nimport { UserBeforeUpdateEvent, UserAfterUpdateEvent } from \"./events.js\";\nimport type { AdminUser } from \"~/features/users/shared/types.js\";\nimport type { UpdateUserInput } from \"~/features/users/shared/types.js\";\n\nclass UpdateUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: AdminUsersRepository.Interface,\n private rolesRepository: RolesRepository.Interface,\n private teamsRepository: TeamsRepository.Interface\n ) {}\n\n async execute(\n id: string,\n input: UpdateUserInput\n ): Promise<Result<AdminUser, UseCaseAbstraction.Error>> {\n // 1. Check permission\n const permission = await this.identityContext.getPermission(\"adminUsers.user\");\n if (!permission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n // 2. Validate input\n const validation = updateUserValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new UserValidationError(validation.error.issues[0].message));\n }\n\n // If the input contains email, check if it is free to use.\n if (input.email) {\n const existingUserResult = await this.repository.get({ email: input.email });\n if (existingUserResult.isOk()) {\n if (existingUserResult.value.id !== id) {\n return Result.fail(new EmailTakenError(input.email));\n }\n }\n }\n // 3. Get existing user\n const getUserResult = await this.repository.get({ id });\n if (getUserResult.isFail()) {\n return Result.fail(getUserResult.error);\n }\n\n const originalUser = getUserResult.value;\n\n /**\n * Security: the caller may only assign roles and teams whose permissions they hold, and\n * may only manage a user whose current roles and teams they could assign (otherwise they\n * could, for example, change the password of a user with more access than they have).\n */\n const canAssign = await canAssignRolesAndTeams({\n identityContext: this.identityContext,\n rolesRepository: this.rolesRepository,\n teamsRepository: this.teamsRepository,\n roles: [...(originalUser.roles ?? []), ...(validation.data.roles ?? [])],\n teams: [...(originalUser.teams ?? []), ...(validation.data.teams ?? [])]\n });\n if (!canAssign) {\n return Result.fail(new NotAuthorizedError(CANNOT_GRANT_PERMISSIONS_MESSAGE));\n }\n\n // 4. Clone update data for event modification\n const updateData = structuredClone(validation.data);\n\n // 5. Publish before event\n await this.eventPublisher.publish(\n new UserBeforeUpdateEvent({ user: originalUser, updateData, input: validation.data })\n );\n\n // 6. Merge updates with existing user\n const updatedUser: AdminUser = {\n ...originalUser,\n ...updateData\n };\n\n // 7. Update user via repository\n const result = await this.repository.update(updatedUser);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n // 8. Publish after event\n await this.eventPublisher.publish(\n new UserAfterUpdateEvent({\n originalUser,\n updatedUser: result.value,\n input: validation.data\n })\n );\n\n return Result.ok(result.value);\n }\n}\n\nexport const UpdateUserUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: UpdateUserUseCaseImpl,\n dependencies: [\n IdentityContext,\n EventPublisher,\n AdminUsersRepository,\n RolesRepository,\n TeamsRepository\n ]\n});\n"],"names":["UpdateUserUseCaseImpl","identityContext","eventPublisher","repository","rolesRepository","teamsRepository","id","input","permission","Result","NotAuthorizedError","validation","updateUserValidation","UserValidationError","existingUserResult","EmailTakenError","getUserResult","originalUser","canAssign","canAssignRolesAndTeams","CANNOT_GRANT_PERMISSIONS_MESSAGE","updateData","structuredClone","UserBeforeUpdateEvent","updatedUser","result","UserAfterUpdateEvent","UpdateUserUseCase","createImplementation","UseCaseAbstraction","IdentityContext","EventPublisher","AdminUsersRepository","RolesRepository","TeamsRepository"],"mappings":";;;;;;;;;;;;AAoBA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAwC,EACxCC,UAA0C,EAC1CC,eAA0C,EAC1CC,eAA0C,CACpD;aALUJ,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,EAAU,EACVC,KAAsB,EAC8B;QAEpD,MAAMC,aAAa,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC5D,IAAI,CAACA,YACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAI3B,MAAMC,aAAaC,qBAAqB,SAAS,CAACL;QAClD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,oBAAoBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAIjF,IAAIJ,MAAM,KAAK,EAAE;YACb,MAAMO,qBAAqB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,O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QAC1B;QAGJ,OAAOF,OAAO,EAAE,CAACgB,OAAO,KAAK;IACjC;AACJ;AAEO,MAAME,sCAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgB7B;IAChB,cAAc;QACV8B;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/security/apiKey.gql.js","sources":["../../../src/graphql/security/apiKey.gql.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { CreateApiKeyUseCase } from \"~/features/security/apiKeys/CreateApiKey/index.js\";\nimport { UpdateApiKeyUseCase } from \"~/features/security/apiKeys/UpdateApiKey/index.js\";\nimport { DeleteApiKeyUseCase } from \"~/features/security/apiKeys/DeleteApiKey/index.js\";\nimport { ListApiKeysUseCase } from \"~/features/security/apiKeys/ListApiKeys/index.js\";\nimport { GetApiKeyUseCase } from \"~/features/security/apiKeys/GetApiKey/index.js\";\n\nexport default new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type SecurityApiKey {\n id: ID\n name: String\n slug: String\n description: String\n token: String\n permissions: [JSON]\n createdOn: DateTime\n createdBy: SecurityCreatedBy\n }\n\n input SecurityApiKeyInput {\n id: ID\n name: String!\n slug: String\n description: String\n token: String\n permissions: [JSON]!\n }\n\n type SecurityApiKeyResponse {\n data: SecurityApiKey\n error: SecurityError\n }\n\n type SecurityApiKeyListResponse {\n data: [SecurityApiKey!]\n error: SecurityError\n }\n\n extend type SecurityQuery {\n listApiKeys: SecurityApiKeyListResponse\n getApiKey(id: ID!): SecurityApiKeyResponse\n }\n\n extend type SecurityMutation {\n createApiKey(data: SecurityApiKeyInput!): SecurityApiKeyResponse\n updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse\n deleteApiKey(id: ID!): SecurityBooleanResponse\n }\n `,\n resolvers: {\n SecurityQuery: {\n async listApiKeys(_, __, context) {\n const list = context.container.resolve(ListApiKeysUseCase);\n const result = await list.execute();\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async getApiKey(_, args: any, context) {\n const getById = context.container.resolve(GetApiKeyUseCase);\n const result = await getById.execute(args.id);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n },\n SecurityMutation: {\n async createApiKey(_, args: any, context) {\n const createApiKey = context.container.resolve(CreateApiKeyUseCase);\n const result = await createApiKey.execute(args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async updateApiKey(_, args: any, context) {\n const updateApiKey = context.container.resolve(UpdateApiKeyUseCase);\n const result = await updateApiKey.execute(args.id, args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async deleteApiKey(_, args: any, context) {\n const deleteApiKey = context.container.resolve(DeleteApiKeyUseCase);\n const result = await deleteApiKey.execute(args.id);\n\n if (result.isOk()) {\n return new Response(true);\n }\n return new ErrorResponse(result.error);\n }\n }\n }\n});\n"],"names":["GraphQLSchemaPlugin","_","__","context","list","ListApiKeysUseCase","result","Response","ErrorResponse","args","getById","GetApiKeyUseCase","createApiKey","CreateApiKeyUseCase","updateApiKey","UpdateApiKeyUseCase","deleteApiKey","DeleteApiKeyUseCase"],"mappings":";;;;;;;AASA,mBAAe,IAAIA,oBAAoC;IACnD,UAAwB,CAAC
|
|
1
|
+
{"version":3,"file":"graphql/security/apiKey.gql.js","sources":["../../../src/graphql/security/apiKey.gql.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { CreateApiKeyUseCase } from \"~/features/security/apiKeys/CreateApiKey/index.js\";\nimport { UpdateApiKeyUseCase } from \"~/features/security/apiKeys/UpdateApiKey/index.js\";\nimport { DeleteApiKeyUseCase } from \"~/features/security/apiKeys/DeleteApiKey/index.js\";\nimport { ListApiKeysUseCase } from \"~/features/security/apiKeys/ListApiKeys/index.js\";\nimport { GetApiKeyUseCase } from \"~/features/security/apiKeys/GetApiKey/index.js\";\n\nexport default new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type SecurityApiKey {\n id: ID\n name: String\n slug: String\n description: String\n # Security: null when the caller doesn't have full access.\n token: String\n permissions: [JSON]\n createdOn: DateTime\n createdBy: SecurityCreatedBy\n }\n\n input SecurityApiKeyInput {\n id: ID\n name: String!\n slug: String\n description: String\n token: String\n permissions: [JSON]!\n }\n\n type SecurityApiKeyResponse {\n data: SecurityApiKey\n error: SecurityError\n }\n\n type SecurityApiKeyListResponse {\n data: [SecurityApiKey!]\n error: SecurityError\n }\n\n extend type SecurityQuery {\n listApiKeys: SecurityApiKeyListResponse\n getApiKey(id: ID!): SecurityApiKeyResponse\n }\n\n extend type SecurityMutation {\n createApiKey(data: SecurityApiKeyInput!): SecurityApiKeyResponse\n updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse\n deleteApiKey(id: ID!): SecurityBooleanResponse\n }\n `,\n resolvers: {\n SecurityQuery: {\n async listApiKeys(_, __, context) {\n const list = context.container.resolve(ListApiKeysUseCase);\n const result = await list.execute();\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async getApiKey(_, args: any, context) {\n const getById = context.container.resolve(GetApiKeyUseCase);\n const result = await getById.execute(args.id);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n },\n SecurityMutation: {\n async createApiKey(_, args: any, context) {\n const createApiKey = context.container.resolve(CreateApiKeyUseCase);\n const result = await createApiKey.execute(args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async updateApiKey(_, args: any, context) {\n const updateApiKey = context.container.resolve(UpdateApiKeyUseCase);\n const result = await updateApiKey.execute(args.id, args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n },\n async deleteApiKey(_, args: any, context) {\n const deleteApiKey = context.container.resolve(DeleteApiKeyUseCase);\n const result = await deleteApiKey.execute(args.id);\n\n if (result.isOk()) {\n return new Response(true);\n }\n return new ErrorResponse(result.error);\n }\n }\n }\n});\n"],"names":["GraphQLSchemaPlugin","_","__","context","list","ListApiKeysUseCase","result","Response","ErrorResponse","args","getById","GetApiKeyUseCase","createApiKey","CreateApiKeyUseCase","updateApiKey","UpdateApiKeyUseCase","deleteApiKey","DeleteApiKeyUseCase"],"mappings":";;;;;;;AASA,mBAAe,IAAIA,oBAAoC;IACnD,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0CzB,CAAC;IACD,WAAW;QACP,eAAe;YACX,MAAM,aAAYC,CAAC,EAAEC,EAAE,EAAEC,OAAO;gBAC5B,MAAMC,OAAOD,QAAQ,SAAS,CAAC,OAAO,CAACE;gBACvC,MAAMC,SAAS,MAAMF,KAAK,OAAO;gBAEjC,IAAIE,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,WAAUL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACjC,MAAMO,UAAUP,QAAQ,SAAS,CAAC,OAAO,CAACQ;gBAC1C,MAAML,SAAS,MAAMI,QAAQ,OAAO,CAACD,KAAK,EAAE;gBAE5C,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;QACJ;QACA,kBAAkB;YACd,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMS,eAAeT,QAAQ,SAAS,CAAC,OAAO,CAACU;gBAC/C,MAAMP,SAAS,MAAMM,aAAa,OAAO,CAACH,KAAK,IAAI;gBAEnD,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMW,eAAeX,QAAQ,SAAS,CAAC,OAAO,CAACY;gBAC/C,MAAMT,SAAS,MAAMQ,aAAa,OAAO,CAACL,KAAK,EAAE,EAAEA,KAAK,IAAI;gBAE5D,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;YACA,MAAM,cAAaL,CAAC,EAAEQ,IAAS,EAAEN,OAAO;gBACpC,MAAMa,eAAeb,QAAQ,SAAS,CAAC,OAAO,CAACc;gBAC/C,MAAMX,SAAS,MAAMU,aAAa,OAAO,CAACP,KAAK,EAAE;gBAEjD,IAAIH,OAAO,IAAI,IACX,OAAO,IAAIC,SAAS;gBAExB,OAAO,IAAIC,cAAcF,OAAO,KAAK;YACzC;QACJ;IACJ;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response } from "@webiny/handler-graphql/responses.js";
|
|
2
2
|
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
|
|
3
3
|
import { GetUserUseCase } from "../../features/users/GetUser/index.js";
|
|
4
|
-
import
|
|
4
|
+
import { GetCurrentUserUseCase } from "../../features/users/GetCurrentUser/index.js";
|
|
5
5
|
import { ListUsersUseCase } from "../../features/users/ListUsers/index.js";
|
|
6
6
|
const emptyResolver = ()=>({});
|
|
7
7
|
const createUsersGraphQL = ()=>[
|
|
@@ -97,7 +97,8 @@ const createUsersGraphQL = ()=>[
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
AdminUsersQuery: {
|
|
100
|
-
getUser: async (_,
|
|
100
|
+
getUser: async (_, args, context)=>{
|
|
101
|
+
const where = args.where ?? {};
|
|
101
102
|
const getUser = context.container.resolve(GetUserUseCase);
|
|
102
103
|
const userResult = await getUser.execute({
|
|
103
104
|
id: where.id,
|
|
@@ -115,22 +116,18 @@ const createUsersGraphQL = ()=>[
|
|
|
115
116
|
return new Response(userResult.value);
|
|
116
117
|
},
|
|
117
118
|
getCurrentUser: async (_, __, context)=>{
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}));
|
|
124
|
-
if (userResponse.isFail()) {
|
|
125
|
-
const error = userResponse.error;
|
|
126
|
-
if ("AdminUser/NotFound" === error.code) return new NotFoundResponse(`User with ID ${identity.id} was not found!`);
|
|
119
|
+
const getCurrentUser = context.container.resolve(GetCurrentUserUseCase);
|
|
120
|
+
const userResult = await getCurrentUser.execute();
|
|
121
|
+
if (userResult.isFail()) {
|
|
122
|
+
const error = userResult.error;
|
|
123
|
+
if ("AdminUser/NotFound" === error.code) return new NotFoundResponse("Current user was not found!");
|
|
127
124
|
return new ErrorResponse({
|
|
128
125
|
message: error.message,
|
|
129
126
|
code: error.code,
|
|
130
127
|
data: error.data
|
|
131
128
|
});
|
|
132
129
|
}
|
|
133
|
-
return new Response(
|
|
130
|
+
return new Response(userResult.value);
|
|
134
131
|
},
|
|
135
132
|
listUsers: async (_, __, context)=>{
|
|
136
133
|
const listUsers = context.container.resolve(ListUsersUseCase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/users/user.gql.js","sources":["../../../src/graphql/users/user.gql.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"~/graphql/security/NotAuthorizedResponse.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\n\nconst emptyResolver = () => ({});\n\nexport const createUsersGraphQL = () => {\n return [\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n `,\n resolvers: {\n Query: {\n adminUsers: emptyResolver\n },\n Mutation: {\n adminUsers: emptyResolver\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n `,\n resolvers: {\n AdminUser: {\n roles(user: AdminUser, _, context) {\n if (!user.roles) {\n return null;\n }\n\n return context.security.listRoles({ where: { id_in: user.roles } });\n }\n },\n AdminUsersQuery: {\n getUser: async (_, { where }: any, context) => {\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n },\n getCurrentUser: async (_, __, context) => {\n const identity = context.security.getIdentity();\n\n if (!identity.isAdmin()) {\n throw new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions to execute `getUser` (this method can load any user in the system),\n // but loading your own user record should be allowed. For that reason, let's temporarily disable authorization.\n\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResponse = await context.security.withoutAuthorization(\n async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n }\n );\n\n if (userResponse.isFail()) {\n const error = userResponse.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User with ID ${identity.id} was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResponse.value);\n },\n listUsers: async (_, __, context) => {\n const listUsers = context.container.resolve(ListUsersUseCase);\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `,\n resolvers: {\n AdminUser: {\n teams(user: AdminUser, _, context) {\n const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n return context.security.listTeams({ where: { id_in: user.teams } });\n }\n }\n }\n })\n ].filter(Boolean);\n};\n"],"names":["emptyResolver","createUsersGraphQL","GraphQLSchemaPlugin","user","_","context","where","getUser","GetUserUseCase","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","__","identity","NotAuthorizedResponse","userResponse","listUsers","ListUsersUseCase","users","ListErrorResponse","ListResponse","hasTeams","Array","Boolean"],"mappings":";;;;;AAcA,MAAMA,gBAAgB,IAAO,EAAC;AAEvB,MAAMC,qBAAqB,IACvB;QACH,IAAIC,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCzB,CAAC;YACD,WAAW;gBACP,OAAO;oBACH,YAAYF;gBAChB;gBACA,UAAU;oBACN,YAAYA;gBAChB;YACJ;QACJ;QACA,IAAIE,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkCzB,CAAC;YACD,WAAW;gBACP,WAAW;oBACP,OAAMC,IAAe,EAAEC,CAAC,EAAEC,OAAO;wBAC7B,IAAI,CAACF,KAAK,KAAK,EACX,OAAO;wBAGX,OAAOE,QAAQ,QAAQ,CAAC,SAAS,CAAC;4BAAE,OAAO;gCAAE,OAAOF,KAAK,KAAK;4BAAC;wBAAE;oBACrE;gBACJ;gBACA,iBAAiB;oBACb,SAAS,OAAOC,GAAG,EAAEE,KAAK,EAAO,EAAED;wBAC/B,MAAME,UAAUF,QAAQ,SAAS,CAAC,OAAO,CAACG;wBAE1C,MAAMC,aAAa,MAAMF,QAAQ,OAAO,CAAC;4BACrC,IAAID,MAAM,EAAE;4BACZ,OAAOA,MAAM,KAAK;wBACtB;wBAEA,IAAIG,WAAW,MAAM,IAAI;4BACrB,MAAMC,QAAQD,WAAW,KAAK;4BAC9B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAO,IAAIC,iBACP,CAAC,MAAM,EAAEC,KAAK,SAAS,CAACN,OAAO,gBAAgB,CAAC;4BAIxD,OAAO,IAAIO,cAAc;gCACrB,SAASH,MAAM,OAAO;gCACtB,MAAMA,MAAM,IAAI;gCAChB,MAAMA,MAAM,IAAI;4BACpB;wB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AAE;wBAGb,OAAOnB,QAAQ,QAAQ,CAAC,SAAS,CAAC;4BAAE,OAAO;gCAAE,OAAOF,KAAK,KAAK;4BAAC;wBAAE;oBACrE;gBACJ;YACJ;QACJ;KACH,CAAC,MAAM,CAACuB"}
|
|
1
|
+
{"version":3,"file":"graphql/users/user.gql.js","sources":["../../../src/graphql/users/user.gql.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport { GetCurrentUserUseCase } from \"~/features/users/GetCurrentUser/index.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\n\nconst emptyResolver = () => ({});\n\nexport const createUsersGraphQL = () => {\n return [\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n `,\n resolvers: {\n Query: {\n adminUsers: emptyResolver\n },\n Mutation: {\n adminUsers: emptyResolver\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n `,\n resolvers: {\n AdminUser: {\n roles(user: AdminUser, _, context) {\n if (!user.roles) {\n return null;\n }\n\n return context.security.listRoles({ where: { id_in: user.roles } });\n }\n },\n AdminUsersQuery: {\n getUser: async (_, args: any, context) => {\n // `where` is optional in the schema.\n const where = args.where ?? {};\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n },\n getCurrentUser: async (_, __, context) => {\n const getCurrentUser = context.container.resolve(GetCurrentUserUseCase);\n\n const userResult = await getCurrentUser.execute();\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\"Current user was not found!\");\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n },\n listUsers: async (_, __, context) => {\n const listUsers = context.container.resolve(ListUsersUseCase);\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `,\n resolvers: {\n AdminUser: {\n teams(user: AdminUser, _, context) {\n const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n return context.security.listTeams({ where: { id_in: user.teams } });\n }\n }\n }\n })\n ].filter(Boolean);\n};\n"],"names":["emptyResolver","createUsersGraphQL","GraphQLSchemaPlugin","user","_","context","args","where","getUser","GetUserUseCase","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","__","getCurrentUser","GetCurrentUserUseCase","listUsers","ListUsersUseCase","users","ListErrorResponse","ListResponse","hasTeams","Array","Boolean"],"mappings":";;;;;AAcA,MAAMA,gBAAgB,IAAO,EAAC;AAEvB,MAAMC,qBAAqB,IACvB;QACH,IAAIC,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCzB,CAAC;YACD,WAAW;gBACP,OAAO;oBACH,YAAYF;gBAChB;gBACA,UAAU;oBACN,YAAYA;gBAChB;YACJ;QACJ;QACA,IAAIE,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkCzB,CAAC;YACD,WAAW;gBACP,WAAW;oBACP,OAAMC,IAAe,EAAEC,CAAC,EAAEC,OAAO;wBAC7B,IAAI,CAACF,KAAK,KAAK,EACX,OAAO;wBAGX,OAAOE,QAAQ,QAAQ,CAAC,SAAS,CAAC;4BAAE,OAAO;gCAAE,OAAOF,KAAK,KAAK;4BAAC;wBAAE;oBACrE;gBACJ;gBACA,iBAAiB;oBACb,SAAS,OAAOC,GAAGE,MAAWD;wBAE1B,MAAME,QAAQD,KAAK,KAAK,IAAI,CAAC;wBAC7B,MAAME,UAAUH,QAAQ,SAAS,CAAC,OAAO,CAACI;wBAE1C,MAAMC,aAAa,MAAMF,QAAQ,OAAO,CAAC;4BACrC,IAAID,MAAM,EAAE;4BACZ,OAAOA,MAAM,KAAK;wBACtB;wBAEA,IAAIG,WAAW,MAAM,IAAI;4BACrB,MAAMC,QAAQD,WAAW,KAAK;4BAC9B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAO,IAAIC,iB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,OAAO;gCAAE,OAAOF,KAAK,KAAK;4BAAC;wBAAE;oBACrE;gBACJ;YACJ;QACJ;KACH,CAAC,MAAM,CAACuB"}
|
|
@@ -41,7 +41,10 @@ class OidcJwtIdentityProviderImpl {
|
|
|
41
41
|
const jwks = await this.jwksCache.getKeys(provider.issuer);
|
|
42
42
|
const jwk = jwks.find((key)=>key.kid === header.kid);
|
|
43
43
|
if (!jwk) return null;
|
|
44
|
-
if (!verifiedPayload) verifiedPayload = await verifyJwtUsingJwk(token, jwk
|
|
44
|
+
if (!verifiedPayload) verifiedPayload = await verifyJwtUsingJwk(token, jwk, {
|
|
45
|
+
issuer: provider.issuer,
|
|
46
|
+
audience: provider.clientId
|
|
47
|
+
});
|
|
45
48
|
if (provider.verifyTokenClaims) await provider.verifyTokenClaims(verifiedPayload);
|
|
46
49
|
return verifiedPayload;
|
|
47
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idp/OidcJwtIdentityProvider.js","sources":["../../src/idp/OidcJwtIdentityProvider.ts"],"sourcesContent":["import { verifyJwtUsingJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport { JwkCache, JwtIdentityProvider, OidcIdentityProvider } from \"./abstractions.js\";\n\nclass OidcJwtIdentityProviderImpl implements JwtIdentityProvider.Interface {\n constructor(\n private oidcIdentityProviders: OidcIdentityProvider.Interface[],\n private jwksCache: JwkCache.Interface\n ) {}\n\n isApplicable(token: JwtIdentityProvider.JwtPayload): boolean {\n return this.oidcIdentityProviders.some(provider => provider.isApplicable(token));\n }\n\n async getIdentity(token: string, jwt: JwtIdentityProvider.Jwt): Promise<IdentityData | null> {\n const { header, payload } = jwt;\n\n const provider = this.getApplicableProvider(payload);\n\n if (!provider) {\n return null;\n }\n\n const verifiedPayload = await this.verifyToken(provider, token, header);\n\n if (!verifiedPayload) {\n return null;\n }\n\n // Call config.getIdentity to get IdentityData\n const providerIdentity = await provider.getIdentity(verifiedPayload);\n\n const identity: IdentityData = {\n ...providerIdentity,\n type: providerIdentity.type ?? \"admin\"\n };\n\n // Handle default values\n const context = identity.context ?? { canAccessTenant: true, defaultTenantId: \"root\" };\n if (context.canAccessTenant === undefined) {\n context.canAccessTenant = true;\n }\n if (context.defaultTenantId === undefined) {\n context.defaultTenantId = \"root\";\n }\n\n identity.context = context;\n\n return identity;\n }\n\n private getApplicableProvider(\n payload: JwtIdentityProvider.JwtPayload\n ): OidcIdentityProvider.Interface | undefined {\n return this.oidcIdentityProviders.find(provider => provider.isApplicable(payload));\n }\n\n private async verifyToken(\n provider: OidcIdentityProvider.Interface,\n token: string,\n header: JwtIdentityProvider.JwtHeader\n ) {\n // If the implementation specifies a custom verification function, use it.\n let verifiedPayload: JwtIdentityProvider.JwtPayload | undefined;\n if (typeof provider.verifyToken === \"function\") {\n // Use custom verification\n const result = await provider.verifyToken(token);\n if (result) {\n return result;\n }\n return null;\n }\n\n // Otherwise, continue with OIDC best practices, using JWKs.\n\n // Fetch JWKs from cache\n const jwks = await this.jwksCache.getKeys(provider.issuer);\n\n // Find matching JWK using header.kid\n const jwk = jwks.find(key => key.kid === header.kid);\n if (!jwk) {\n return null;\n }\n\n if (!verifiedPayload) {\n // Default JWK verification\n verifiedPayload = await verifyJwtUsingJwk(token, jwk);\n }\n\n // Call verifyTokenClaims if provided\n if (provider.verifyTokenClaims) {\n await provider.verifyTokenClaims(verifiedPayload);\n }\n\n return verifiedPayload;\n }\n}\n\nexport const OidcJwtIdentityProvider = JwtIdentityProvider.createImplementation({\n implementation: OidcJwtIdentityProviderImpl,\n dependencies: [[OidcIdentityProvider, { multiple: true }], JwkCache]\n});\n"],"names":["OidcJwtIdentityProviderImpl","oidcIdentityProviders","jwksCache","token","provider","jwt","header","payload","verifiedPayload","providerIdentity","identity","context","undefined","result","jwks","jwk","key","verifyJwtUsingJwk","OidcJwtIdentityProvider","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";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AAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACV,SAAS,MAAM;QAGzD,MAAMW,MAAMD,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,GAAG,KAAKV,OAAO,GAAG;QACnD,IAAI,CAACS,KACD,OAAO;QAGX,IAAI,CAACP,
|
|
1
|
+
{"version":3,"file":"idp/OidcJwtIdentityProvider.js","sources":["../../src/idp/OidcJwtIdentityProvider.ts"],"sourcesContent":["import { verifyJwtUsingJwk } from \"~/features/security/utils/verifyJwtUsingJwk.js\";\nimport type { IdentityData } from \"~/features/security/IdentityContext/Identity.js\";\nimport { JwkCache, JwtIdentityProvider, OidcIdentityProvider } from \"./abstractions.js\";\n\nclass OidcJwtIdentityProviderImpl implements JwtIdentityProvider.Interface {\n constructor(\n private oidcIdentityProviders: OidcIdentityProvider.Interface[],\n private jwksCache: JwkCache.Interface\n ) {}\n\n isApplicable(token: JwtIdentityProvider.JwtPayload): boolean {\n return this.oidcIdentityProviders.some(provider => provider.isApplicable(token));\n }\n\n async getIdentity(token: string, jwt: JwtIdentityProvider.Jwt): Promise<IdentityData | null> {\n const { header, payload } = jwt;\n\n const provider = this.getApplicableProvider(payload);\n\n if (!provider) {\n return null;\n }\n\n const verifiedPayload = await this.verifyToken(provider, token, header);\n\n if (!verifiedPayload) {\n return null;\n }\n\n // Call config.getIdentity to get IdentityData\n const providerIdentity = await provider.getIdentity(verifiedPayload);\n\n const identity: IdentityData = {\n ...providerIdentity,\n type: providerIdentity.type ?? \"admin\"\n };\n\n // Handle default values\n const context = identity.context ?? { canAccessTenant: true, defaultTenantId: \"root\" };\n if (context.canAccessTenant === undefined) {\n context.canAccessTenant = true;\n }\n if (context.defaultTenantId === undefined) {\n context.defaultTenantId = \"root\";\n }\n\n identity.context = context;\n\n return identity;\n }\n\n private getApplicableProvider(\n payload: JwtIdentityProvider.JwtPayload\n ): OidcIdentityProvider.Interface | undefined {\n return this.oidcIdentityProviders.find(provider => provider.isApplicable(payload));\n }\n\n private async verifyToken(\n provider: OidcIdentityProvider.Interface,\n token: string,\n header: JwtIdentityProvider.JwtHeader\n ) {\n // If the implementation specifies a custom verification function, use it.\n let verifiedPayload: JwtIdentityProvider.JwtPayload | undefined;\n if (typeof provider.verifyToken === \"function\") {\n // Use custom verification\n const result = await provider.verifyToken(token);\n if (result) {\n return result;\n }\n return null;\n }\n\n // Otherwise, continue with OIDC best practices, using JWKs.\n\n // Fetch JWKs from cache\n const jwks = await this.jwksCache.getKeys(provider.issuer);\n\n // Find matching JWK using header.kid\n const jwk = jwks.find(key => key.kid === header.kid);\n if (!jwk) {\n return null;\n }\n\n if (!verifiedPayload) {\n // Default JWK verification\n // Security: audience/issuer are enforced only when the provider has them configured.\n verifiedPayload = await verifyJwtUsingJwk(token, jwk, {\n issuer: provider.issuer,\n audience: provider.clientId\n });\n }\n\n // Call verifyTokenClaims if provided\n if (provider.verifyTokenClaims) {\n await provider.verifyTokenClaims(verifiedPayload);\n }\n\n return verifiedPayload;\n }\n}\n\nexport const OidcJwtIdentityProvider = JwtIdentityProvider.createImplementation({\n implementation: OidcJwtIdentityProviderImpl,\n dependencies: [[OidcIdentityProvider, { multiple: true }], JwkCache]\n});\n"],"names":["OidcJwtIdentityProviderImpl","oidcIdentityProviders","jwksCache","token","provider","jwt","header","payload","verifiedPayload","providerIdentity","identity","context","undefined","result","jwks","jwk","key","verifyJwtUsingJwk","OidcJwtIdentityProvider","JwtIdentityProvider","OidcIdentityProvider","JwkCache"],"mappings":";;AAIA,MAAMA;IACF,YACYC,qBAAuD,EACvDC,SAA6B,CACvC;aAFUD,qBAAqB,GAArBA;aACAC,SAAS,GAATA;IACT;IAEH,aAAaC,KAAqC,EAAW;QACzD,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACC,CAAAA,WAAYA,SAAS,YAAY,CAACD;IAC7E;IAEA,MAAM,YAAYA,KAAa,EAAEE,GAA4B,EAAgC;QACzF,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;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AiB,EAC1B,MAAMA,SAAS,iBAAiB,CAACI;QAGrC,OAAOA;IACX;AACJ;AAEO,MAAMU,0BAA0BC,oBAAoB,oBAAoB,CAAC;IAC5E,gBAAgBnB;IAChB,cAAc;QAAC;YAACoB;YAAsB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAS;AACxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-core",
|
|
3
|
-
"version": "6.5.2-beta.
|
|
3
|
+
"version": "6.5.2-beta.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,39 +14,39 @@
|
|
|
14
14
|
"./*": "./*"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ai-sdk/anthropic": "4.0.
|
|
18
|
-
"@ai-sdk/google": "4.0.
|
|
19
|
-
"@ai-sdk/openai": "4.0.
|
|
17
|
+
"@ai-sdk/anthropic": "4.0.99",
|
|
18
|
+
"@ai-sdk/google": "4.0.114",
|
|
19
|
+
"@ai-sdk/openai": "4.0.111",
|
|
20
20
|
"@openrouter/ai-sdk-provider": "3.1.0",
|
|
21
|
-
"@webiny/api": "6.5.2-beta.
|
|
21
|
+
"@webiny/api": "6.5.2-beta.3",
|
|
22
22
|
"@webiny/di": "1.1.0",
|
|
23
|
-
"@webiny/error": "6.5.2-beta.
|
|
24
|
-
"@webiny/feature": "6.5.2-beta.
|
|
25
|
-
"@webiny/feature-flags": "6.5.2-beta.
|
|
26
|
-
"@webiny/handler": "6.5.2-beta.
|
|
27
|
-
"@webiny/handler-db": "6.5.2-beta.
|
|
28
|
-
"@webiny/handler-graphql": "6.5.2-beta.
|
|
29
|
-
"@webiny/plugins": "6.5.2-beta.
|
|
30
|
-
"@webiny/utils": "6.5.2-beta.
|
|
31
|
-
"@webiny/wcp": "6.5.2-beta.
|
|
32
|
-
"ai": "7.0.
|
|
23
|
+
"@webiny/error": "6.5.2-beta.3",
|
|
24
|
+
"@webiny/feature": "6.5.2-beta.3",
|
|
25
|
+
"@webiny/feature-flags": "6.5.2-beta.3",
|
|
26
|
+
"@webiny/handler": "6.5.2-beta.3",
|
|
27
|
+
"@webiny/handler-db": "6.5.2-beta.3",
|
|
28
|
+
"@webiny/handler-graphql": "6.5.2-beta.3",
|
|
29
|
+
"@webiny/plugins": "6.5.2-beta.3",
|
|
30
|
+
"@webiny/utils": "6.5.2-beta.3",
|
|
31
|
+
"@webiny/wcp": "6.5.2-beta.3",
|
|
32
|
+
"ai": "7.0.166",
|
|
33
33
|
"dataloader": "2.2.3",
|
|
34
|
-
"jose": "6.2.
|
|
34
|
+
"jose": "6.2.17",
|
|
35
35
|
"jsonwebtoken": "9.0.3",
|
|
36
36
|
"lodash": "4.18.1",
|
|
37
|
-
"minimatch": "11.0.
|
|
37
|
+
"minimatch": "11.0.5",
|
|
38
38
|
"pino": "10.4.0",
|
|
39
39
|
"pino-lambda": "4.4.1",
|
|
40
40
|
"zod": "4.6.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/jsonwebtoken": "9.0.10",
|
|
44
|
-
"@webiny/build-tools": "6.5.2-beta.
|
|
45
|
-
"@webiny/handler-aws": "6.5.2-beta.
|
|
46
|
-
"@webiny/project-utils": "6.5.2-beta.
|
|
47
|
-
"rimraf": "6.1.
|
|
44
|
+
"@webiny/build-tools": "6.5.2-beta.3",
|
|
45
|
+
"@webiny/handler-aws": "6.5.2-beta.3",
|
|
46
|
+
"@webiny/project-utils": "6.5.2-beta.3",
|
|
47
|
+
"rimraf": "6.1.4",
|
|
48
48
|
"typescript": "7.0.2",
|
|
49
|
-
"vitest": "5.0
|
|
49
|
+
"vitest": "5.1.0"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|