@strapi/plugin-users-permissions 4.0.0-beta.18 → 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/package.json CHANGED
@@ -1,21 +1,31 @@
1
1
  {
2
2
  "name": "@strapi/plugin-users-permissions",
3
- "version": "4.0.0-beta.18",
3
+ "version": "4.0.0-beta.19",
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.18",
18
- "@strapi/utils": "4.0.0-beta.18",
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",
@@ -36,26 +46,16 @@
36
46
  "devDependencies": {
37
47
  "koa": "^2.13.1"
38
48
  },
39
- "author": {
40
- "name": "Strapi team",
41
- "email": "hi@strapi.io",
42
- "url": "https://strapi.io"
43
- },
44
- "maintainers": [
45
- {
46
- "name": "Strapi team",
47
- "email": "hi@strapi.io",
48
- "url": "https://strapi.io"
49
- }
50
- ],
51
- "repository": {
52
- "type": "git",
53
- "url": "git://github.com/strapi/strapi.git"
54
- },
55
49
  "engines": {
56
50
  "node": ">=12.x.x <=16.x.x",
57
51
  "npm": ">=6.0.0"
58
52
  },
59
- "license": "SEE LICENSE IN LICENSE",
60
- "gitHead": "3e9e3f13cb85822e6d92b0e448ae0b94d440dac1"
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"
61
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
 
@@ -28,7 +28,7 @@ module.exports = ({ strapi }) => {
28
28
  const getProfile = async (provider, query, callback) => {
29
29
  const access_token = query.access_token || query.code || query.oauth_token;
30
30
 
31
- const grant = await strapi
31
+ const providers = await strapi
32
32
  .store({ type: 'plugin', name: 'users-permissions', key: 'grant' })
33
33
  .get();
34
34
 
@@ -168,7 +168,7 @@ module.exports = ({ strapi }) => {
168
168
  return callback(null, {
169
169
  username: userbody.login,
170
170
  email: Array.isArray(emailsbody)
171
- ? emailsbody.find((email) => email.primary === true).email
171
+ ? emailsbody.find(email => email.primary === true).email
172
172
  : null,
173
173
  });
174
174
  });
@@ -201,8 +201,8 @@ module.exports = ({ strapi }) => {
201
201
  const twitter = purest({
202
202
  provider: 'twitter',
203
203
  config: purestConfig,
204
- key: grant.twitter.key,
205
- secret: grant.twitter.secret,
204
+ key: providers.twitter.key,
205
+ secret: providers.twitter.secret,
206
206
  });
207
207
 
208
208
  twitter
@@ -225,8 +225,8 @@ module.exports = ({ strapi }) => {
225
225
  case 'instagram': {
226
226
  const instagram = purest({
227
227
  provider: 'instagram',
228
- key: grant.instagram.key,
229
- secret: grant.instagram.secret,
228
+ key: providers.instagram.key,
229
+ secret: providers.instagram.secret,
230
230
  config: purestConfig,
231
231
  });
232
232
 
@@ -298,7 +298,7 @@ module.exports = ({ strapi }) => {
298
298
 
299
299
  twitch
300
300
  .get('users')
301
- .auth(access_token, grant.twitch.key)
301
+ .auth(access_token, providers.twitch.key)
302
302
  .request((err, res, body) => {
303
303
  if (err) {
304
304
  callback(err);
@@ -403,7 +403,7 @@ module.exports = ({ strapi }) => {
403
403
  }
404
404
  case 'auth0': {
405
405
  const purestAuth0Conf = {};
406
- purestAuth0Conf[`https://${grant.auth0.subdomain}.auth0.com`] = {
406
+ purestAuth0Conf[`https://${providers.auth0.subdomain}.auth0.com`] = {
407
407
  __domain: {
408
408
  auth: {
409
409
  auth: { bearer: '[0]' },
@@ -442,7 +442,7 @@ module.exports = ({ strapi }) => {
442
442
  break;
443
443
  }
444
444
  case 'cas': {
445
- const provider_url = 'https://' + _.get(grant['cas'], 'subdomain');
445
+ const provider_url = 'https://' + _.get(providers.cas, 'subdomain');
446
446
  const cas = purest({
447
447
  provider: 'cas',
448
448
  config: {
@@ -551,7 +551,7 @@ module.exports = ({ strapi }) => {
551
551
  }
552
552
 
553
553
  if (
554
- !_.isEmpty(_.find(users, (user) => user.provider !== provider)) &&
554
+ !_.isEmpty(_.find(users, user => user.provider !== provider)) &&
555
555
  advanced.unique_email
556
556
  ) {
557
557
  return resolve([