@strapi/plugin-users-permissions 0.0.0-next.d08e60ce27fb0ebcae796c0c29862c4135d1acb8 → 0.0.0-next.d0bd7aa4c25bfb448b93a62f3d47db9b6fdd8ee3

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.
Files changed (156) hide show
  1. package/.eslintignore +1 -2
  2. package/.eslintrc +17 -0
  3. package/admin/src/index.js +5 -15
  4. package/admin/src/pages/Roles/pages/{CreatePage.js → CreatePage.jsx} +11 -2
  5. package/admin/src/pages/Roles/pages/{EditPage.js → EditPage.jsx} +11 -2
  6. package/dist/_chunks/ar-MvD8Ghac.mjs +44 -0
  7. package/dist/_chunks/ar-MvD8Ghac.mjs.map +1 -0
  8. package/dist/_chunks/ar-t5qTFaAD.js +44 -0
  9. package/dist/_chunks/ar-t5qTFaAD.js.map +1 -0
  10. package/dist/_chunks/cs-BMuXwxA1.mjs +50 -0
  11. package/dist/_chunks/cs-BMuXwxA1.mjs.map +1 -0
  12. package/dist/_chunks/cs-I8N4u-Sd.js +50 -0
  13. package/dist/_chunks/cs-I8N4u-Sd.js.map +1 -0
  14. package/dist/_chunks/de-YTjtq89K.js +62 -0
  15. package/dist/_chunks/de-YTjtq89K.js.map +1 -0
  16. package/dist/_chunks/de-zs2qqc0W.mjs +62 -0
  17. package/dist/_chunks/de-zs2qqc0W.mjs.map +1 -0
  18. package/dist/_chunks/dk-HctVBMsG.mjs +86 -0
  19. package/dist/_chunks/dk-HctVBMsG.mjs.map +1 -0
  20. package/dist/_chunks/dk-TF-dWjzl.js +86 -0
  21. package/dist/_chunks/dk-TF-dWjzl.js.map +1 -0
  22. package/dist/_chunks/en-CE3wEy_c.mjs +86 -0
  23. package/dist/_chunks/en-CE3wEy_c.mjs.map +1 -0
  24. package/dist/_chunks/en-m608rMZx.js +86 -0
  25. package/dist/_chunks/en-m608rMZx.js.map +1 -0
  26. package/dist/_chunks/es-9381tih_.mjs +86 -0
  27. package/dist/_chunks/es-9381tih_.mjs.map +1 -0
  28. package/dist/_chunks/es-XBQsB8_9.js +86 -0
  29. package/dist/_chunks/es-XBQsB8_9.js.map +1 -0
  30. package/dist/_chunks/fr-6cz3U-IF.js +50 -0
  31. package/dist/_chunks/fr-6cz3U-IF.js.map +1 -0
  32. package/dist/_chunks/fr-CMSc77If.mjs +50 -0
  33. package/dist/_chunks/fr-CMSc77If.mjs.map +1 -0
  34. package/dist/_chunks/id-RJ934rq-.js +62 -0
  35. package/dist/_chunks/id-RJ934rq-.js.map +1 -0
  36. package/dist/_chunks/id-SDuyIkZa.mjs +62 -0
  37. package/dist/_chunks/id-SDuyIkZa.mjs.map +1 -0
  38. package/dist/_chunks/index-0Vc-UWcV.js +249 -0
  39. package/dist/_chunks/index-0Vc-UWcV.js.map +1 -0
  40. package/dist/_chunks/index-4Vr0bnMf.mjs +385 -0
  41. package/dist/_chunks/index-4Vr0bnMf.mjs.map +1 -0
  42. package/dist/_chunks/index-9piswtke.mjs +301 -0
  43. package/dist/_chunks/index-9piswtke.mjs.map +1 -0
  44. package/dist/_chunks/index-A0iXYUYF.mjs +615 -0
  45. package/dist/_chunks/index-A0iXYUYF.mjs.map +1 -0
  46. package/dist/_chunks/index-F4BN074l.mjs +250 -0
  47. package/dist/_chunks/index-F4BN074l.mjs.map +1 -0
  48. package/dist/_chunks/index-NUzEflvS.js +320 -0
  49. package/dist/_chunks/index-NUzEflvS.js.map +1 -0
  50. package/dist/_chunks/index-RsjaHQhm.mjs +1159 -0
  51. package/dist/_chunks/index-RsjaHQhm.mjs.map +1 -0
  52. package/dist/_chunks/index-WmKXywmF.js +638 -0
  53. package/dist/_chunks/index-WmKXywmF.js.map +1 -0
  54. package/dist/_chunks/index-iRrIhpCY.js +407 -0
  55. package/dist/_chunks/index-iRrIhpCY.js.map +1 -0
  56. package/dist/_chunks/index-qfsD2498.js +1191 -0
  57. package/dist/_chunks/index-qfsD2498.js.map +1 -0
  58. package/dist/_chunks/it-YhZOlM2X.js +62 -0
  59. package/dist/_chunks/it-YhZOlM2X.js.map +1 -0
  60. package/dist/_chunks/it-bvH7DgQo.mjs +62 -0
  61. package/dist/_chunks/it-bvH7DgQo.mjs.map +1 -0
  62. package/dist/_chunks/ja-o_-JPvQv.mjs +48 -0
  63. package/dist/_chunks/ja-o_-JPvQv.mjs.map +1 -0
  64. package/dist/_chunks/ja-xssHUXFv.js +48 -0
  65. package/dist/_chunks/ja-xssHUXFv.js.map +1 -0
  66. package/dist/_chunks/ko-C3mHUSJa.js +86 -0
  67. package/dist/_chunks/ko-C3mHUSJa.js.map +1 -0
  68. package/dist/_chunks/ko-XJbPSez_.mjs +86 -0
  69. package/dist/_chunks/ko-XJbPSez_.mjs.map +1 -0
  70. package/dist/_chunks/ms-II5Ea73J.mjs +49 -0
  71. package/dist/_chunks/ms-II5Ea73J.mjs.map +1 -0
  72. package/dist/_chunks/ms-d0hfg65Z.js +49 -0
  73. package/dist/_chunks/ms-d0hfg65Z.js.map +1 -0
  74. package/dist/_chunks/nl-TA7TfK_5.js +48 -0
  75. package/dist/_chunks/nl-TA7TfK_5.js.map +1 -0
  76. package/dist/_chunks/nl-vEy6TN0K.mjs +48 -0
  77. package/dist/_chunks/nl-vEy6TN0K.mjs.map +1 -0
  78. package/dist/_chunks/pl-0pUL9hdA.js +86 -0
  79. package/dist/_chunks/pl-0pUL9hdA.js.map +1 -0
  80. package/dist/_chunks/pl-2VowaFGt.mjs +86 -0
  81. package/dist/_chunks/pl-2VowaFGt.mjs.map +1 -0
  82. package/dist/_chunks/pt-BR-WNOhafR4.js +44 -0
  83. package/dist/_chunks/pt-BR-WNOhafR4.js.map +1 -0
  84. package/dist/_chunks/pt-BR-sS1Xp3Jt.mjs +44 -0
  85. package/dist/_chunks/pt-BR-sS1Xp3Jt.mjs.map +1 -0
  86. package/dist/_chunks/pt-Rf9W51IO.mjs +48 -0
  87. package/dist/_chunks/pt-Rf9W51IO.mjs.map +1 -0
  88. package/dist/_chunks/pt-guNR9Gax.js +48 -0
  89. package/dist/_chunks/pt-guNR9Gax.js.map +1 -0
  90. package/dist/_chunks/ru-X3BMXDds.js +86 -0
  91. package/dist/_chunks/ru-X3BMXDds.js.map +1 -0
  92. package/dist/_chunks/ru-qKHnd5or.mjs +86 -0
  93. package/dist/_chunks/ru-qKHnd5or.mjs.map +1 -0
  94. package/dist/_chunks/sk-NWPw1oTN.js +50 -0
  95. package/dist/_chunks/sk-NWPw1oTN.js.map +1 -0
  96. package/dist/_chunks/sk-_Ryr-eTT.mjs +50 -0
  97. package/dist/_chunks/sk-_Ryr-eTT.mjs.map +1 -0
  98. package/dist/_chunks/sv-76NnbB__.js +86 -0
  99. package/dist/_chunks/sv-76NnbB__.js.map +1 -0
  100. package/dist/_chunks/sv-BqzScFXS.mjs +86 -0
  101. package/dist/_chunks/sv-BqzScFXS.mjs.map +1 -0
  102. package/dist/_chunks/th-WsknMEpq.mjs +60 -0
  103. package/dist/_chunks/th-WsknMEpq.mjs.map +1 -0
  104. package/dist/_chunks/th-cbppX21D.js +60 -0
  105. package/dist/_chunks/th-cbppX21D.js.map +1 -0
  106. package/dist/_chunks/tr-6mm_Fmz7.js +85 -0
  107. package/dist/_chunks/tr-6mm_Fmz7.js.map +1 -0
  108. package/dist/_chunks/tr-_DB1F1GW.mjs +85 -0
  109. package/dist/_chunks/tr-_DB1F1GW.mjs.map +1 -0
  110. package/dist/_chunks/uk-sI2I1ogF.js +49 -0
  111. package/dist/_chunks/uk-sI2I1ogF.js.map +1 -0
  112. package/dist/_chunks/uk-yxMSQAwI.mjs +49 -0
  113. package/dist/_chunks/uk-yxMSQAwI.mjs.map +1 -0
  114. package/dist/_chunks/vi-A3zJxaiI.js +50 -0
  115. package/dist/_chunks/vi-A3zJxaiI.js.map +1 -0
  116. package/dist/_chunks/vi-xY0zCW3d.mjs +50 -0
  117. package/dist/_chunks/vi-xY0zCW3d.mjs.map +1 -0
  118. package/dist/_chunks/zh-72SpmFXa.js +86 -0
  119. package/dist/_chunks/zh-72SpmFXa.js.map +1 -0
  120. package/dist/_chunks/zh-Hans-ArWWtyP4.js +86 -0
  121. package/dist/_chunks/zh-Hans-ArWWtyP4.js.map +1 -0
  122. package/dist/_chunks/zh-Hans-E84cu4kP.mjs +86 -0
  123. package/dist/_chunks/zh-Hans-E84cu4kP.mjs.map +1 -0
  124. package/dist/_chunks/zh-OFeldzbX.mjs +86 -0
  125. package/dist/_chunks/zh-OFeldzbX.mjs.map +1 -0
  126. package/dist/admin/index.js +5 -0
  127. package/dist/admin/index.js.map +1 -0
  128. package/dist/admin/index.mjs +6 -0
  129. package/dist/admin/index.mjs.map +1 -0
  130. package/package.json +34 -14
  131. package/packup.config.ts +22 -0
  132. package/server/bootstrap/grant-config.js +9 -0
  133. package/server/bootstrap/index.js +36 -0
  134. package/server/controllers/auth.js +51 -14
  135. package/server/controllers/user.js +12 -1
  136. package/server/services/providers-registry.js +15 -0
  137. package/.eslintrc.js +0 -14
  138. package/strapi-admin.js +0 -3
  139. /package/admin/src/components/BoundRoute/{index.js → index.jsx} +0 -0
  140. /package/admin/src/components/FormModal/Input/{index.js → index.jsx} +0 -0
  141. /package/admin/src/components/FormModal/{index.js → index.jsx} +0 -0
  142. /package/admin/src/components/Permissions/PermissionRow/{CheckboxWrapper.js → CheckboxWrapper.jsx} +0 -0
  143. /package/admin/src/components/Permissions/PermissionRow/{SubCategory.js → SubCategory.jsx} +0 -0
  144. /package/admin/src/components/Permissions/PermissionRow/{index.js → index.jsx} +0 -0
  145. /package/admin/src/components/Permissions/{index.js → index.jsx} +0 -0
  146. /package/admin/src/components/Policies/{index.js → index.jsx} +0 -0
  147. /package/admin/src/components/UsersPermissions/{index.js → index.jsx} +0 -0
  148. /package/admin/src/contexts/UsersPermissionsContext/{index.js → index.jsx} +0 -0
  149. /package/admin/src/pages/AdvancedSettings/{index.js → index.jsx} +0 -0
  150. /package/admin/src/pages/EmailTemplates/components/{EmailForm.js → EmailForm.jsx} +0 -0
  151. /package/admin/src/pages/EmailTemplates/components/{EmailTable.js → EmailTable.jsx} +0 -0
  152. /package/admin/src/pages/EmailTemplates/{index.js → index.jsx} +0 -0
  153. /package/admin/src/pages/Providers/{index.js → index.jsx} +0 -0
  154. /package/admin/src/pages/Roles/{index.js → index.jsx} +0 -0
  155. /package/admin/src/pages/Roles/pages/ListPage/components/{TableBody.js → TableBody.jsx} +0 -0
  156. /package/admin/src/pages/Roles/pages/ListPage/{index.js → index.jsx} +0 -0
