@strapi/plugin-users-permissions 4.0.0-beta.15 → 4.0.0-beta.19
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/admin/src/components/Permissions/index.js +8 -7
- package/admin/src/components/Policies/index.js +5 -2
- package/admin/src/components/UsersPermissions/index.js +5 -8
- package/admin/src/pages/Roles/ListPage/index.js +2 -0
- package/package.json +28 -27
- package/server/bootstrap/index.js +0 -3
- package/server/controllers/auth.js +9 -1
- package/server/services/providers.js +10 -9
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useReducer } from 'react';
|
|
2
2
|
import { Accordion, AccordionToggle, AccordionContent } from '@strapi/design-system/Accordion';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
import { Box } from '@strapi/design-system/Box';
|
|
5
|
+
import { Stack } from '@strapi/design-system/Stack';
|
|
5
6
|
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
|
6
7
|
import formatPluginName from '../../utils/formatPluginName';
|
|
7
8
|
import PermissionRow from './PermissionRow';
|
|
@@ -15,20 +16,20 @@ const Permissions = () => {
|
|
|
15
16
|
init(state, modifiedData)
|
|
16
17
|
);
|
|
17
18
|
|
|
18
|
-
const handleToggle =
|
|
19
|
+
const handleToggle = index =>
|
|
19
20
|
dispatch({
|
|
20
21
|
type: 'TOGGLE_COLLAPSE',
|
|
21
22
|
index,
|
|
22
23
|
});
|
|
23
|
-
}, []);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
|
|
26
|
+
<Stack size={1}>
|
|
27
27
|
{collapses.map((collapse, index) => (
|
|
28
28
|
<Accordion
|
|
29
29
|
expanded={collapse.isOpen}
|
|
30
30
|
toggle={() => handleToggle(index)}
|
|
31
31
|
key={collapse.name}
|
|
32
|
+
variant={index % 2 === 0 ? 'secondary' : undefined}
|
|
32
33
|
>
|
|
33
34
|
<AccordionToggle
|
|
34
35
|
title={formatPluginName(collapse.name)}
|
|
@@ -42,14 +43,14 @@ const Permissions = () => {
|
|
|
42
43
|
variant={index % 2 ? 'primary' : 'secondary'}
|
|
43
44
|
/>
|
|
44
45
|
<AccordionContent>
|
|
45
|
-
<Box
|
|
46
|
+
<Box>
|
|
46
47
|
<PermissionRow permissions={modifiedData[collapse.name]} name={collapse.name} />
|
|
47
48
|
</Box>
|
|
48
49
|
</AccordionContent>
|
|
49
50
|
</Accordion>
|
|
50
51
|
))}
|
|
51
|
-
|
|
52
|
+
</Stack>
|
|
52
53
|
);
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
export default
|
|
56
|
+
export default Permissions;
|
|
@@ -3,18 +3,21 @@ import { useIntl } from 'react-intl';
|
|
|
3
3
|
import { Typography } from '@strapi/design-system/Typography';
|
|
4
4
|
import { Stack } from '@strapi/design-system/Stack';
|
|
5
5
|
import { GridItem } from '@strapi/design-system/Grid';
|
|
6
|
-
import { get, isEmpty,
|
|
6
|
+
import { get, isEmpty, without } from 'lodash';
|
|
7
7
|
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
|
8
8
|
import BoundRoute from '../BoundRoute';
|
|
9
9
|
|
|
10
10
|
const Policies = () => {
|
|
11
11
|
const { formatMessage } = useIntl();
|
|
12
12
|
const { selectedAction, routes } = useUsersPermissions();
|
|
13
|
+
|
|
13
14
|
const path = without(selectedAction.split('.'), 'controllers');
|
|
14
15
|
const controllerRoutes = get(routes, path[0]);
|
|
16
|
+
const pathResolved = path.slice(1).join('.');
|
|
17
|
+
|
|
15
18
|
const displayedRoutes = isEmpty(controllerRoutes)
|
|
16
19
|
? []
|
|
17
|
-
: controllerRoutes.filter(o =>
|
|
20
|
+
: controllerRoutes.filter(o => o.handler.endsWith(pathResolved));
|
|
18
21
|
|
|
19
22
|
return (
|
|
20
23
|
<GridItem
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useReducer,
|
|
1
|
+
import React, { memo, useReducer, forwardRef, useImperativeHandle } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Typography } from '@strapi/design-system/Typography';
|
|
4
4
|
import { Stack } from '@strapi/design-system/Stack';
|
|
@@ -31,28 +31,25 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
|
|
|
31
31
|
},
|
|
32
32
|
}));
|
|
33
33
|
|
|
34
|
-
const handleChange =
|
|
34
|
+
const handleChange = ({ target: { name, value } }) =>
|
|
35
35
|
dispatch({
|
|
36
36
|
type: 'ON_CHANGE',
|
|
37
37
|
keys: name.split('.'),
|
|
38
38
|
value: value === 'empty__string_value' ? '' : value,
|
|
39
39
|
});
|
|
40
|
-
}, []);
|
|
41
40
|
|
|
42
|
-
const handleChangeSelectAll =
|
|
41
|
+
const handleChangeSelectAll = ({ target: { name, value } }) =>
|
|
43
42
|
dispatch({
|
|
44
43
|
type: 'ON_CHANGE_SELECT_ALL',
|
|
45
44
|
keys: name.split('.'),
|
|
46
45
|
value,
|
|
47
46
|
});
|
|
48
|
-
}, []);
|
|
49
47
|
|
|
50
|
-
const handleSelectedAction =
|
|
48
|
+
const handleSelectedAction = actionToSelect =>
|
|
51
49
|
dispatch({
|
|
52
50
|
type: 'SELECT_ACTION',
|
|
53
51
|
actionToSelect,
|
|
54
52
|
});
|
|
55
|
-
}, []);
|
|
56
53
|
|
|
57
54
|
const providerValue = {
|
|
58
55
|
...state,
|
|
@@ -65,7 +62,7 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
|
|
|
65
62
|
<UsersPermissionsProvider value={providerValue}>
|
|
66
63
|
<Grid gap={0} shadow="filterShadow" hasRadius background="neutral0">
|
|
67
64
|
<GridItem col={7} paddingTop={6} paddingBottom={6} paddingLeft={7} paddingRight={7}>
|
|
68
|
-
<Stack size={
|
|
65
|
+
<Stack size={6}>
|
|
69
66
|
<Stack size={2}>
|
|
70
67
|
<Typography variant="delta" as="h2">
|
|
71
68
|
{formatMessage({
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
NoPermissions,
|
|
17
17
|
LoadingIndicatorPage,
|
|
18
18
|
SearchURLQuery,
|
|
19
|
+
useFocusWhenNavigate,
|
|
19
20
|
useQueryParams,
|
|
20
21
|
EmptyStateLayout,
|
|
21
22
|
ConfirmDialog,
|
|
@@ -42,6 +43,7 @@ const RoleListPage = () => {
|
|
|
42
43
|
const [showConfirmDelete, setShowConfirmDelete] = useState(false);
|
|
43
44
|
const [isConfirmButtonLoading, setIsConfirmButtonLoading] = useState(false);
|
|
44
45
|
const [roleToDelete, setRoleToDelete] = useState();
|
|
46
|
+
useFocusWhenNavigate();
|
|
45
47
|
|
|
46
48
|
const queryClient = useQueryClient();
|
|
47
49
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-users-permissions",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.19",
|
|
4
4
|
"description": "Protect your API with a full-authentication process based on JWT",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"description": "Protect your API with a full authentication process based on JWT. This plugin comes also with an ACL strategy that allows you to manage the permissions between the groups of users.",
|
|
9
|
-
"required": true,
|
|
10
|
-
"kind": "plugin"
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git://github.com/strapi/strapi.git"
|
|
11
8
|
},
|
|
9
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Strapi Solutions SAS",
|
|
12
|
+
"email": "hi@strapi.io",
|
|
13
|
+
"url": "https://strapi.io"
|
|
14
|
+
},
|
|
15
|
+
"maintainers": [
|
|
16
|
+
{
|
|
17
|
+
"name": "Strapi Solutions SAS",
|
|
18
|
+
"email": "hi@strapi.io",
|
|
19
|
+
"url": "https://strapi.io"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
12
22
|
"scripts": {
|
|
13
23
|
"test": "echo \"no tests yet\""
|
|
14
24
|
},
|
|
15
25
|
"dependencies": {
|
|
16
26
|
"@purest/providers": "^1.0.2",
|
|
17
|
-
"@strapi/helper-plugin": "4.0.0-beta.
|
|
18
|
-
"@strapi/utils": "4.0.0-beta.
|
|
27
|
+
"@strapi/helper-plugin": "4.0.0-beta.19",
|
|
28
|
+
"@strapi/utils": "4.0.0-beta.19",
|
|
19
29
|
"bcryptjs": "2.4.3",
|
|
20
30
|
"grant-koa": "5.4.8",
|
|
21
31
|
"jsonwebtoken": "^8.1.0",
|
|
@@ -30,31 +40,22 @@
|
|
|
30
40
|
"react-router-dom": "5.2.0",
|
|
31
41
|
"redux-saga": "^0.16.0",
|
|
32
42
|
"request": "^2.83.0",
|
|
43
|
+
"url-join": "4.0.1",
|
|
33
44
|
"uuid": "^3.1.0"
|
|
34
45
|
},
|
|
35
46
|
"devDependencies": {
|
|
36
47
|
"koa": "^2.13.1"
|
|
37
48
|
},
|
|
38
|
-
"author": {
|
|
39
|
-
"name": "Strapi team",
|
|
40
|
-
"email": "hi@strapi.io",
|
|
41
|
-
"url": "https://strapi.io"
|
|
42
|
-
},
|
|
43
|
-
"maintainers": [
|
|
44
|
-
{
|
|
45
|
-
"name": "Strapi team",
|
|
46
|
-
"email": "hi@strapi.io",
|
|
47
|
-
"url": "https://strapi.io"
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
"repository": {
|
|
51
|
-
"type": "git",
|
|
52
|
-
"url": "git://github.com/strapi/strapi.git"
|
|
53
|
-
},
|
|
54
49
|
"engines": {
|
|
55
50
|
"node": ">=12.x.x <=16.x.x",
|
|
56
51
|
"npm": ">=6.0.0"
|
|
57
52
|
},
|
|
58
|
-
"
|
|
59
|
-
|
|
53
|
+
"strapi": {
|
|
54
|
+
"displayName": "Roles & Permissions",
|
|
55
|
+
"name": "users-permissions",
|
|
56
|
+
"description": "Protect your API with a full authentication process based on JWT. This plugin comes also with an ACL strategy that allows you to manage the permissions between the groups of users.",
|
|
57
|
+
"required": true,
|
|
58
|
+
"kind": "plugin"
|
|
59
|
+
},
|
|
60
|
+
"gitHead": "6e0f2052136c7d337d72b944cd0564d4559896d0"
|
|
60
61
|
}
|
|
@@ -162,10 +162,18 @@ module.exports = {
|
|
|
162
162
|
async connect(ctx, next) {
|
|
163
163
|
const grant = require('grant-koa');
|
|
164
164
|
|
|
165
|
-
const
|
|
165
|
+
const providers = await strapi
|
|
166
166
|
.store({ type: 'plugin', name: 'users-permissions', key: 'grant' })
|
|
167
167
|
.get();
|
|
168
168
|
|
|
169
|
+
const apiPrefix = strapi.config.get('api.rest.prefix');
|
|
170
|
+
const grantConfig = {
|
|
171
|
+
defaults: {
|
|
172
|
+
prefix: `${apiPrefix}/connect`,
|
|
173
|
+
},
|
|
174
|
+
...providers,
|
|
175
|
+
};
|
|
176
|
+
|
|
169
177
|
const [requestPath] = ctx.request.url.split('?');
|
|
170
178
|
const provider = requestPath.split('/connect/')[1].split('/')[0];
|
|
171
179
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// Public node modules.
|
|
8
8
|
const _ = require('lodash');
|
|
9
9
|
const jwt = require('jsonwebtoken');
|
|
10
|
+
const urlJoin = require('url-join');
|
|
10
11
|
|
|
11
12
|
const { getAbsoluteServerUrl } = require('@strapi/utils');
|
|
12
13
|
|
|
@@ -27,7 +28,7 @@ module.exports = ({ strapi }) => {
|
|
|
27
28
|
const getProfile = async (provider, query, callback) => {
|
|
28
29
|
const access_token = query.access_token || query.code || query.oauth_token;
|
|
29
30
|
|
|
30
|
-
const
|
|
31
|
+
const providers = await strapi
|
|
31
32
|
.store({ type: 'plugin', name: 'users-permissions', key: 'grant' })
|
|
32
33
|
.get();
|
|
33
34
|
|
|
@@ -200,8 +201,8 @@ module.exports = ({ strapi }) => {
|
|
|
200
201
|
const twitter = purest({
|
|
201
202
|
provider: 'twitter',
|
|
202
203
|
config: purestConfig,
|
|
203
|
-
key:
|
|
204
|
-
secret:
|
|
204
|
+
key: providers.twitter.key,
|
|
205
|
+
secret: providers.twitter.secret,
|
|
205
206
|
});
|
|
206
207
|
|
|
207
208
|
twitter
|
|
@@ -224,8 +225,8 @@ module.exports = ({ strapi }) => {
|
|
|
224
225
|
case 'instagram': {
|
|
225
226
|
const instagram = purest({
|
|
226
227
|
provider: 'instagram',
|
|
227
|
-
key:
|
|
228
|
-
secret:
|
|
228
|
+
key: providers.instagram.key,
|
|
229
|
+
secret: providers.instagram.secret,
|
|
229
230
|
config: purestConfig,
|
|
230
231
|
});
|
|
231
232
|
|
|
@@ -297,7 +298,7 @@ module.exports = ({ strapi }) => {
|
|
|
297
298
|
|
|
298
299
|
twitch
|
|
299
300
|
.get('users')
|
|
300
|
-
.auth(access_token,
|
|
301
|
+
.auth(access_token, providers.twitch.key)
|
|
301
302
|
.request((err, res, body) => {
|
|
302
303
|
if (err) {
|
|
303
304
|
callback(err);
|
|
@@ -402,7 +403,7 @@ module.exports = ({ strapi }) => {
|
|
|
402
403
|
}
|
|
403
404
|
case 'auth0': {
|
|
404
405
|
const purestAuth0Conf = {};
|
|
405
|
-
purestAuth0Conf[`https://${
|
|
406
|
+
purestAuth0Conf[`https://${providers.auth0.subdomain}.auth0.com`] = {
|
|
406
407
|
__domain: {
|
|
407
408
|
auth: {
|
|
408
409
|
auth: { bearer: '[0]' },
|
|
@@ -441,7 +442,7 @@ module.exports = ({ strapi }) => {
|
|
|
441
442
|
break;
|
|
442
443
|
}
|
|
443
444
|
case 'cas': {
|
|
444
|
-
const provider_url = 'https://' + _.get(
|
|
445
|
+
const provider_url = 'https://' + _.get(providers.cas, 'subdomain');
|
|
445
446
|
const cas = purest({
|
|
446
447
|
provider: 'cas',
|
|
447
448
|
config: {
|
|
@@ -588,7 +589,7 @@ module.exports = ({ strapi }) => {
|
|
|
588
589
|
|
|
589
590
|
const buildRedirectUri = (provider = '') => {
|
|
590
591
|
const apiPrefix = strapi.config.get('api.rest.prefix');
|
|
591
|
-
return
|
|
592
|
+
return urlJoin(getAbsoluteServerUrl(strapi.config), apiPrefix, 'connect', provider, 'callback');
|
|
592
593
|
};
|
|
593
594
|
|
|
594
595
|
return {
|