@strapi/plugin-users-permissions 5.56.0 → 5.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/controllers/auth.js +8 -8
- package/dist/server/controllers/auth.js.map +1 -1
- package/dist/server/controllers/auth.mjs +8 -7
- package/dist/server/controllers/auth.mjs.map +1 -1
- package/dist/server/controllers/validation/email-template.js +1 -4
- package/dist/server/controllers/validation/email-template.js.map +1 -1
- package/dist/server/controllers/validation/email-template.mjs +1 -3
- package/dist/server/controllers/validation/email-template.mjs.map +1 -1
- package/dist/server/graphql/mutations/auth/change-password.js +1 -1
- package/dist/server/graphql/mutations/auth/change-password.js.map +1 -1
- package/dist/server/graphql/mutations/auth/change-password.mjs +1 -1
- package/dist/server/graphql/mutations/auth/change-password.mjs.map +1 -1
- package/dist/server/graphql/mutations/auth/email-confirmation.js +1 -1
- package/dist/server/graphql/mutations/auth/email-confirmation.js.map +1 -1
- package/dist/server/graphql/mutations/auth/email-confirmation.mjs +1 -1
- package/dist/server/graphql/mutations/auth/email-confirmation.mjs.map +1 -1
- package/dist/server/graphql/mutations/auth/forgot-password.js +1 -1
- package/dist/server/graphql/mutations/auth/forgot-password.js.map +1 -1
- package/dist/server/graphql/mutations/auth/forgot-password.mjs +1 -1
- package/dist/server/graphql/mutations/auth/forgot-password.mjs.map +1 -1
- package/dist/server/graphql/mutations/auth/login.js +1 -1
- package/dist/server/graphql/mutations/auth/login.js.map +1 -1
- package/dist/server/graphql/mutations/auth/login.mjs +1 -1
- package/dist/server/graphql/mutations/auth/login.mjs.map +1 -1
- package/dist/server/graphql/mutations/auth/register.js +1 -1
- package/dist/server/graphql/mutations/auth/register.js.map +1 -1
- package/dist/server/graphql/mutations/auth/register.mjs +1 -1
- package/dist/server/graphql/mutations/auth/register.mjs.map +1 -1
- package/dist/server/graphql/mutations/auth/reset-password.js +1 -1
- package/dist/server/graphql/mutations/auth/reset-password.js.map +1 -1
- package/dist/server/graphql/mutations/auth/reset-password.mjs +1 -1
- package/dist/server/graphql/mutations/auth/reset-password.mjs.map +1 -1
- package/dist/server/graphql/mutations/crud/role/create-role.js +1 -1
- package/dist/server/graphql/mutations/crud/role/create-role.js.map +1 -1
- package/dist/server/graphql/mutations/crud/role/create-role.mjs +1 -1
- package/dist/server/graphql/mutations/crud/role/create-role.mjs.map +1 -1
- package/dist/server/graphql/mutations/crud/user/create-user.js +1 -1
- package/dist/server/graphql/mutations/crud/user/create-user.js.map +1 -1
- package/dist/server/graphql/mutations/crud/user/create-user.mjs +1 -1
- package/dist/server/graphql/mutations/crud/user/create-user.mjs.map +1 -1
- package/dist/server/graphql/mutations/crud/user/update-user.js +1 -1
- package/dist/server/graphql/mutations/crud/user/update-user.js.map +1 -1
- package/dist/server/graphql/mutations/crud/user/update-user.mjs +1 -1
- package/dist/server/graphql/mutations/crud/user/update-user.mjs.map +1 -1
- package/dist/server/graphql/utils.js +4 -4
- package/dist/server/graphql/utils.js.map +1 -1
- package/dist/server/graphql/utils.mjs +4 -4
- package/dist/server/graphql/utils.mjs.map +1 -1
- package/dist/server/middlewares/rateLimit.js +4 -4
- package/dist/server/middlewares/rateLimit.js.map +1 -1
- package/dist/server/middlewares/rateLimit.mjs +4 -4
- package/dist/server/middlewares/rateLimit.mjs.map +1 -1
- package/dist/server/services/providers-registry.js +3 -3
- package/dist/server/services/providers-registry.mjs +2 -2
- package/dist/server/services/providers.js +3 -3
- package/dist/server/services/providers.mjs +2 -2
- package/dist/server/services/user.js +9 -9
- package/dist/server/services/user.js.map +1 -1
- package/dist/server/services/user.mjs +8 -8
- package/dist/server/services/user.mjs.map +1 -1
- package/dist/server/services/users-permissions.js +6 -9
- package/dist/server/services/users-permissions.js.map +1 -1
- package/dist/server/services/users-permissions.mjs +5 -7
- package/dist/server/services/users-permissions.mjs.map +1 -1
- package/dist/server/strategies/users-permissions.js +8 -7
- package/dist/server/strategies/users-permissions.js.map +1 -1
- package/dist/server/strategies/users-permissions.mjs +8 -7
- package/dist/server/strategies/users-permissions.mjs.map +1 -1
- package/dist/server/utils/sanitize/sanitizers.js +1 -1
- package/dist/server/utils/sanitize/sanitizers.js.map +1 -1
- package/dist/server/utils/sanitize/sanitizers.mjs +1 -1
- package/dist/server/utils/sanitize/sanitizers.mjs.map +1 -1
- package/package.json +4 -4
- package/server/src/controllers/auth.js +4 -4
- package/server/src/controllers/validation/email-template.js +1 -2
- package/server/src/graphql/mutations/auth/change-password.js +1 -1
- package/server/src/graphql/mutations/auth/email-confirmation.js +1 -1
- package/server/src/graphql/mutations/auth/forgot-password.js +1 -1
- package/server/src/graphql/mutations/auth/login.js +1 -1
- package/server/src/graphql/mutations/auth/register.js +1 -1
- package/server/src/graphql/mutations/auth/reset-password.js +1 -1
- package/server/src/graphql/mutations/crud/role/create-role.js +1 -1
- package/server/src/graphql/mutations/crud/user/create-user.js +1 -1
- package/server/src/graphql/mutations/crud/user/update-user.js +1 -1
- package/server/src/graphql/utils.js +3 -3
- package/server/src/middlewares/rateLimit.js +3 -3
- package/server/src/services/user.js +3 -3
- package/server/src/services/users-permissions.js +3 -5
- package/server/src/strategies/users-permissions.js +13 -9
- package/server/src/utils/sanitize/sanitizers.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { get } = require('lodash');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Throws an ApolloError if context body contains a bad request
|
|
@@ -8,10 +8,10 @@ const { getOr } = require('lodash/fp');
|
|
|
8
8
|
* @throws ApolloError if the body is a bad request
|
|
9
9
|
*/
|
|
10
10
|
function checkBadRequest(contextBody) {
|
|
11
|
-
const statusCode =
|
|
11
|
+
const statusCode = get(contextBody, 'statusCode', 200);
|
|
12
12
|
|
|
13
13
|
if (statusCode !== 200) {
|
|
14
|
-
const errorMessage =
|
|
14
|
+
const errorMessage = get(contextBody, 'error', 'Bad Request');
|
|
15
15
|
|
|
16
16
|
const exception = new Error(errorMessage);
|
|
17
17
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const utils = require('@strapi/utils');
|
|
5
|
-
const { isString, has
|
|
5
|
+
const { toLower, isString, has } = require('lodash');
|
|
6
6
|
|
|
7
7
|
const { RateLimitError } = utils.errors;
|
|
8
8
|
|
|
@@ -47,7 +47,7 @@ const routeUsesEmailIdentifier = (requestPath) => {
|
|
|
47
47
|
*/
|
|
48
48
|
const normalizeRequestPathForRateLimit = (requestPath) => {
|
|
49
49
|
const normalized = path.posix.normalize(requestPath);
|
|
50
|
-
const lower =
|
|
50
|
+
const lower = normalized.toLowerCase();
|
|
51
51
|
return lower.replace(/\/+$/, '') || '/';
|
|
52
52
|
};
|
|
53
53
|
|
|
@@ -102,7 +102,7 @@ module.exports =
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
if (!has('enabled'
|
|
105
|
+
if (!has(rateLimitConfig, 'enabled')) {
|
|
106
106
|
rateLimitConfig.enabled = true;
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -11,12 +11,12 @@ const bcrypt = require('bcryptjs');
|
|
|
11
11
|
const urlJoin = require('url-join');
|
|
12
12
|
|
|
13
13
|
const { sanitize, ALLOWED_QUERY_PARAM_KEYS } = require('@strapi/utils');
|
|
14
|
-
const {
|
|
14
|
+
const { pick, get, toNumber } = require('lodash');
|
|
15
15
|
const { getService } = require('../utils');
|
|
16
16
|
|
|
17
17
|
const USER_MODEL_UID = 'plugin::users-permissions.user';
|
|
18
18
|
|
|
19
|
-
const pickAllowedQueryParams = pick(ALLOWED_QUERY_PARAM_KEYS);
|
|
19
|
+
const pickAllowedQueryParams = (params) => pick(params, ALLOWED_QUERY_PARAM_KEYS);
|
|
20
20
|
|
|
21
21
|
const getSessionManager = () => {
|
|
22
22
|
const manager = strapi.sessionManager;
|
|
@@ -52,7 +52,7 @@ module.exports = ({ strapi }) => ({
|
|
|
52
52
|
for (const key in values) {
|
|
53
53
|
if (attributes[key] && attributes[key].type === 'password') {
|
|
54
54
|
// Check if a custom encryption.rounds has been set on the password attribute
|
|
55
|
-
const rounds = toNumber(
|
|
55
|
+
const rounds = toNumber(get(attributes[key], 'encryption.rounds', 10));
|
|
56
56
|
values[key] = await bcrypt.hash(values[key], rounds);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
|
-
const { filter, map, pipe, prop } = require('lodash/fp');
|
|
5
4
|
const urlJoin = require('url-join');
|
|
6
5
|
const {
|
|
7
6
|
template: { createStrictInterpolationRegExp },
|
|
@@ -193,10 +192,9 @@ module.exports = ({ strapi }) => ({
|
|
|
193
192
|
if (permissionsFoundInDB.length === 0) {
|
|
194
193
|
// create default permissions
|
|
195
194
|
for (const role of roles) {
|
|
196
|
-
const toCreate =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
)(DEFAULT_PERMISSIONS);
|
|
195
|
+
const toCreate = DEFAULT_PERMISSIONS.filter(
|
|
196
|
+
({ roleType }) => roleType === role.type || roleType === null
|
|
197
|
+
).map(({ action }) => action);
|
|
200
198
|
|
|
201
199
|
await Promise.all(
|
|
202
200
|
toCreate.map((action) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { map, every } = require('lodash');
|
|
4
4
|
const { ForbiddenError, UnauthorizedError } = require('@strapi/utils').errors;
|
|
5
5
|
|
|
6
6
|
const { getService } = require('../utils');
|
|
@@ -43,7 +43,11 @@ const authenticate = async (ctx) => {
|
|
|
43
43
|
// Fetch user's permissions
|
|
44
44
|
const permissions = await Promise.resolve(user.role.id)
|
|
45
45
|
.then(getService('permission').findRolePermissions)
|
|
46
|
-
.then(
|
|
46
|
+
.then((permissions) =>
|
|
47
|
+
map(permissions, (permission) =>
|
|
48
|
+
getService('permission').toContentAPIPermission(permission)
|
|
49
|
+
)
|
|
50
|
+
);
|
|
47
51
|
|
|
48
52
|
// Generate an ability (content API engine) based on the given permissions
|
|
49
53
|
const ability = await strapi.contentAPI.permissions.engine.generateAbility(permissions);
|
|
@@ -64,7 +68,11 @@ const authenticate = async (ctx) => {
|
|
|
64
68
|
|
|
65
69
|
const publicPermissions = await getService('permission')
|
|
66
70
|
.findPublicPermissions()
|
|
67
|
-
.then(
|
|
71
|
+
.then((permissions) =>
|
|
72
|
+
map(permissions, (permission) =>
|
|
73
|
+
getService('permission').toContentAPIPermission(permission)
|
|
74
|
+
)
|
|
75
|
+
);
|
|
68
76
|
|
|
69
77
|
if (publicPermissions.length === 0) {
|
|
70
78
|
return { authenticated: false };
|
|
@@ -100,12 +108,8 @@ const verify = async (auth, config) => {
|
|
|
100
108
|
throw new UnauthorizedError();
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
castArray,
|
|
106
|
-
// Transform the scope array into an action array
|
|
107
|
-
every((scope) => ability.can(scope))
|
|
108
|
-
)(config.scope);
|
|
111
|
+
const scopes = Array.isArray(config.scope) ? config.scope : [config.scope];
|
|
112
|
+
const isAllowed = every(scopes, (scope) => ability.can(scope));
|
|
109
113
|
|
|
110
114
|
if (!isAllowed) {
|
|
111
115
|
throw new ForbiddenError();
|