@@ -9,7 +9,11 @@
9
9
  /* eslint-disable no-useless-escape */
10
10
  const crypto = require('crypto');
11
11
  const _ = require('lodash');
12
+ const { concat, compact, isArray } = require('lodash/fp');
12
13
  const utils = require('@strapi/utils');
14
+ const {
15
+ contentTypes: { getNonWritableAttributes },
16
+ } = require('@strapi/utils');
13
17
  const { getService } = require('../utils');
14
18
  const {
15
19
  validateCallbackBody,
@@ -22,7 +26,7 @@ const {
22
26
  } = require('./validation/auth');
23
27
 
24
28
  const { getAbsoluteAdminUrl, getAbsoluteServerUrl, sanitize } = utils;
25
- const { ApplicationError, ValidationError } = utils.errors;
29
+ const { ApplicationError, ValidationError, ForbiddenError } = utils.errors;
26
30
 
27
31
  const sanitizeUser = (user, ctx) => {
28
32
  const { auth } = ctx.state;
@@ -96,6 +100,10 @@ module.exports = {
96
100
  try {
97
101
  const user = await getService('providers').connect(provider, ctx.query);
98
102
 
103
+ if (user.blocked) {
104
+ throw new ForbiddenError('Your account has been blocked by an administrator');
105
+ }
106
+
99
107
  return ctx.send({
100
108
  jwt: getService('jwt').issue({ id: user.id }),
101
109
  user: await sanitizeUser(user, ctx),
@@ -273,20 +281,49 @@ module.exports = {
273
281
  throw new ApplicationError('Register action is currently disabled');
274
282
  }
275
283
 
284
+ const { register } = strapi.config.get('plugin.users-permissions');
285
+ const alwaysAllowedKeys = ['username', 'password', 'email'];
286
+ const userModel = strapi.contentTypes['plugin::users-permissions.user'];
287
+ const { attributes } = userModel;
288
+
289
+ const nonWritable = getNonWritableAttributes(userModel);
290
+
291
+ const allowedKeys = compact(
292
+ concat(
293
+ alwaysAllowedKeys,
294
+ isArray(register?.allowedFields)
295
+ ? // Note that we do not filter allowedFields in case a user explicitly chooses to allow a private or otherwise omitted field on registration
296
+ register.allowedFields // if null or undefined, compact will remove it
297
+ : // to prevent breaking changes, if allowedFields is not set in config, we only remove private and known dangerous user schema fields
298
+ // TODO V5: allowedFields defaults to [] when undefined and remove this case
299
+ Object.keys(attributes).filter(
300
+ (key) =>
301
+ !nonWritable.includes(key) &&
302
+ !attributes[key].private &&
303
+ ![
304
+ // many of these are included in nonWritable, but we'll list them again to be safe and since we're removing this code in v5 anyway
305
+ // Strapi user schema fields
306
+ 'confirmed',
307
+ 'blocked',
308
+ 'confirmationToken',
309
+ 'resetPasswordToken',
310
+ 'provider',
311
+ 'id',
312
+ 'role',
313
+ // other Strapi fields that might be added
314
+ 'createdAt',
315
+ 'updatedAt',
316
+ 'createdBy',
317
+ 'updatedBy',
318
+ 'publishedAt', // d&p
319
+ 'strapi_reviewWorkflows_stage', // review workflows
320
+ ].includes(key)
321
+ )
322
+ )
323
+ );
324
+
276
325
  const params = {
277
- ..._.omit(ctx.request.body, [
278
- 'confirmed',
279
- 'blocked',
280
- 'confirmationToken',
281
- 'resetPasswordToken',
282
- 'provider',
283
- 'id',
284
- 'createdAt',
285
- 'updatedAt',
286
- 'createdBy',
287
- 'updatedBy',
288
- 'role',
289
- ]),
326
+ ..._.pick(ctx.request.body, allowedKeys),
290
327
  provider: 'local',
291
328
  };
292
329
 
@@ -11,7 +11,7 @@ const utils = require('@strapi/utils');
11
11
  const { getService } = require('../utils');
12
12
  const { validateCreateUserBody, validateUpdateUserBody } = require('./validation/user');
13
13
 
14
- const { sanitize } = utils;
14
+ const { sanitize, validate } = utils;
15
15
  const { ApplicationError, ValidationError, NotFoundError } = utils.errors;
16
16
 
17
17
  const sanitizeOutput = async (user, ctx) => {
@@ -21,6 +21,13 @@ const sanitizeOutput = async (user, ctx) => {
21
21
  return sanitize.contentAPI.output(user, schema, { auth });
22
22
  };
23
23
 
24
+ const validateQuery = async (query, ctx) => {
25
+ const schema = strapi.getModel('plugin::users-permissions.user');
26
+ const { auth } = ctx.state;
27
+
28
+ return validate.contentAPI.query(query, schema, { auth });
29
+ };
30
+
24
31
  const sanitizeQuery = async (query, ctx) => {
25
32
  const schema = strapi.getModel('plugin::users-permissions.user');
26
33
  const { auth } = ctx.state;
@@ -143,6 +150,7 @@ module.exports = {
143
150
  * @return {Object|Array}
144
151
  */
145
152
  async find(ctx) {
153
+ await validateQuery(ctx.query, ctx);
146
154
  const sanitizedQuery = await sanitizeQuery(ctx.query, ctx);
147
155
  const users = await getService('user').fetchAll(sanitizedQuery);
148
156
 
@@ -155,6 +163,7 @@ module.exports = {
155
163
  */
156
164
  async findOne(ctx) {
157
165
  const { id } = ctx.params;
166
+ await validateQuery(ctx.query, ctx);
158
167
  const sanitizedQuery = await sanitizeQuery(ctx.query, ctx);
159
168
 
160
169
  let data = await getService('user').fetch(id, sanitizedQuery);
@@ -171,6 +180,7 @@ module.exports = {
171
180
  * @return {Number}
172
181
  */
173
182
  async count(ctx) {
183
+ await validateQuery(ctx.query, ctx);
174
184
  const sanitizedQuery = await sanitizeQuery(ctx.query, ctx);
175
185
 
176
186
  ctx.body = await getService('user').count(sanitizedQuery);
@@ -201,6 +211,7 @@ module.exports = {
201
211
  return ctx.unauthorized();
202
212
  }
203
213
 
214
+ await validateQuery(query, ctx);
204
215
  const sanitizedQuery = await sanitizeQuery(query, ctx);
205
216
  const user = await getService('user').fetch(authUser.id, sanitizedQuery);
206
217
 
@@ -331,6 +331,21 @@ const getInitialProviders = ({ purest }) => ({
331
331
  };
332
332
  });
333
333
  },
334
+ async keycloak({ accessToken, providers }) {
335
+ const keycloak = purest({ provider: 'keycloak' });
336
+
337
+ return keycloak
338
+ .subdomain(providers.keycloak.subdomain)
339
+ .get('protocol/openid-connect/userinfo')
340
+ .auth(accessToken)
341
+ .request()
342
+ .then(({ body }) => {
343
+ return {
344
+ username: body.preferred_username,
345
+ email: body.email,
346
+ };
347
+ });
348
+ },
334
349
  });
335
350
 
336
351
  module.exports = () => {
package/.eslintrc.js DELETED
@@ -1,14 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- overrides: [
4
- {
5
- files: ['admin/**/*'],
6
- extends: ['custom/front'],
7
- },
8
- {
9
- files: ['**/*'],
10
- excludedFiles: ['admin/**/*'],
11
- extends: ['custom/back'],
12
- },
13
- ],
14
- };
package/strapi-admin.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = require('./admin/src').default;
File without changes