@strapi/plugin-users-permissions 4.0.0-beta.17 → 4.0.0-beta.20

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.
@@ -2,6 +2,7 @@ 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';
@@ -22,12 +23,13 @@ const Permissions = () => {
22
23
  });
23
24
 
24
25
  return (
25
- <>
26
+ <Stack size={1}>
26
27
  {collapses.map((collapse, index) => (
27
28
  <Accordion
28
29
  expanded={collapse.isOpen}
29
30
  toggle={() => handleToggle(index)}
30
31
  key={collapse.name}
32
+ variant={index % 2 === 0 ? 'secondary' : undefined}
31
33
  >
32
34
  <AccordionToggle
33
35
  title={formatPluginName(collapse.name)}
@@ -41,13 +43,13 @@ const Permissions = () => {
41
43
  variant={index % 2 ? 'primary' : 'secondary'}
42
44
  />
43
45
  <AccordionContent>
44
- <Box background="neutral0">
46
+ <Box>
45
47
  <PermissionRow permissions={modifiedData[collapse.name]} name={collapse.name} />
46
48
  </Box>
47
49
  </AccordionContent>
48
50
  </Accordion>
49
51
  ))}
50
- </>
52
+ </Stack>
51
53
  );
52
54
  };
53
55
 
@@ -62,7 +62,7 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
62
62
  <UsersPermissionsProvider value={providerValue}>
63
63
  <Grid gap={0} shadow="filterShadow" hasRadius background="neutral0">
64
64
  <GridItem col={7} paddingTop={6} paddingBottom={6} paddingLeft={7} paddingRight={7}>
65
- <Stack size={4}>
65
+ <Stack size={6}>
66
66
  <Stack size={2}>
67
67
  <Typography variant="delta" as="h2">
68
68
  {formatMessage({
@@ -6,7 +6,7 @@
6
6
  "security": [],
7
7
  "externalDocs": {
8
8
  "description": "Find out more in the strapi's documentation",
9
- "url": "https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#registration"
9
+ "url": "https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#registration"
10
10
  },
11
11
  "responses": {
12
12
  "200": {
@@ -58,7 +58,7 @@
58
58
  "security": [],
59
59
  "externalDocs": {
60
60
  "description": "Find out more in the strapi's documentation",
61
- "url": "https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#email-validation"
61
+ "url": "https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#email-validation"
62
62
  },
63
63
  "responses": {
64
64
  "200": {
@@ -130,7 +130,7 @@
130
130
  ],
131
131
  "externalDocs": {
132
132
  "description": "Find out more about the authentication flow in the strapi documentation",
133
- "url": "https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#setting-up-the-provider-examples"
133
+ "url": "https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#providers"
134
134
  },
135
135
  "responses": {
136
136
  "200": {
@@ -143,7 +143,7 @@
143
143
  "post": {
144
144
  "externalDocs": {
145
145
  "description": "Find out more in the strapi's documentation",
146
- "url": "https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#login"
146
+ "url": "https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#login"
147
147
  },
148
148
  "tags": ["Authentication"],
149
149
  "security": [],
@@ -188,7 +188,7 @@
188
188
  "tags": ["Authentication"],
189
189
  "externalDocs": {
190
190
  "description": "Find out more in the strapi's documentation",
191
- "url": "https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#setting-up-the-provider-examples"
191
+ "url": "https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#providers"
192
192
  },
193
193
  "parameters": [
194
194
  {
@@ -223,7 +223,7 @@
223
223
  "summary": "Send an email to reset your password",
224
224
  "externalDocs": {
225
225
  "description": "Find out more in the strapi's documentation",
226
- "url": "https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#forgotten-reset-password"
226
+ "url": "https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#forgotten-reset-password"
227
227
  },
228
228
  "requestBody": {
229
229
  "description": "",
@@ -315,7 +315,7 @@
315
315
  "description": "All the routes related to the authentication",
316
316
  "externalDocs": {
317
317
  "description": "Find out more in strapi's documentation",
318
- "url": "https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html"
318
+ "url": "https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html"
319
319
  }
320
320
  },
321
321
  {
package/package.json CHANGED
@@ -1,21 +1,31 @@
1
1
  {
2
2
  "name": "@strapi/plugin-users-permissions",
3
- "version": "4.0.0-beta.17",
3
+ "version": "4.0.0-beta.20",
4
4
  "description": "Protect your API with a full-authentication process based on JWT",
5
- "strapi": {
6
- "displayName": "Roles & Permissions",
7
- "name": "users-permissions",
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.17",
18
- "@strapi/utils": "4.0.0-beta.17",
27
+ "@strapi/helper-plugin": "4.0.0-beta.20",
28
+ "@strapi/utils": "4.0.0-beta.20",
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
- "license": "SEE LICENSE IN LICENSE",
59
- "gitHead": "8f9cf3803464d3dbfc8c1090c16bb5f53a60c6c3"
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": "b4993dab9f6dbc583709167f459b6f00e0b4baa6"
60
61
  }
@@ -41,9 +41,6 @@ const initGrant = async pluginStore => {
41
41
  const baseURL = `${strapi.config.server.url}/${apiPrefix}/auth`;
42
42
 
43
43
  const grantConfig = {
44
- defaults: {
45
- prefix: `${apiPrefix}/connect`,
46
- },
47
44
  email: {
48
45
  enabled: true,
49
46
  icon: 'envelope',
@@ -162,10 +162,18 @@ module.exports = {
162
162
  async connect(ctx, next) {
163
163
  const grant = require('grant-koa');
164
164
 
165
- const grantConfig = await strapi
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
 
@@ -175,7 +183,7 @@ module.exports = {
175
183
 
176
184
  if (!strapi.config.server.url.startsWith('http')) {
177
185
  strapi.log.warn(
178
- 'You are using a third party provider for login. Make sure to set an absolute url in config/server.js. More info here: https://strapi.io/documentation/developer-docs/latest/development/plugins/users-permissions.html#setting-up-the-server-url'
186
+ 'You are using a third party provider for login. Make sure to set an absolute url in config/server.js. More info here: https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#setting-up-the-server-url'
179
187
  );
180
188
  }
181
189
 
@@ -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 grant = await strapi
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: grant.twitter.key,
204
- secret: grant.twitter.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: grant.instagram.key,
228
- secret: grant.instagram.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, grant.twitch.key)
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://${grant.auth0.subdomain}.auth0.com`] = {
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(grant['cas'], 'subdomain');
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 `${getAbsoluteServerUrl(strapi.config)}/${apiPrefix}/connect/${provider}/callback`;
592
+ return urlJoin(getAbsoluteServerUrl(strapi.config), apiPrefix, 'connect', provider, 'callback');
592
593
  };
593
594
 
594
595
  return {