@webiny/cognito 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.c27f4d8a31
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/Cognito.d.ts +1 -5
- package/Cognito.js +2 -3
- package/Cognito.js.map +1 -1
- package/admin/Cognito.js +2 -4
- package/admin/Cognito.js.map +1 -1
- package/admin/SecurityPermission.d.ts +2 -0
- package/admin/SecurityPermission.js +26 -0
- package/admin/SecurityPermission.js.map +1 -0
- package/api/features/CreateUser/CreateUserUseCase.js +1 -1
- package/api/features/CreateUser/CreateUserUseCase.js.map +1 -1
- package/api/features/CreateUser/schema.d.ts +4 -36
- package/api/features/UpdateUser/UpdateUserUseCase.js +1 -1
- package/api/features/UpdateUser/UpdateUserUseCase.js.map +1 -1
- package/api/features/UpdateUser/schema.d.ts +4 -34
- package/package.json +24 -25
- package/admin/plugins/permissionRenderer/AdminUsersPermissions.d.ts +0 -7
- package/admin/plugins/permissionRenderer/AdminUsersPermissions.js +0 -129
- package/admin/plugins/permissionRenderer/AdminUsersPermissions.js.map +0 -1
- package/admin/plugins/permissionRenderer/index.d.ts +0 -3
- package/admin/plugins/permissionRenderer/index.js +0 -20
- package/admin/plugins/permissionRenderer/index.js.map +0 -1
package/Cognito.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const Cognito: import("@webiny/project/defineExtension/defineExtension").ExtensionComponent<z.ZodObject<{
|
|
3
3
|
apiConfig: z.ZodOptional<z.ZodString>;
|
|
4
|
-
},
|
|
5
|
-
apiConfig?: string | undefined;
|
|
6
|
-
}, {
|
|
7
|
-
apiConfig?: string | undefined;
|
|
8
|
-
}>>;
|
|
4
|
+
}, z.core.$strip>>;
|
package/Cognito.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { defineExtension } from "@webiny/project/defineExtension/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import { Api, Admin } from "@webiny/project-aws";
|
|
3
|
+
import { Api, Admin, Infra } from "@webiny/project-aws";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
export const Cognito = defineExtension({
|
|
7
6
|
type: "Project/Cognito",
|
|
@@ -13,7 +12,7 @@ export const Cognito = defineExtension({
|
|
|
13
12
|
apiConfig: z.string().describe("Path to API configuration.").optional()
|
|
14
13
|
}),
|
|
15
14
|
render: props => {
|
|
16
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EnvVar, {
|
|
15
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Infra.EnvVar, {
|
|
17
16
|
varName: "REACT_APP_IDP_TYPE",
|
|
18
17
|
value: "cognito"
|
|
19
18
|
}), /*#__PURE__*/React.createElement(Api.Extension, {
|
package/Cognito.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","defineExtension","
|
|
1
|
+
{"version":3,"names":["React","defineExtension","Api","Admin","Infra","z","Cognito","type","tags","runtimeContext","description","paramsSchema","object","apiConfig","string","describe","optional","render","props","createElement","Fragment","EnvVar","varName","value","Extension","src","import","meta","dirname","exportName"],"sources":["Cognito.tsx"],"sourcesContent":["import React from \"react\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { Api, Admin, Infra } from \"@webiny/project-aws\";\nimport { z } from \"zod\";\n\nexport const Cognito = defineExtension({\n type: \"Project/Cognito\",\n tags: { runtimeContext: \"project\" },\n description: \"Enable and configure Cognito authentication.\",\n paramsSchema: z.object({\n apiConfig: z.string().describe(\"Path to API configuration.\").optional()\n }),\n render: props => {\n return (\n <>\n <Infra.EnvVar varName={\"REACT_APP_IDP_TYPE\"} value={\"cognito\"} />\n {/* Api extensions */}\n <Api.Extension\n src={import.meta.dirname + \"/api/CognitoApiFeature.js\"}\n exportName={\"CognitoApiFeature\"}\n />\n {props.apiConfig ? <Api.Extension src={props.apiConfig} /> : null}\n {/* Admin extensions */}\n <Admin.Extension src={import.meta.dirname + \"/admin/Extension.js\"} />\n </>\n );\n }\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,0CAA0C;AAC1E,SAASC,GAAG,EAAEC,KAAK,EAAEC,KAAK,QAAQ,qBAAqB;AACvD,SAASC,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,OAAO,GAAGL,eAAe,CAAC;EACnCM,IAAI,EAAE,iBAAiB;EACvBC,IAAI,EAAE;IAAEC,cAAc,EAAE;EAAU,CAAC;EACnCC,WAAW,EAAE,8CAA8C;EAC3DC,YAAY,EAAEN,CAAC,CAACO,MAAM,CAAC;IACnBC,SAAS,EAAER,CAAC,CAACS,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,4BAA4B,CAAC,CAACC,QAAQ,CAAC;EAC1E,CAAC,CAAC;EACFC,MAAM,EAAEC,KAAK,IAAI;IACb,oBACIlB,KAAA,CAAAmB,aAAA,CAAAnB,KAAA,CAAAoB,QAAA,qBACIpB,KAAA,CAAAmB,aAAA,CAACf,KAAK,CAACiB,MAAM;MAACC,OAAO,EAAE,oBAAqB;MAACC,KAAK,EAAE;IAAU,CAAE,CAAC,eAEjEvB,KAAA,CAAAmB,aAAA,CAACjB,GAAG,CAACsB,SAAS;MACVC,GAAG,EAAEC,MAAM,CAACC,IAAI,CAACC,OAAO,GAAG,2BAA4B;MACvDC,UAAU,EAAE;IAAoB,CACnC,CAAC,EACDX,KAAK,CAACL,SAAS,gBAAGb,KAAA,CAAAmB,aAAA,CAACjB,GAAG,CAACsB,SAAS;MAACC,GAAG,EAAEP,KAAK,CAACL;IAAU,CAAE,CAAC,GAAG,IAAI,eAEjEb,KAAA,CAAAmB,aAAA,CAAChB,KAAK,CAACqB,SAAS;MAACC,GAAG,EAAEC,MAAM,CAACC,IAAI,CAACC,OAAO,GAAG;IAAsB,CAAE,CACtE,CAAC;EAEX;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/admin/Cognito.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React, { Fragment, memo } from "react";
|
|
2
2
|
import { AdminConfig, AdminLayout } from "@webiny/app-admin";
|
|
3
|
-
import { plugins } from "@webiny/plugins";
|
|
4
3
|
import { HasPermission } from "@webiny/app-admin";
|
|
5
4
|
import { useRouter } from "@webiny/app-admin";
|
|
6
5
|
import { Permission } from "./plugins/constants.js";
|
|
7
6
|
import { UsersView } from "./ui/views/Users/UsersView.js";
|
|
8
7
|
import { UserAccountForm } from "./ui/views/Account/index.js";
|
|
9
8
|
import { AccountDetails } from "./plugins/userMenu/AccountDetails.js";
|
|
10
|
-
import
|
|
9
|
+
import { SecurityPermission } from "./SecurityPermission.js";
|
|
11
10
|
import { CognitoLogin } from "./CognitoLogin.js";
|
|
12
11
|
import { Routes } from "./routes.js";
|
|
13
12
|
const {
|
|
@@ -18,8 +17,7 @@ const CognitoIdP = props => {
|
|
|
18
17
|
const {
|
|
19
18
|
getLink
|
|
20
19
|
} = useRouter();
|
|
21
|
-
|
|
22
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(CognitoLogin, props.login), /*#__PURE__*/React.createElement(AdminConfig, null, /*#__PURE__*/React.createElement(HasPermission, {
|
|
20
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(SecurityPermission, null), /*#__PURE__*/React.createElement(CognitoLogin, props.login), /*#__PURE__*/React.createElement(AdminConfig, null, /*#__PURE__*/React.createElement(HasPermission, {
|
|
23
21
|
name: Permission.Users
|
|
24
22
|
}, /*#__PURE__*/React.createElement(Route, {
|
|
25
23
|
route: Routes.Users.List,
|
package/admin/Cognito.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Fragment","memo","AdminConfig","AdminLayout","
|
|
1
|
+
{"version":3,"names":["React","Fragment","memo","AdminConfig","AdminLayout","HasPermission","useRouter","Permission","UsersView","UserAccountForm","AccountDetails","SecurityPermission","CognitoLogin","Routes","Route","Menu","CognitoIdP","props","getLink","createElement","login","name","Users","route","List","element","title","Account","parent","after","Link","text","to","pinnable","User","accountRoute","CognitoAdmin"],"sources":["Cognito.tsx"],"sourcesContent":["import React, { Fragment, memo } from \"react\";\nimport { AdminConfig, AdminLayout } from \"@webiny/app-admin\";\nimport { HasPermission } from \"@webiny/app-admin\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { Permission } from \"./plugins/constants.js\";\nimport { UsersView } from \"./ui/views/Users/UsersView.js\";\nimport { UserAccountForm } from \"./ui/views/Account/index.js\";\nimport { AccountDetails } from \"./plugins/userMenu/AccountDetails.js\";\nimport { SecurityPermission } from \"./SecurityPermission.js\";\nimport { CognitoLogin, type CognitoLoginProps } from \"./CognitoLogin.js\";\nimport { Routes } from \"./routes.js\";\n\nconst { Route, Menu } = AdminConfig;\n\nexport interface CognitoAdminProps {\n login: CognitoLoginProps;\n}\n\nconst CognitoIdP = (props: CognitoAdminProps) => {\n const { getLink } = useRouter();\n\n return (\n <Fragment>\n <SecurityPermission />\n <CognitoLogin {...props.login} />\n <AdminConfig>\n <HasPermission name={Permission.Users}>\n <Route\n route={Routes.Users.List}\n element={\n <AdminLayout title={\"Admin Users\"}>\n <UsersView />\n </AdminLayout>\n }\n />\n\n <Route\n route={Routes.Users.Account}\n element={\n <AdminLayout title={\"User Account\"}>\n <UserAccountForm />\n </AdminLayout>\n }\n />\n\n <Menu\n name={\"cognito.settings.adminUsers\"}\n parent={\"settings\"}\n after={\"security.settings\"}\n element={\n <Menu.Link\n text={\"Users\"}\n to={getLink(Routes.Users.List)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n\n <Menu.User\n name={\"accountSettings\"}\n after={\"userInfo\"}\n element={<AccountDetails accountRoute={getLink(Routes.Users.Account)} />}\n />\n </AdminConfig>\n </Fragment>\n );\n};\n\nexport const CognitoAdmin = memo(CognitoIdP);\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AE,CACT;EAChB,CACJ,CAAC,eAEFT,KAAA,CAAAmB,aAAA,CAACJ,IAAI;IACDM,IAAI,EAAE,6BAA8B;IACpCO,MAAM,EAAE,UAAW;IACnBC,KAAK,EAAE,mBAAoB;IAC3BJ,OAAO,eACHzB,KAAA,CAAAmB,aAAA,CAACJ,IAAI,CAACe,IAAI;MACNC,IAAI,EAAE,OAAQ;MACdC,EAAE,EAAEd,OAAO,CAACL,MAAM,CAACS,KAAK,CAACE,IAAI,CAAE;MAC/BS,QAAQ,EAAE;IAAK,CAClB;EACJ,CACJ,CACU,CAAC,eAEhBjC,KAAA,CAAAmB,aAAA,CAACJ,IAAI,CAACmB,IAAI;IACNb,IAAI,EAAE,iBAAkB;IACxBQ,KAAK,EAAE,UAAW;IAClBJ,OAAO,eAAEzB,KAAA,CAAAmB,aAAA,CAACT,cAAc;MAACyB,YAAY,EAAEjB,OAAO,CAACL,MAAM,CAACS,KAAK,CAACK,OAAO;IAAE,CAAE;EAAE,CAC5E,CACQ,CACP,CAAC;AAEnB,CAAC;AAED,OAAO,MAAMS,YAAY,gBAAGlC,IAAI,CAACc,UAAU,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AdminConfig } from "@webiny/app-admin";
|
|
3
|
+
import { ReactComponent as PermissionsIcon } from "@webiny/icons/group.svg";
|
|
4
|
+
const {
|
|
5
|
+
Security
|
|
6
|
+
} = AdminConfig;
|
|
7
|
+
export const SecurityPermission = () => {
|
|
8
|
+
return /*#__PURE__*/React.createElement(AdminConfig, null, /*#__PURE__*/React.createElement(Security.Permissions, {
|
|
9
|
+
name: "admin-users",
|
|
10
|
+
title: "Admin Users",
|
|
11
|
+
description: "Manage Admin Users permissions.",
|
|
12
|
+
icon: /*#__PURE__*/React.createElement(PermissionsIcon, null),
|
|
13
|
+
schema: {
|
|
14
|
+
prefix: "adminUsers",
|
|
15
|
+
fullAccess: true,
|
|
16
|
+
entities: [{
|
|
17
|
+
id: "user",
|
|
18
|
+
title: "Users",
|
|
19
|
+
permission: "adminUsers.user",
|
|
20
|
+
scopes: ["full"]
|
|
21
|
+
}]
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=SecurityPermission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","AdminConfig","ReactComponent","PermissionsIcon","Security","SecurityPermission","createElement","Permissions","name","title","description","icon","schema","prefix","fullAccess","entities","id","permission","scopes"],"sources":["SecurityPermission.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig } from \"@webiny/app-admin\";\nimport { ReactComponent as PermissionsIcon } from \"@webiny/icons/group.svg\";\n\nconst { Security } = AdminConfig;\n\nexport const SecurityPermission = () => {\n return (\n <AdminConfig>\n <Security.Permissions\n name=\"admin-users\"\n title=\"Admin Users\"\n description=\"Manage Admin Users permissions.\"\n icon={<PermissionsIcon />}\n schema={{\n prefix: \"adminUsers\",\n fullAccess: true,\n entities: [\n {\n id: \"user\",\n title: \"Users\",\n permission: \"adminUsers.user\",\n scopes: [\"full\"]\n }\n ]\n }}\n />\n </AdminConfig>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,cAAc,IAAIC,eAAe,QAAQ,yBAAyB;AAE3E,MAAM;EAAEC;AAAS,CAAC,GAAGH,WAAW;AAEhC,OAAO,MAAMI,kBAAkB,GAAGA,CAAA,KAAM;EACpC,oBACIL,KAAA,CAAAM,aAAA,CAACL,WAAW,qBACRD,KAAA,CAAAM,aAAA,CAACF,QAAQ,CAACG,WAAW;IACjBC,IAAI,EAAC,aAAa;IAClBC,KAAK,EAAC,aAAa;IACnBC,WAAW,EAAC,iCAAiC;IAC7CC,IAAI,eAAEX,KAAA,CAAAM,aAAA,CAACH,eAAe,MAAE,CAAE;IAC1BS,MAAM,EAAE;MACJC,MAAM,EAAE,YAAY;MACpBC,UAAU,EAAE,IAAI;MAChBC,QAAQ,EAAE,CACN;QACIC,EAAE,EAAE,MAAM;QACVP,KAAK,EAAE,OAAO;QACdQ,UAAU,EAAE,iBAAiB;QAC7BC,MAAM,EAAE,CAAC,MAAM;MACnB,CAAC;IAET;EAAE,CACL,CACQ,CAAC;AAEtB,CAAC","ignoreList":[]}
|
|
@@ -26,7 +26,7 @@ class CreateUserUseCaseImpl {
|
|
|
26
26
|
// Validate input (including password)
|
|
27
27
|
const validation = createAdminUserValidation.safeParse(input);
|
|
28
28
|
if (!validation.success) {
|
|
29
|
-
return Result.fail(new UserValidationError(validation.error.
|
|
29
|
+
return Result.fail(new UserValidationError(validation.error.issues[0].message));
|
|
30
30
|
}
|
|
31
31
|
const data = validation.data;
|
|
32
32
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","AdminUsersRepository","NotAuthorizedError","UserValidationError","IdentityContext","CreateUserUseCase","CoreCreateUser","ListUsersUseCase","UseCaseAbstraction","Username","CognitoAccountExistsError","CognitoCreateUserError","createAdminUserValidation","CognitoService","CreateUserUseCaseImpl","constructor","identityContext","cognitoService","createUserUseCase","listUsersUseCase","repository","execute","input","permission","getPermission","fail","validation","safeParse","success","error","
|
|
1
|
+
{"version":3,"names":["Result","AdminUsersRepository","NotAuthorizedError","UserValidationError","IdentityContext","CreateUserUseCase","CoreCreateUser","ListUsersUseCase","UseCaseAbstraction","Username","CognitoAccountExistsError","CognitoCreateUserError","createAdminUserValidation","CognitoService","CreateUserUseCaseImpl","constructor","identityContext","cognitoService","createUserUseCase","listUsersUseCase","repository","execute","input","permission","getPermission","fail","validation","safeParse","success","error","issues","message","data","password","userDataWithoutPassword","username","fromUser","existingUserResult","get","email","isOk","user","undefined","userExists","createUserResult","isFail","value","createUser","temporaryPassword","attributes","givenName","firstName","familyName","lastName","preferredUsername","customId","id","setEmailVerified","usersResult","console","users","length","setPermanentPassword","ok","cognitoError","delete","rollbackError","createImplementation","implementation","dependencies"],"sources":["CreateUserUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { AdminUsersRepository } from \"@webiny/api-core/features/users/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n UserValidationError\n} from \"@webiny/api-core/features/users/shared/errors.js\";\nimport type { AdminUser } from \"@webiny/api-core/types/users.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { CreateUserUseCase as CoreCreateUser } from \"@webiny/api-core/features/users/CreateUser/index.js\";\nimport { ListUsersUseCase } from \"@webiny/api-core/features/users/ListUsers/index.js\";\n\nimport { CreateUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { Username } from \"~/api/domain/Username.js\";\nimport { CognitoAccountExistsError, CognitoCreateUserError } from \"~/api/domain/errors.js\";\nimport { createAdminUserValidation } from \"./schema.js\";\nimport type { CreateAdminUserInput } from \"./abstractions.js\";\nimport { CognitoService } from \"~/api/features/CognitoService/index.js\";\n\nclass CreateUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private cognitoService: CognitoService.Interface,\n private createUserUseCase: CoreCreateUser.Interface,\n private listUsersUseCase: ListUsersUseCase.Interface,\n private repository: AdminUsersRepository.Interface\n ) {}\n\n async execute(\n input: CreateAdminUserInput\n ): Promise<Result<AdminUser, UseCaseAbstraction.Error>> {\n const permission = await this.identityContext.getPermission(\"adminUsers.user\");\n if (!permission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n // Validate input (including password)\n const validation = createAdminUserValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new UserValidationError(validation.error.issues[0].message));\n }\n\n const data = validation.data;\n const { password, ...userDataWithoutPassword } = data;\n\n const username = Username.fromUser(data);\n\n // Check if user exists in database (faster than Cognito check)\n const existingUserResult = await this.repository.get({ email: data.email });\n if (existingUserResult.isOk()) {\n return Result.fail(new CognitoAccountExistsError(data.email));\n }\n\n let user: AdminUser | undefined = undefined;\n\n try {\n // Check if user exists in Cognito\n const userExists = await this.cognitoService.userExists(username);\n if (userExists) {\n return Result.fail(new CognitoAccountExistsError(data.email));\n }\n // Create user in api-core\n const createUserResult = await this.createUserUseCase.execute(userDataWithoutPassword);\n if (createUserResult.isFail()) {\n return Result.fail(createUserResult.error);\n }\n\n user = createUserResult.value;\n\n // Create user in Cognito\n await this.cognitoService.createUser({\n username,\n temporaryPassword: password,\n attributes: {\n givenName: data.firstName,\n familyName: data.lastName,\n preferredUsername: username,\n email: username,\n customId: user.id\n }\n });\n\n // Set email as verified\n await this.cognitoService.setEmailVerified(username);\n\n // Check if this is the first user in the system, and if so, set permanent password\n const usersResult = await this.listUsersUseCase.execute();\n if (usersResult.isFail()) {\n // Log error but don't fail the operation\n console.error(`Failed to list users: ${usersResult.error.message}`);\n } else {\n const users = usersResult.value;\n if (users.length <= 1) {\n // This is the first user, set permanent password\n await this.cognitoService.setPermanentPassword(username, password);\n }\n }\n\n return Result.ok(user);\n } catch (cognitoError) {\n if (user) {\n // Rollback: Delete user from api-core if Cognito creation failed\n try {\n await this.repository.delete(user);\n } catch (rollbackError) {\n console.error(\"Failed to rollback user creation:\", rollbackError);\n }\n }\n return Result.fail(new CognitoCreateUserError(cognitoError as Error));\n }\n }\n}\n\nexport const CreateUserUseCase = UseCaseAbstraction.createImplementation({\n implementation: CreateUserUseCaseImpl,\n dependencies: [\n IdentityContext,\n CognitoService,\n CoreCreateUser,\n ListUsersUseCase,\n AdminUsersRepository\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,oBAAoB,QAAQ,wDAAwD;AAC7F,SACIC,kBAAkB,EAClBC,mBAAmB,QAChB,kDAAkD;AAEzD,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,iBAAiB,IAAIC,cAAc,QAAQ,qDAAqD;AACzG,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,SAASF,iBAAiB,IAAIG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,KAAK,CAAC,yBAAyB6B,WAAW,CAAC7B,KAAK,CAACE,OAAO,EAAE,CAAC;MACvE,CAAC,MAAM;QACH,MAAM6B,KAAK,GAAGF,WAAW,CAACZ,KAAK;QAC/B,IAAIc,KAAK,CAACC,MAAM,IAAI,CAAC,EAAE;UACnB;UACA,MAAM,IAAI,CAAC5C,cAAc,CAAC6C,oBAAoB,CAAC3B,QAAQ,EAAEF,QAAQ,CAAC;QACtE;MACJ;MAEA,OAAOjC,MAAM,CAAC+D,EAAE,CAACtB,IAAI,CAAC;IAC1B,CAAC,CAAC,OAAOuB,YAAY,EAAE;MACnB,IAAIvB,IAAI,EAAE;QACN;QACA,IAAI;UACA,MAAM,IAAI,CAACrB,UAAU,CAAC6C,MAAM,CAACxB,IAAI,CAAC;QACtC,CAAC,CAAC,OAAOyB,aAAa,EAAE;UACpBP,OAAO,CAAC9B,KAAK,CAAC,mCAAmC,EAAEqC,aAAa,CAAC;QACrE;MACJ;MACA,OAAOlE,MAAM,CAACyB,IAAI,CAAC,IAAId,sBAAsB,CAACqD,YAAqB,CAAC,CAAC;IACzE;EACJ;AACJ;AAEA,OAAO,MAAM3D,iBAAiB,GAAGG,kBAAkB,CAAC2D,oBAAoB,CAAC;EACrEC,cAAc,EAAEtD,qBAAqB;EACrCuD,YAAY,EAAE,CACVjE,eAAe,EACfS,cAAc,EACdP,cAAc,EACdC,gBAAgB,EAChBN,oBAAoB;AAE5B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,39 +9,7 @@ export declare const createAdminUserValidation: z.ZodObject<{
|
|
|
9
9
|
avatar: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
10
10
|
id: z.ZodString;
|
|
11
11
|
src: z.ZodString;
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
src: string;
|
|
17
|
-
id: string;
|
|
18
|
-
}>>>;
|
|
19
|
-
roles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
20
|
-
teams: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
21
|
-
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
roles: string[];
|
|
23
|
-
teams: string[];
|
|
24
|
-
email: string;
|
|
25
|
-
password: string;
|
|
26
|
-
displayName?: string | undefined;
|
|
27
|
-
id?: string | undefined;
|
|
28
|
-
firstName?: string | undefined;
|
|
29
|
-
lastName?: string | undefined;
|
|
30
|
-
avatar?: {
|
|
31
|
-
src: string;
|
|
32
|
-
id: string;
|
|
33
|
-
} | null | undefined;
|
|
34
|
-
}, {
|
|
35
|
-
email: string;
|
|
36
|
-
password: string;
|
|
37
|
-
displayName?: string | undefined;
|
|
38
|
-
id?: string | undefined;
|
|
39
|
-
roles?: string[] | undefined;
|
|
40
|
-
teams?: string[] | undefined;
|
|
41
|
-
firstName?: string | undefined;
|
|
42
|
-
lastName?: string | undefined;
|
|
43
|
-
avatar?: {
|
|
44
|
-
src: string;
|
|
45
|
-
id: string;
|
|
46
|
-
} | null | undefined;
|
|
47
|
-
}>;
|
|
12
|
+
}, z.core.$strip>>>;
|
|
13
|
+
roles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
14
|
+
teams: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
@@ -30,7 +30,7 @@ class UpdateUserUseCaseImpl {
|
|
|
30
30
|
// Validate input (including password)
|
|
31
31
|
const validation = updateAdminUserValidation.safeParse(input);
|
|
32
32
|
if (!validation.success) {
|
|
33
|
-
return Result.fail(new UserValidationError(validation.error.
|
|
33
|
+
return Result.fail(new UserValidationError(validation.error.issues[0].message));
|
|
34
34
|
}
|
|
35
35
|
const data = validation.data;
|
|
36
36
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","UpdateUserUseCase","CoreUpdateUser","GetUserUseCase","NotAuthorizedError","UserValidationError","IdentityContext","UseCaseAbstraction","Username","CognitoUpdateUserError","updateAdminUserValidation","CognitoService","defaultUpdateAttributes","family_name","given_name","preferred_username","UpdateUserUseCaseImpl","constructor","identityContext","cognitoService","updateUserUseCase","getUserUseCase","updateAttributes","execute","id","input","permission","getPermission","fail","validation","safeParse","success","error","
|
|
1
|
+
{"version":3,"names":["Result","UpdateUserUseCase","CoreUpdateUser","GetUserUseCase","NotAuthorizedError","UserValidationError","IdentityContext","UseCaseAbstraction","Username","CognitoUpdateUserError","updateAdminUserValidation","CognitoService","defaultUpdateAttributes","family_name","given_name","preferred_username","UpdateUserUseCaseImpl","constructor","identityContext","cognitoService","updateUserUseCase","getUserUseCase","updateAttributes","execute","id","input","permission","getPermission","fail","validation","safeParse","success","error","issues","message","data","password","userDataWithoutPassword","getUserResult","isFail","originalUser","value","updateUserResult","updatedUser","attributes","Object","keys","forEach","attr","mappedAttr","attrValue","email","updateUserAttributes","fromUser","setPermanentPassword","ok","cognitoError","createImplementation","implementation","dependencies"],"sources":["UpdateUserUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateUserUseCase as CoreUpdateUser } from \"@webiny/api-core/features/UpdateUser\";\nimport { GetUserUseCase } from \"@webiny/api-core/features/GetUser\";\nimport {\n NotAuthorizedError,\n UserValidationError\n} from \"@webiny/api-core/features/users/shared/errors.js\";\nimport type { AdminUser } from \"@webiny/api-core/types/users.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { UpdateUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { Username } from \"~/api/domain/Username.js\";\nimport { CognitoUpdateUserError } from \"~/api/domain/errors.js\";\nimport { updateAdminUserValidation } from \"./schema.js\";\nimport type { UpdateAdminUserInput } from \"./abstractions.js\";\nimport { CognitoService } from \"~/api/features/CognitoService/index.js\";\n\ntype MappedAttrType = (user: AdminUser) => string | keyof AdminUser;\n\nconst defaultUpdateAttributes = {\n family_name: \"lastName\",\n given_name: \"firstName\",\n preferred_username: \"email\"\n};\n\nclass UpdateUserUseCaseImpl implements UseCaseAbstraction.Interface {\n private updateAttributes: Record<string, string | MappedAttrType>;\n\n constructor(\n private identityContext: IdentityContext.Interface,\n private cognitoService: CognitoService.Interface,\n private updateUserUseCase: CoreUpdateUser.Interface,\n private getUserUseCase: GetUserUseCase.Interface\n ) {\n this.updateAttributes = defaultUpdateAttributes;\n }\n\n async execute(\n id: string,\n input: UpdateAdminUserInput\n ): Promise<Result<AdminUser, UseCaseAbstraction.Error>> {\n const permission = await this.identityContext.getPermission(\"adminUsers.user\");\n if (!permission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n // Validate input (including password)\n const validation = updateAdminUserValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new UserValidationError(validation.error.issues[0].message));\n }\n\n const data = validation.data;\n const { password, ...userDataWithoutPassword } = data;\n\n // Get original user to know the email before update\n const getUserResult = await this.getUserUseCase.execute({ id });\n if (getUserResult.isFail()) {\n return Result.fail(getUserResult.error);\n }\n\n const originalUser = getUserResult.value;\n\n // Update user in api-core\n const updateUserResult = await this.updateUserUseCase.execute(id, userDataWithoutPassword);\n if (updateUserResult.isFail()) {\n return Result.fail(updateUserResult.error);\n }\n\n const updatedUser = updateUserResult.value;\n\n // Update user in Cognito\n try {\n // Build new attributes\n const attributes: Record<string, string> = {};\n\n Object.keys(this.updateAttributes).forEach(attr => {\n const mappedAttr = this.updateAttributes[\n attr as keyof typeof this.updateAttributes\n ] as MappedAttrType;\n const attrValue =\n typeof mappedAttr === \"function\"\n ? mappedAttr(updatedUser)\n : updatedUser[mappedAttr];\n attributes[attr] = attrValue;\n });\n\n // If email changed, set email_verified to true\n if (originalUser.email !== updatedUser.email) {\n attributes[\"email_verified\"] = \"true\";\n }\n\n await this.cognitoService.updateUserAttributes(\n Username.fromUser(originalUser),\n attributes\n );\n\n // Update password if provided\n if (password) {\n await this.cognitoService.setPermanentPassword(\n Username.fromUser(updatedUser),\n password\n );\n }\n\n return Result.ok(updatedUser);\n } catch (cognitoError) {\n return Result.fail(new CognitoUpdateUserError(cognitoError as Error));\n }\n }\n}\n\nexport const UpdateUserUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateUserUseCaseImpl,\n dependencies: [IdentityContext, CognitoService, CoreUpdateUser, GetUserUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,iBAAiB,IAAIC,cAAc,QAAQ,sCAAsC;AAC1F,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SACIC,kBAAkB,EAClBC,mBAAmB,QAChB,kDAAkD;AAEzD,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASL,iBAAiB,IAAIM,kBAAkB;AAChD,SAASC,QAAQ;AACjB,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAElC,SAASC,cAAc;AAIvB,MAAMC,uBAAuB,GAAG;EAC5BC,WAAW,EAAE,UAAU;EACvBC,UAAU,EAAE,WAAW;EACvBC,kBAAkB,EAAE;AACxB,CAAC;AAED,MAAMC,qBAAqB,CAAyC;EAGhEC,WAAWA,CACCC,eAA0C,EAC1CC,cAAwC,EACxCC,iBAA2C,EAC3CC,cAAwC,EAClD;IAAA,KAJUH,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,iBAA2C,GAA3CA,iBAA2C;IAAA,KAC3CC,cAAwC,GAAxCA,cAAwC;IAEhD,IAAI,CAACC,gBAAgB,GAAGV,uBAAuB;EACnD;EAEA,MAAMW,OAAOA,CACTC,EAAU,EACVC,KAA2B,EACyB;IACpD,MAAMC,UAAU,GAAG,MAAM,IAAI,CAACR,eAAe,CAACS,aAAa,CAAC,iBAAiB,CAAC;IAC9E,IAAI,CAACD,UAAU,EAAE;MACb,OAAO1B,MAAM,CAAC4B,IAAI,CAAC,IAAIxB,kBAAkB,CAAC,CAAC,CAAC;IAChD;;IAEA;IACA,MAAMyB,UAAU,GAAGnB,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AU,CAACI,IAAI,CAAC,GAAGE,SAAS;MAChC,CAAC,CAAC;;MAEF;MACA,IAAIV,YAAY,CAACW,KAAK,KAAKR,WAAW,CAACQ,KAAK,EAAE;QAC1CP,UAAU,CAAC,gBAAgB,CAAC,GAAG,MAAM;MACzC;MAEA,MAAM,IAAI,CAACzB,cAAc,CAACiC,oBAAoB,CAC1C5C,QAAQ,CAAC6C,QAAQ,CAACb,YAAY,CAAC,EAC/BI,UACJ,CAAC;;MAED;MACA,IAAIR,QAAQ,EAAE;QACV,MAAM,IAAI,CAACjB,cAAc,CAACmC,oBAAoB,CAC1C9C,QAAQ,CAAC6C,QAAQ,CAACV,WAAW,CAAC,EAC9BP,QACJ,CAAC;MACL;MAEA,OAAOpC,MAAM,CAACuD,EAAE,CAACZ,WAAW,CAAC;IACjC,CAAC,CAAC,OAAOa,YAAY,EAAE;MACnB,OAAOxD,MAAM,CAAC4B,IAAI,CAAC,IAAInB,sBAAsB,CAAC+C,YAAqB,CAAC,CAAC;IACzE;EACJ;AACJ;AAEA,OAAO,MAAMvD,iBAAiB,GAAGM,kBAAkB,CAACkD,oBAAoB,CAAC;EACrEC,cAAc,EAAE1C,qBAAqB;EACrC2C,YAAY,EAAE,CAACrD,eAAe,EAAEK,cAAc,EAAET,cAAc,EAAEC,cAAc;AAClF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -8,37 +8,7 @@ export declare const updateAdminUserValidation: z.ZodObject<{
|
|
|
8
8
|
avatar: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
9
9
|
id: z.ZodString;
|
|
10
10
|
src: z.ZodString;
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
src: string;
|
|
16
|
-
id: string;
|
|
17
|
-
}>>>;
|
|
18
|
-
roles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
-
teams: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
displayName?: string | undefined;
|
|
22
|
-
roles?: string[] | undefined;
|
|
23
|
-
teams?: string[] | undefined;
|
|
24
|
-
firstName?: string | undefined;
|
|
25
|
-
lastName?: string | undefined;
|
|
26
|
-
email?: string | undefined;
|
|
27
|
-
avatar?: {
|
|
28
|
-
src: string;
|
|
29
|
-
id: string;
|
|
30
|
-
} | null | undefined;
|
|
31
|
-
password?: string | undefined;
|
|
32
|
-
}, {
|
|
33
|
-
displayName?: string | undefined;
|
|
34
|
-
roles?: string[] | undefined;
|
|
35
|
-
teams?: string[] | undefined;
|
|
36
|
-
firstName?: string | undefined;
|
|
37
|
-
lastName?: string | undefined;
|
|
38
|
-
email?: string | undefined;
|
|
39
|
-
avatar?: {
|
|
40
|
-
src: string;
|
|
41
|
-
id: string;
|
|
42
|
-
} | null | undefined;
|
|
43
|
-
password?: string | undefined;
|
|
44
|
-
}>;
|
|
11
|
+
}, z.core.$strip>>>;
|
|
12
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
teams: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cognito",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.c27f4d8a31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,41 +9,40 @@
|
|
|
9
9
|
"author": "Webiny Ltd.",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@apollo/react-hooks": "3.1.5",
|
|
12
|
-
"@aws-amplify/auth": "5.6.
|
|
13
|
-
"@webiny/admin-ui": "0.0.0-unstable.
|
|
14
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
15
|
-
"@webiny/app": "0.0.0-unstable.
|
|
16
|
-
"@webiny/app-admin": "0.0.0-unstable.
|
|
17
|
-
"@webiny/aws-sdk": "0.0.0-unstable.
|
|
12
|
+
"@aws-amplify/auth": "5.6.18",
|
|
13
|
+
"@webiny/admin-ui": "0.0.0-unstable.c27f4d8a31",
|
|
14
|
+
"@webiny/api-core": "0.0.0-unstable.c27f4d8a31",
|
|
15
|
+
"@webiny/app": "0.0.0-unstable.c27f4d8a31",
|
|
16
|
+
"@webiny/app-admin": "0.0.0-unstable.c27f4d8a31",
|
|
17
|
+
"@webiny/aws-sdk": "0.0.0-unstable.c27f4d8a31",
|
|
18
18
|
"@webiny/di": "*",
|
|
19
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
20
|
-
"@webiny/form": "0.0.0-unstable.
|
|
21
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
22
|
-
"@webiny/icons": "0.0.0-unstable.
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/project": "0.0.0-unstable.
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"
|
|
28
|
-
"graphql": "16.12.0",
|
|
19
|
+
"@webiny/feature": "0.0.0-unstable.c27f4d8a31",
|
|
20
|
+
"@webiny/form": "0.0.0-unstable.c27f4d8a31",
|
|
21
|
+
"@webiny/handler-graphql": "0.0.0-unstable.c27f4d8a31",
|
|
22
|
+
"@webiny/icons": "0.0.0-unstable.c27f4d8a31",
|
|
23
|
+
"@webiny/project": "0.0.0-unstable.c27f4d8a31",
|
|
24
|
+
"@webiny/project-aws": "0.0.0-unstable.c27f4d8a31",
|
|
25
|
+
"@webiny/ui": "0.0.0-unstable.c27f4d8a31",
|
|
26
|
+
"@webiny/validation": "0.0.0-unstable.c27f4d8a31",
|
|
27
|
+
"graphql": "16.13.1",
|
|
29
28
|
"graphql-tag": "2.12.6",
|
|
30
29
|
"jsonwebtoken": "9.0.3",
|
|
31
30
|
"lodash": "4.17.23",
|
|
32
31
|
"mobx": "6.15.0",
|
|
33
32
|
"mobx-react-lite": "3.4.3",
|
|
34
|
-
"react": "18.
|
|
35
|
-
"zod": "3.
|
|
33
|
+
"react": "18.3.1",
|
|
34
|
+
"zod": "4.3.6"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@types/react": "18.
|
|
39
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
40
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
41
|
-
"@webiny/wcp": "0.0.0-unstable.
|
|
42
|
-
"vitest": "
|
|
37
|
+
"@types/react": "18.3.28",
|
|
38
|
+
"@webiny/build-tools": "0.0.0-unstable.c27f4d8a31",
|
|
39
|
+
"@webiny/project-utils": "0.0.0-unstable.c27f4d8a31",
|
|
40
|
+
"@webiny/wcp": "0.0.0-unstable.c27f4d8a31",
|
|
41
|
+
"vitest": "4.0.18"
|
|
43
42
|
},
|
|
44
43
|
"publishConfig": {
|
|
45
44
|
"access": "public",
|
|
46
45
|
"directory": "dist"
|
|
47
46
|
},
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "c27f4d8a31c3af1570817797441855292b6c1f20"
|
|
49
48
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { Identity } from "@webiny/app-admin/domain/Identity.js";
|
|
3
|
-
export interface AdminUsersPermissionsProps {
|
|
4
|
-
value: Identity.Permission[];
|
|
5
|
-
onChange: (value: Identity.Permission[]) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare const AdminUsersPermissions: ({ value, onChange }: AdminUsersPermissionsProps) => React.JSX.Element;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import React, { Fragment, useCallback, useMemo } from "react";
|
|
2
|
-
import { Grid, Cell } from "@webiny/ui/Grid/index.js";
|
|
3
|
-
import { Select } from "@webiny/ui/Select/index.js";
|
|
4
|
-
import { i18n } from "@webiny/app/i18n/index.js";
|
|
5
|
-
import { CannotUseAaclAlert, PermissionInfo, gridWithPaddingClass, PermissionsGroup } from "@webiny/app-admin";
|
|
6
|
-
import { Form } from "@webiny/form";
|
|
7
|
-
import { useSecurity } from "@webiny/app-admin";
|
|
8
|
-
const t = i18n.ns("app-security-admin-users/plugins/permissionRenderer");
|
|
9
|
-
const ADMIN_USERS = "adminUsers";
|
|
10
|
-
const ADMIN_USERS_FULL_ACCESS = `${ADMIN_USERS}.*`;
|
|
11
|
-
const ADMIN_USERS_USER_ACCESS = `${ADMIN_USERS}.user`;
|
|
12
|
-
const FULL_ACCESS = "full";
|
|
13
|
-
const NO_ACCESS = "no";
|
|
14
|
-
const CUSTOM_ACCESS = "custom";
|
|
15
|
-
export const AdminUsersPermissions = ({
|
|
16
|
-
value,
|
|
17
|
-
onChange
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
getPermission
|
|
21
|
-
} = useSecurity();
|
|
22
|
-
|
|
23
|
-
// We disable form elements for custom permissions if AACL cannot be used.
|
|
24
|
-
const cannotUseAAcl = useMemo(() => {
|
|
25
|
-
return !getPermission("aacl", true);
|
|
26
|
-
}, []);
|
|
27
|
-
const onFormChange = useCallback(data => {
|
|
28
|
-
let newValue = [];
|
|
29
|
-
if (Array.isArray(value)) {
|
|
30
|
-
// Let's just filter out the `security*` permission objects, it's easier to build new ones from scratch.
|
|
31
|
-
newValue = value.filter(item => !item.name.startsWith(ADMIN_USERS));
|
|
32
|
-
}
|
|
33
|
-
const permissions = [];
|
|
34
|
-
if (data.accessLevel === FULL_ACCESS) {
|
|
35
|
-
permissions.push({
|
|
36
|
-
name: ADMIN_USERS_FULL_ACCESS
|
|
37
|
-
});
|
|
38
|
-
} else if (data.accessLevel === CUSTOM_ACCESS) {
|
|
39
|
-
if (data.userAccessScope === FULL_ACCESS) {
|
|
40
|
-
permissions.push({
|
|
41
|
-
name: ADMIN_USERS_USER_ACCESS
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (permissions && permissions.length) {
|
|
46
|
-
newValue.push(...permissions);
|
|
47
|
-
}
|
|
48
|
-
onChange(newValue);
|
|
49
|
-
}, [value]);
|
|
50
|
-
const formData = useMemo(() => {
|
|
51
|
-
if (!Array.isArray(value)) {
|
|
52
|
-
return {
|
|
53
|
-
accessLevel: NO_ACCESS
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const hasFullAccess = value.find(item => item.name === ADMIN_USERS_FULL_ACCESS || item.name === "*");
|
|
57
|
-
if (hasFullAccess) {
|
|
58
|
-
return {
|
|
59
|
-
accessLevel: FULL_ACCESS
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const permissions = value.filter(item => item.name.startsWith(ADMIN_USERS));
|
|
63
|
-
if (permissions.length === 0) {
|
|
64
|
-
return {
|
|
65
|
-
accessLevel: NO_ACCESS
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const data = {
|
|
69
|
-
accessLevel: CUSTOM_ACCESS,
|
|
70
|
-
userAccessScope: NO_ACCESS
|
|
71
|
-
};
|
|
72
|
-
const hasUserAccess = permissions.find(item => item.name === ADMIN_USERS_USER_ACCESS);
|
|
73
|
-
if (hasUserAccess) {
|
|
74
|
-
data.userAccessScope = FULL_ACCESS;
|
|
75
|
-
}
|
|
76
|
-
return data;
|
|
77
|
-
}, []);
|
|
78
|
-
return /*#__PURE__*/React.createElement(Form, {
|
|
79
|
-
data: formData,
|
|
80
|
-
onChange: onFormChange
|
|
81
|
-
}, ({
|
|
82
|
-
data,
|
|
83
|
-
Bind
|
|
84
|
-
}) => {
|
|
85
|
-
const disableUserAccessScope = data.groupAccessScope === NO_ACCESS;
|
|
86
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Grid, {
|
|
87
|
-
className: gridWithPaddingClass
|
|
88
|
-
}, /*#__PURE__*/React.createElement(Cell, {
|
|
89
|
-
span: 12
|
|
90
|
-
}, data.accessLevel === "custom" && cannotUseAAcl && /*#__PURE__*/React.createElement(CannotUseAaclAlert, null))), /*#__PURE__*/React.createElement(Grid, {
|
|
91
|
-
className: gridWithPaddingClass
|
|
92
|
-
}, /*#__PURE__*/React.createElement(Cell, {
|
|
93
|
-
span: 6
|
|
94
|
-
}, /*#__PURE__*/React.createElement(PermissionInfo, {
|
|
95
|
-
title: t`Access Level`
|
|
96
|
-
})), /*#__PURE__*/React.createElement(Cell, {
|
|
97
|
-
span: 6
|
|
98
|
-
}, /*#__PURE__*/React.createElement(Bind, {
|
|
99
|
-
name: "accessLevel"
|
|
100
|
-
}, /*#__PURE__*/React.createElement(Select, null, /*#__PURE__*/React.createElement("option", {
|
|
101
|
-
value: NO_ACCESS
|
|
102
|
-
}, t`No access`), /*#__PURE__*/React.createElement("option", {
|
|
103
|
-
value: FULL_ACCESS
|
|
104
|
-
}, t`Full access`), /*#__PURE__*/React.createElement("option", {
|
|
105
|
-
value: CUSTOM_ACCESS
|
|
106
|
-
}, t`Custom access`))))), data.accessLevel === CUSTOM_ACCESS && /*#__PURE__*/React.createElement("div", {
|
|
107
|
-
className: "mt-lg"
|
|
108
|
-
}, /*#__PURE__*/React.createElement(PermissionsGroup, {
|
|
109
|
-
title: t`Users`
|
|
110
|
-
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
|
|
111
|
-
span: 12
|
|
112
|
-
}, /*#__PURE__*/React.createElement(Bind, {
|
|
113
|
-
name: "userAccessScope"
|
|
114
|
-
}, ({
|
|
115
|
-
value,
|
|
116
|
-
...props
|
|
117
|
-
}) => /*#__PURE__*/React.createElement(Select, Object.assign({}, props, {
|
|
118
|
-
label: t`Access Scope`,
|
|
119
|
-
disabled: cannotUseAAcl || disableUserAccessScope,
|
|
120
|
-
value: disableUserAccessScope ? NO_ACCESS : value
|
|
121
|
-
}), /*#__PURE__*/React.createElement("option", {
|
|
122
|
-
value: NO_ACCESS
|
|
123
|
-
}, t`No access`), /*#__PURE__*/React.createElement("option", {
|
|
124
|
-
value: FULL_ACCESS
|
|
125
|
-
}, t`Full access`))))))));
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
//# sourceMappingURL=AdminUsersPermissions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","Fragment","useCallback","useMemo","Grid","Cell","Select","i18n","CannotUseAaclAlert","PermissionInfo","gridWithPaddingClass","PermissionsGroup","Form","useSecurity","t","ns","ADMIN_USERS","ADMIN_USERS_FULL_ACCESS","ADMIN_USERS_USER_ACCESS","FULL_ACCESS","NO_ACCESS","CUSTOM_ACCESS","AdminUsersPermissions","value","onChange","getPermission","cannotUseAAcl","onFormChange","data","newValue","Array","isArray","filter","item","name","startsWith","permissions","accessLevel","push","userAccessScope","length","formData","hasFullAccess","find","hasUserAccess","createElement","Bind","disableUserAccessScope","groupAccessScope","className","span","title","props","Object","assign","label","disabled"],"sources":["AdminUsersPermissions.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport { Grid, Cell } from \"@webiny/ui/Grid/index.js\";\nimport { Select } from \"@webiny/ui/Select/index.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport {\n CannotUseAaclAlert,\n PermissionInfo,\n gridWithPaddingClass,\n PermissionsGroup,\n type AaclPermission\n} from \"@webiny/app-admin\";\nimport { Form } from \"@webiny/form\";\nimport { useSecurity } from \"@webiny/app-admin\";\nimport type { Identity } from \"@webiny/app-admin/domain/Identity.js\";\n\nconst t = i18n.ns(\"app-security-admin-users/plugins/permissionRenderer\");\n\nconst ADMIN_USERS = \"adminUsers\";\nconst ADMIN_USERS_FULL_ACCESS = `${ADMIN_USERS}.*`;\nconst ADMIN_USERS_USER_ACCESS = `${ADMIN_USERS}.user`;\nconst FULL_ACCESS = \"full\";\nconst NO_ACCESS = \"no\";\nconst CUSTOM_ACCESS = \"custom\";\n\nexport interface AdminUsersPermissionsProps {\n value: Identity.Permission[];\n onChange: (value: Identity.Permission[]) => void;\n}\n\ninterface OnFormChangeCallable {\n (data: Identity.Permission): void;\n}\n\nexport const AdminUsersPermissions = ({ value, onChange }: AdminUsersPermissionsProps) => {\n const { getPermission } = useSecurity();\n\n // We disable form elements for custom permissions if AACL cannot be used.\n const cannotUseAAcl = useMemo(() => {\n return !getPermission<AaclPermission>(\"aacl\", true);\n }, []);\n\n const onFormChange = useCallback<OnFormChangeCallable>(\n data => {\n let newValue: Identity.Permission[] = [];\n if (Array.isArray(value)) {\n // Let's just filter out the `security*` permission objects, it's easier to build new ones from scratch.\n newValue = value.filter(item => !item.name.startsWith(ADMIN_USERS));\n }\n\n const permissions = [];\n if (data.accessLevel === FULL_ACCESS) {\n permissions.push({ name: ADMIN_USERS_FULL_ACCESS });\n } else if (data.accessLevel === CUSTOM_ACCESS) {\n if (data.userAccessScope === FULL_ACCESS) {\n permissions.push({ name: ADMIN_USERS_USER_ACCESS });\n }\n }\n\n if (permissions && permissions.length) {\n newValue.push(...permissions);\n }\n\n onChange(newValue);\n },\n [value]\n );\n\n const formData = useMemo(() => {\n if (!Array.isArray(value)) {\n return { accessLevel: NO_ACCESS };\n }\n\n const hasFullAccess = value.find(\n item => item.name === ADMIN_USERS_FULL_ACCESS || item.name === \"*\"\n );\n\n if (hasFullAccess) {\n return { accessLevel: FULL_ACCESS };\n }\n\n const permissions = value.filter(item => item.name.startsWith(ADMIN_USERS));\n if (permissions.length === 0) {\n return { accessLevel: NO_ACCESS };\n }\n\n const data = {\n accessLevel: CUSTOM_ACCESS,\n userAccessScope: NO_ACCESS\n };\n\n const hasUserAccess = permissions.find(item => item.name === ADMIN_USERS_USER_ACCESS);\n if (hasUserAccess) {\n data.userAccessScope = FULL_ACCESS;\n }\n\n return data;\n }, []);\n\n return (\n <Form data={formData} onChange={onFormChange}>\n {({ data, Bind }) => {\n const disableUserAccessScope = data.groupAccessScope === NO_ACCESS;\n return (\n <Fragment>\n <Grid className={gridWithPaddingClass}>\n <Cell span={12}>\n {data.accessLevel === \"custom\" && cannotUseAAcl && (\n <CannotUseAaclAlert />\n )}\n </Cell>\n </Grid>\n <Grid className={gridWithPaddingClass}>\n <Cell span={6}>\n <PermissionInfo title={t`Access Level`} />\n </Cell>\n <Cell span={6}>\n <Bind name={\"accessLevel\"}>\n <Select>\n <option value={NO_ACCESS}>{t`No access`}</option>\n <option value={FULL_ACCESS}>{t`Full access`}</option>\n <option value={CUSTOM_ACCESS}>{t`Custom access`}</option>\n </Select>\n </Bind>\n </Cell>\n </Grid>\n {data.accessLevel === CUSTOM_ACCESS && (\n <div className={\"mt-lg\"}>\n <PermissionsGroup title={t`Users`}>\n <Grid>\n <Cell span={12}>\n <Bind name={\"userAccessScope\"}>\n {({ value, ...props }) => (\n <Select\n {...props}\n label={t`Access Scope`}\n disabled={\n cannotUseAAcl || disableUserAccessScope\n }\n value={\n disableUserAccessScope\n ? NO_ACCESS\n : value\n }\n >\n <option\n value={NO_ACCESS}\n >{t`No access`}</option>\n <option\n value={FULL_ACCESS}\n >{t`Full access`}</option>\n </Select>\n )}\n </Bind>\n </Cell>\n </Grid>\n </PermissionsGroup>\n </div>\n )}\n </Fragment>\n );\n }}\n </Form>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC7D,SAASC,IAAI,EAAEC,IAAI,QAAQ,0BAA0B;AACrD,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,IAAI,QAAQ,2BAA2B;AAChD,SACIC,kBAAkB,EAClBC,cAAc,EACdC,oBAAoB,EACpBC,gBAAgB,QAEb,mBAAmB;AAC1B,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,WAAW,QAAQ,mBAAmB;AAG/C,MAAMC,CAAC,GAAGP,IAAI,CAACQ,EAAE,CAAC,qDAAqD,CAAC;AAExE,MAAMC,WAAW,GAAG,YAAY;AAChC,MAAMC,uBAAuB,GAAG,GAAGD,WAAW,IAAI;AAClD,MAAME,uBAAuB,GAAG,GAAGF,WAAW,OAAO;AACrD,MAAMG,WAAW,GAAG,MAAM;AAC1B,MAAMC,SAAS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,KAAA,CAAA6C,aAAA,CAACvC,MAAM,EAAA+C,MAAA,CAAAC,MAAA,KACCF,KAAK;MACTG,KAAK,EAAEzC,CAAC,cAAe;MACvB0C,QAAQ,EACJ9B,aAAa,IAAIqB,sBACpB;MACDxB,KAAK,EACDwB,sBAAsB,GAChB3B,SAAS,GACTG;IACT,iBAEDvB,KAAA,CAAA6C,aAAA;MACItB,KAAK,EAAEH;IAAU,GACnBN,CAAC,WAAoB,CAAC,eACxBd,KAAA,CAAA6C,aAAA;MACItB,KAAK,EAAEJ;IAAY,GACrBL,CAAC,aAAsB,CACrB,CAEV,CACJ,CACJ,CACQ,CACjB,CAEH,CAAC;EAEnB,CACE,CAAC;AAEf,CAAC","ignoreList":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Accordion } from "@webiny/admin-ui";
|
|
3
|
-
import { ReactComponent as PermissionsIcon } from "@webiny/icons/group.svg";
|
|
4
|
-
import { AdminUsersPermissions } from "./AdminUsersPermissions.js";
|
|
5
|
-
import { PermissionRendererPlugin } from "@webiny/app-admin/plugins/PermissionRendererPlugin.js";
|
|
6
|
-
export default new PermissionRendererPlugin({
|
|
7
|
-
render(props) {
|
|
8
|
-
return /*#__PURE__*/React.createElement(Accordion.Item, {
|
|
9
|
-
icon: /*#__PURE__*/React.createElement(Accordion.Item.Icon, {
|
|
10
|
-
icon: /*#__PURE__*/React.createElement(PermissionsIcon, null),
|
|
11
|
-
label: "Admin Users Permissions"
|
|
12
|
-
}),
|
|
13
|
-
title: `Admin Users`,
|
|
14
|
-
description: `Manage Admin Users access permissions.`,
|
|
15
|
-
"data-testid": "permission.adminUsers"
|
|
16
|
-
}, /*#__PURE__*/React.createElement(AdminUsersPermissions, props));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","Accordion","ReactComponent","PermissionsIcon","AdminUsersPermissions","PermissionRendererPlugin","render","props","createElement","Item","icon","Icon","label","title","description"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport { Accordion } from \"@webiny/admin-ui\";\nimport { ReactComponent as PermissionsIcon } from \"@webiny/icons/group.svg\";\nimport { AdminUsersPermissions } from \"./AdminUsersPermissions.js\";\nimport { PermissionRendererPlugin } from \"@webiny/app-admin/plugins/PermissionRendererPlugin.js\";\n\nexport default new PermissionRendererPlugin({\n render(props) {\n return (\n <Accordion.Item\n icon={\n <Accordion.Item.Icon\n icon={<PermissionsIcon />}\n label={\"Admin Users Permissions\"}\n />\n }\n title={`Admin Users`}\n description={`Manage Admin Users access permissions.`}\n data-testid={\"permission.adminUsers\"}\n >\n <AdminUsersPermissions {...props} />\n </Accordion.Item>\n );\n }\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,cAAc,IAAIC,eAAe,QAAQ,yBAAyB;AAC3E,SAASC,qBAAqB;AAC9B,SAASC,wBAAwB,QAAQ,uDAAuD;AAEhG,eAAe,IAAIA,wBAAwB,CAAC;EACxCC,MAAMA,CAACC,KAAK,EAAE;IACV,oBACIP,KAAA,CAAAQ,aAAA,CAACP,SAAS,CAACQ,IAAI;MACXC,IAAI,eACAV,KAAA,CAAAQ,aAAA,CAACP,SAAS,CAACQ,IAAI,CAACE,IAAI;QAChBD,IAAI,eAAEV,KAAA,CAAAQ,aAAA,CAACL,eAAe,MAAE,CAAE;QAC1BS,KAAK,EAAE;MAA0B,CACpC,CACJ;MACDC,KAAK,EAAE,aAAc;MACrBC,WAAW,EAAE,wCAAyC;MACtD,eAAa;IAAwB,gBAErCd,KAAA,CAAAQ,aAAA,CAACJ,qBAAqB,EAAKG,KAAQ,CACvB,CAAC;EAEzB;AACJ,CAAC,CAAC","ignoreList":[]}
|