@akemona-org/strapi-plugin-users-permissions 3.7.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/LICENSE +22 -0
- package/README.md +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/BaselineAlignement/index.js +33 -0
- package/admin/src/components/Bloc/index.js +10 -0
- package/admin/src/components/BoundRoute/Components.js +78 -0
- package/admin/src/components/BoundRoute/index.js +56 -0
- package/admin/src/components/ContainerFluid/index.js +13 -0
- package/admin/src/components/FormBloc/index.js +61 -0
- package/admin/src/components/IntlInput/index.js +38 -0
- package/admin/src/components/ListBaselineAlignment/index.js +8 -0
- package/admin/src/components/ListRow/Components.js +74 -0
- package/admin/src/components/ListRow/index.js +35 -0
- package/admin/src/components/ModalForm/Wrapper.js +12 -0
- package/admin/src/components/ModalForm/index.js +59 -0
- package/admin/src/components/Permissions/ListWrapper.js +9 -0
- package/admin/src/components/Permissions/PermissionRow/BaselineAlignment.js +7 -0
- package/admin/src/components/Permissions/PermissionRow/CheckboxWrapper.js +37 -0
- package/admin/src/components/Permissions/PermissionRow/RowStyle.js +28 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/ConditionsButtonWrapper.js +13 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/PolicyWrapper.js +8 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/SubCategoryWrapper.js +26 -0
- package/admin/src/components/Permissions/PermissionRow/SubCategory/index.js +116 -0
- package/admin/src/components/Permissions/PermissionRow/index.js +92 -0
- package/admin/src/components/Permissions/index.js +44 -0
- package/admin/src/components/Permissions/init.js +14 -0
- package/admin/src/components/Permissions/reducer.js +27 -0
- package/admin/src/components/Policies/Components.js +26 -0
- package/admin/src/components/Policies/index.js +61 -0
- package/admin/src/components/PrefixedIcon/index.js +27 -0
- package/admin/src/components/Roles/EmptyRole/BaselineAlignment.js +7 -0
- package/admin/src/components/Roles/EmptyRole/index.js +27 -0
- package/admin/src/components/Roles/RoleListWrapper/index.js +17 -0
- package/admin/src/components/Roles/RoleRow/RoleDescription.js +9 -0
- package/admin/src/components/Roles/RoleRow/index.js +45 -0
- package/admin/src/components/Roles/index.js +3 -0
- package/admin/src/components/SizedInput/index.js +24 -0
- package/admin/src/components/UsersPermissions/index.js +91 -0
- package/admin/src/components/UsersPermissions/init.js +11 -0
- package/admin/src/components/UsersPermissions/reducer.js +60 -0
- package/admin/src/containers/AdvancedSettings/index.js +218 -0
- package/admin/src/containers/AdvancedSettings/reducer.js +65 -0
- package/admin/src/containers/AdvancedSettings/utils/form.js +52 -0
- package/admin/src/containers/EmailTemplates/CustomTextInput.js +105 -0
- package/admin/src/containers/EmailTemplates/Wrapper.js +36 -0
- package/admin/src/containers/EmailTemplates/index.js +222 -0
- package/admin/src/containers/EmailTemplates/reducer.js +58 -0
- package/admin/src/containers/EmailTemplates/utils/forms.js +81 -0
- package/admin/src/containers/EmailTemplates/utils/schema.js +25 -0
- package/admin/src/containers/Providers/index.js +283 -0
- package/admin/src/containers/Providers/reducer.js +54 -0
- package/admin/src/containers/Providers/utils/createProvidersArray.js +21 -0
- package/admin/src/containers/Providers/utils/forms.js +205 -0
- package/admin/src/containers/Roles/CreatePage/index.js +167 -0
- package/admin/src/containers/Roles/CreatePage/utils/schema.js +9 -0
- package/admin/src/containers/Roles/EditPage/index.js +161 -0
- package/admin/src/containers/Roles/EditPage/utils/schema.js +9 -0
- package/admin/src/containers/Roles/ListPage/BaselineAlignment.js +8 -0
- package/admin/src/containers/Roles/ListPage/index.js +188 -0
- package/admin/src/containers/Roles/ProtectedCreatePage/index.js +12 -0
- package/admin/src/containers/Roles/ProtectedEditPage/index.js +12 -0
- package/admin/src/containers/Roles/ProtectedListPage/index.js +15 -0
- package/admin/src/containers/Roles/index.js +35 -0
- package/admin/src/contexts/EditPage/index.js +26 -0
- package/admin/src/contexts/HomePage/index.js +27 -0
- package/admin/src/contexts/UsersPermissionsContext/index.js +17 -0
- package/admin/src/hooks/index.js +5 -0
- package/admin/src/hooks/useFetchRole/index.js +55 -0
- package/admin/src/hooks/useFetchRole/reducer.js +31 -0
- package/admin/src/hooks/useForm/index.js +96 -0
- package/admin/src/hooks/useForm/reducer.js +59 -0
- package/admin/src/hooks/usePlugins/index.js +73 -0
- package/admin/src/hooks/usePlugins/init.js +5 -0
- package/admin/src/hooks/usePlugins/reducer.js +37 -0
- package/admin/src/hooks/useRolesList/index.js +62 -0
- package/admin/src/hooks/useRolesList/init.js +5 -0
- package/admin/src/hooks/useRolesList/reducer.js +31 -0
- package/admin/src/index.js +109 -0
- package/admin/src/permissions.js +33 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/translations/ar.json +49 -0
- package/admin/src/translations/cs.json +55 -0
- package/admin/src/translations/de.json +68 -0
- package/admin/src/translations/dk.json +116 -0
- package/admin/src/translations/en.json +104 -0
- package/admin/src/translations/es.json +70 -0
- package/admin/src/translations/fr.json +55 -0
- package/admin/src/translations/id.json +69 -0
- package/admin/src/translations/index.js +55 -0
- package/admin/src/translations/it.json +68 -0
- package/admin/src/translations/ja.json +53 -0
- package/admin/src/translations/ko.json +55 -0
- package/admin/src/translations/ms.json +54 -0
- package/admin/src/translations/nl.json +53 -0
- package/admin/src/translations/pl.json +55 -0
- package/admin/src/translations/pt-BR.json +49 -0
- package/admin/src/translations/pt.json +53 -0
- package/admin/src/translations/ru.json +68 -0
- package/admin/src/translations/sk.json +57 -0
- package/admin/src/translations/sv.json +68 -0
- package/admin/src/translations/th.json +66 -0
- package/admin/src/translations/tr.json +53 -0
- package/admin/src/translations/uk.json +54 -0
- package/admin/src/translations/vi.json +55 -0
- package/admin/src/translations/zh-Hans.json +104 -0
- package/admin/src/translations/zh.json +53 -0
- package/admin/src/utils/cleanPermissions.js +25 -0
- package/admin/src/utils/formatPolicies.js +8 -0
- package/admin/src/utils/getRequestURL.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/index.js +4 -0
- package/config/functions/bootstrap.js +234 -0
- package/config/layout.js +10 -0
- package/config/policies/isAuthenticated.js +9 -0
- package/config/policies/permissions.js +93 -0
- package/config/policies/rateLimit.js +33 -0
- package/config/request.json +6 -0
- package/config/routes.json +397 -0
- package/config/schema.graphql.js +280 -0
- package/config/security.json +5 -0
- package/config/users-permissions-actions.js +80 -0
- package/controllers/Auth.js +612 -0
- package/controllers/User.js +125 -0
- package/controllers/UsersPermissions.js +291 -0
- package/controllers/user/admin.js +224 -0
- package/controllers/user/api.js +173 -0
- package/controllers/validation/email-template.js +40 -0
- package/documentation/1.0.0/overrides/users-permissions-Role.json +281 -0
- package/documentation/1.0.0/overrides/users-permissions-User.json +325 -0
- package/middlewares/users-permissions/defaults.json +5 -0
- package/middlewares/users-permissions/index.js +40 -0
- package/models/Permission.js +7 -0
- package/models/Permission.settings.json +43 -0
- package/models/Role.js +7 -0
- package/models/Role.settings.json +42 -0
- package/models/User.config.js +15 -0
- package/models/User.js +7 -0
- package/models/User.settings.json +62 -0
- package/package.json +70 -0
- package/services/Jwt.js +65 -0
- package/services/Providers.js +596 -0
- package/services/User.js +167 -0
- package/services/UsersPermissions.js +416 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
{
|
|
2
|
+
"paths": {
|
|
3
|
+
"/auth/local/register": {
|
|
4
|
+
"post": {
|
|
5
|
+
"tags": ["Authentication"],
|
|
6
|
+
"security": [],
|
|
7
|
+
"externalDocs": {
|
|
8
|
+
"description": "Find out more in the strapi's documentation",
|
|
9
|
+
"url": "https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html#registration"
|
|
10
|
+
},
|
|
11
|
+
"responses": {
|
|
12
|
+
"200": {
|
|
13
|
+
"description": "Successfully register a user",
|
|
14
|
+
"content": {
|
|
15
|
+
"application/json": {
|
|
16
|
+
"schema": {
|
|
17
|
+
"$ref": "#/components/schemas/Users-PermissionsRegisterResponse"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"requestBody": {
|
|
24
|
+
"description": "",
|
|
25
|
+
"required": true,
|
|
26
|
+
"content": {
|
|
27
|
+
"application/json": {
|
|
28
|
+
"schema": {
|
|
29
|
+
"required": ["username", "email", "password"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"username": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"minLength": 3
|
|
34
|
+
},
|
|
35
|
+
"email": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"minLength": 6
|
|
38
|
+
},
|
|
39
|
+
"password": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"minLength": 6
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"/auth/email-confirmation": {
|
|
51
|
+
"get": {
|
|
52
|
+
"tags": ["Authentication"],
|
|
53
|
+
"security": []
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"/auth/send-email-confirmation": {
|
|
57
|
+
"post": {
|
|
58
|
+
"security": [],
|
|
59
|
+
"externalDocs": {
|
|
60
|
+
"description": "Find out more in the strapi's documentation",
|
|
61
|
+
"url": "https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html#email-validation"
|
|
62
|
+
},
|
|
63
|
+
"responses": {
|
|
64
|
+
"200": {
|
|
65
|
+
"description": "Successfully sent email",
|
|
66
|
+
"content": {
|
|
67
|
+
"application/json": {
|
|
68
|
+
"email": {
|
|
69
|
+
"type": "string"
|
|
70
|
+
},
|
|
71
|
+
"sent": {
|
|
72
|
+
"type": "boolean"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"requestBody": {
|
|
79
|
+
"description": "",
|
|
80
|
+
"required": true,
|
|
81
|
+
"content": {
|
|
82
|
+
"application/json": {
|
|
83
|
+
"schema": {
|
|
84
|
+
"required": ["email"],
|
|
85
|
+
"properties": {
|
|
86
|
+
"email": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"minLength": 6
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"/users-permissions/search/{id}": {
|
|
98
|
+
"get": {
|
|
99
|
+
"summary": "Retrieve a list of users by searching for their username or email",
|
|
100
|
+
"parameters": [
|
|
101
|
+
{
|
|
102
|
+
"name": "id",
|
|
103
|
+
"in": "path",
|
|
104
|
+
"description": "A string matching a user's email or username",
|
|
105
|
+
"deprecated": false,
|
|
106
|
+
"required": true,
|
|
107
|
+
"schema": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"/connect/*": {
|
|
115
|
+
"get": {
|
|
116
|
+
"summary": "Authenticate your user with a custom provider",
|
|
117
|
+
"tags": ["Authentication"],
|
|
118
|
+
"security": [],
|
|
119
|
+
"parameters": [
|
|
120
|
+
{
|
|
121
|
+
"name": "provider",
|
|
122
|
+
"in": "path",
|
|
123
|
+
"required": true,
|
|
124
|
+
"deprecated": false,
|
|
125
|
+
"description": "The name of the provider you want to use",
|
|
126
|
+
"schema": {
|
|
127
|
+
"type": "string"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"externalDocs": {
|
|
132
|
+
"description": "Find out more about the authentication flow in the strapi documentation",
|
|
133
|
+
"url": "https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html#setting-up-the-provider-examples"
|
|
134
|
+
},
|
|
135
|
+
"responses": {
|
|
136
|
+
"200": {
|
|
137
|
+
"description": "Your user is redirected"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"/auth/local": {
|
|
143
|
+
"post": {
|
|
144
|
+
"externalDocs": {
|
|
145
|
+
"description": "Find out more in the strapi's documentation",
|
|
146
|
+
"url": "https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html#login"
|
|
147
|
+
},
|
|
148
|
+
"tags": ["Authentication"],
|
|
149
|
+
"security": [],
|
|
150
|
+
"requestBody": {
|
|
151
|
+
"description": "The identifier param can either be an email or a username",
|
|
152
|
+
"content": {
|
|
153
|
+
"application/json": {
|
|
154
|
+
"schema": {
|
|
155
|
+
"required": ["identifier", "password"],
|
|
156
|
+
"properties": {
|
|
157
|
+
"identifier": {
|
|
158
|
+
"type": "string"
|
|
159
|
+
},
|
|
160
|
+
"password": {
|
|
161
|
+
"type": "string"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"example": {
|
|
166
|
+
"identifier": "strapi@akemona.com",
|
|
167
|
+
"password": "superSecure123"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"responses": {
|
|
173
|
+
"200": {
|
|
174
|
+
"description": "Response",
|
|
175
|
+
"content": {
|
|
176
|
+
"application/json": {
|
|
177
|
+
"schema": {
|
|
178
|
+
"$ref": "#/components/schemas/Users-PermissionsRegisterResponse"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"/auth/{provider}/callback": {
|
|
187
|
+
"get": {
|
|
188
|
+
"tags": ["Authentication"],
|
|
189
|
+
"externalDocs": {
|
|
190
|
+
"description": "Find out more in the strapi's documentation",
|
|
191
|
+
"url": "https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html#setting-up-the-provider-examples"
|
|
192
|
+
},
|
|
193
|
+
"parameters": [
|
|
194
|
+
{
|
|
195
|
+
"name": "provider",
|
|
196
|
+
"in": "path",
|
|
197
|
+
"description": "The provider used to authenticate your user",
|
|
198
|
+
"deprecated": false,
|
|
199
|
+
"required": true,
|
|
200
|
+
"schema": {
|
|
201
|
+
"type": "string"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"responses": {
|
|
206
|
+
"200": {
|
|
207
|
+
"description": "Successfull redirection after approving a provider",
|
|
208
|
+
"content": {
|
|
209
|
+
"application/json": {
|
|
210
|
+
"schema": {
|
|
211
|
+
"$ref": "#/components/schemas/Users-PermissionsRegisterResponse"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"/auth/forgot-password": {
|
|
220
|
+
"post": {
|
|
221
|
+
"tags": ["Authentication"],
|
|
222
|
+
"security": [],
|
|
223
|
+
"summary": "Send an email to reset your password",
|
|
224
|
+
"externalDocs": {
|
|
225
|
+
"description": "Find out more in the strapi's documentation",
|
|
226
|
+
"url": "https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html#forgotten-reset-password"
|
|
227
|
+
},
|
|
228
|
+
"requestBody": {
|
|
229
|
+
"description": "",
|
|
230
|
+
"required": true,
|
|
231
|
+
"content": {
|
|
232
|
+
"application/json": {
|
|
233
|
+
"schema": {
|
|
234
|
+
"properties": {
|
|
235
|
+
"email": {
|
|
236
|
+
"type": "string"
|
|
237
|
+
},
|
|
238
|
+
"url": {
|
|
239
|
+
"type": "string"
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
"example": {
|
|
244
|
+
"email": "strapi@akemona.com",
|
|
245
|
+
"url": "http://mon-site.com/rest-password"
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"responses": {
|
|
251
|
+
"200": {
|
|
252
|
+
"description": "Email sent"
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"/auth/reset-password": {
|
|
258
|
+
"post": {
|
|
259
|
+
"tags": ["Authentication"],
|
|
260
|
+
"security": [],
|
|
261
|
+
"responses": {
|
|
262
|
+
"200": {
|
|
263
|
+
"description": "response",
|
|
264
|
+
"content": {
|
|
265
|
+
"application/json": {
|
|
266
|
+
"schema": {
|
|
267
|
+
"$ref": "#/components/schemas/Users-PermissionsRegisterResponse"
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
"requestBody": {
|
|
274
|
+
"description": "",
|
|
275
|
+
"required": true,
|
|
276
|
+
"content": {
|
|
277
|
+
"application/json": {
|
|
278
|
+
"schema": {
|
|
279
|
+
"required": ["code", "password", "passwordConfirmation"],
|
|
280
|
+
"properties": {
|
|
281
|
+
"code": {
|
|
282
|
+
"type": "string"
|
|
283
|
+
},
|
|
284
|
+
"password": {
|
|
285
|
+
"type": "string"
|
|
286
|
+
},
|
|
287
|
+
"passwordConfirmation": {
|
|
288
|
+
"type": "string"
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"components": {
|
|
299
|
+
"schemas": {
|
|
300
|
+
"Users-PermissionsRegisterResponse": {
|
|
301
|
+
"properties": {
|
|
302
|
+
"jwt": {
|
|
303
|
+
"type": "string"
|
|
304
|
+
},
|
|
305
|
+
"user": {
|
|
306
|
+
"$ref": "#/components/schemas/Users-PermissionsUser"
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
"tags": [
|
|
313
|
+
{
|
|
314
|
+
"name": "Authentication",
|
|
315
|
+
"description": "All the routes related to the authentication",
|
|
316
|
+
"externalDocs": {
|
|
317
|
+
"description": "Find out more in strapi's documentation",
|
|
318
|
+
"url": "https://strapi.akemona.com/documentation/developer-docs/latest/development/plugins/users-permissions.html"
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"name": "Users-Permissions - User"
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Module dependencies
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Public node modules.
|
|
8
|
+
const _ = require('lodash');
|
|
9
|
+
|
|
10
|
+
module.exports = strapi => {
|
|
11
|
+
return {
|
|
12
|
+
beforeInitialize() {
|
|
13
|
+
strapi.config.middleware.load.before.unshift('users-permissions');
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
initialize() {
|
|
17
|
+
_.forEach(strapi.admin.config.routes, value => {
|
|
18
|
+
if (_.get(value.config, 'policies')) {
|
|
19
|
+
value.config.policies.unshift('plugins::users-permissions.permissions');
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
_.forEach(strapi.config.routes, value => {
|
|
24
|
+
if (_.get(value.config, 'policies')) {
|
|
25
|
+
value.config.policies.unshift('plugins::users-permissions.permissions');
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (strapi.plugins) {
|
|
30
|
+
_.forEach(strapi.plugins, plugin => {
|
|
31
|
+
_.forEach(plugin.config.routes, value => {
|
|
32
|
+
if (_.get(value.config, 'policies')) {
|
|
33
|
+
value.config.policies.unshift('plugins::users-permissions.permissions');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"info": {
|
|
3
|
+
"name": "permission",
|
|
4
|
+
"description": ""
|
|
5
|
+
},
|
|
6
|
+
"pluginOptions": {
|
|
7
|
+
"content-manager": {
|
|
8
|
+
"visible": false
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"attributes": {
|
|
12
|
+
"type": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"required": true,
|
|
15
|
+
"configurable": false
|
|
16
|
+
},
|
|
17
|
+
"controller": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"required": true,
|
|
20
|
+
"configurable": false
|
|
21
|
+
},
|
|
22
|
+
"action": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"required": true,
|
|
25
|
+
"configurable": false
|
|
26
|
+
},
|
|
27
|
+
"enabled": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"required": true,
|
|
30
|
+
"configurable": false
|
|
31
|
+
},
|
|
32
|
+
"policy": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"configurable": false
|
|
35
|
+
},
|
|
36
|
+
"role": {
|
|
37
|
+
"model": "role",
|
|
38
|
+
"via": "permissions",
|
|
39
|
+
"plugin": "users-permissions",
|
|
40
|
+
"configurable": false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/models/Role.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"info": {
|
|
3
|
+
"name": "role",
|
|
4
|
+
"description": ""
|
|
5
|
+
},
|
|
6
|
+
"pluginOptions": {
|
|
7
|
+
"content-manager": {
|
|
8
|
+
"visible": false
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"attributes": {
|
|
12
|
+
"name": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"minLength": 3,
|
|
15
|
+
"required": true,
|
|
16
|
+
"configurable": false
|
|
17
|
+
},
|
|
18
|
+
"description": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"configurable": false
|
|
21
|
+
},
|
|
22
|
+
"type": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"unique": true,
|
|
25
|
+
"configurable": false
|
|
26
|
+
},
|
|
27
|
+
"permissions": {
|
|
28
|
+
"collection": "permission",
|
|
29
|
+
"via": "role",
|
|
30
|
+
"plugin": "users-permissions",
|
|
31
|
+
"configurable": false,
|
|
32
|
+
"isVirtual": true
|
|
33
|
+
},
|
|
34
|
+
"users": {
|
|
35
|
+
"collection": "user",
|
|
36
|
+
"via": "role",
|
|
37
|
+
"configurable": false,
|
|
38
|
+
"plugin": "users-permissions"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"collectionName": "users-permissions_role"
|
|
42
|
+
}
|
package/models/User.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"collectionName": "users-permissions_user",
|
|
3
|
+
"info": {
|
|
4
|
+
"name": "user",
|
|
5
|
+
"description": ""
|
|
6
|
+
},
|
|
7
|
+
"options": {
|
|
8
|
+
"draftAndPublish": false,
|
|
9
|
+
"timestamps": true
|
|
10
|
+
},
|
|
11
|
+
"attributes": {
|
|
12
|
+
"username": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"minLength": 3,
|
|
15
|
+
"unique": true,
|
|
16
|
+
"configurable": false,
|
|
17
|
+
"required": true
|
|
18
|
+
},
|
|
19
|
+
"email": {
|
|
20
|
+
"type": "email",
|
|
21
|
+
"minLength": 6,
|
|
22
|
+
"configurable": false,
|
|
23
|
+
"required": true
|
|
24
|
+
},
|
|
25
|
+
"provider": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"configurable": false
|
|
28
|
+
},
|
|
29
|
+
"password": {
|
|
30
|
+
"type": "password",
|
|
31
|
+
"minLength": 6,
|
|
32
|
+
"configurable": false,
|
|
33
|
+
"private": true
|
|
34
|
+
},
|
|
35
|
+
"resetPasswordToken": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"configurable": false,
|
|
38
|
+
"private": true
|
|
39
|
+
},
|
|
40
|
+
"confirmationToken": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"configurable": false,
|
|
43
|
+
"private": true
|
|
44
|
+
},
|
|
45
|
+
"confirmed": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"default": false,
|
|
48
|
+
"configurable": false
|
|
49
|
+
},
|
|
50
|
+
"blocked": {
|
|
51
|
+
"type": "boolean",
|
|
52
|
+
"default": false,
|
|
53
|
+
"configurable": false
|
|
54
|
+
},
|
|
55
|
+
"role": {
|
|
56
|
+
"model": "role",
|
|
57
|
+
"via": "users",
|
|
58
|
+
"plugin": "users-permissions",
|
|
59
|
+
"configurable": false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@akemona-org/strapi-plugin-users-permissions",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "3.7.0",
|
|
7
|
+
"description": "Protect your API with a full-authentication process based on JWT",
|
|
8
|
+
"strapi": {
|
|
9
|
+
"name": "Roles & Permissions",
|
|
10
|
+
"icon": "users",
|
|
11
|
+
"description": "users-permissions.plugin.description",
|
|
12
|
+
"required": true
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "echo \"no tests yet\""
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@akemona-org/strapi-helper-plugin": "3.7.0",
|
|
19
|
+
"@akemona-org/strapi-utils": "3.7.0",
|
|
20
|
+
"@buffetjs/core": "3.3.8",
|
|
21
|
+
"@buffetjs/custom": "3.3.8",
|
|
22
|
+
"@buffetjs/hooks": "3.3.8",
|
|
23
|
+
"@buffetjs/icons": "3.3.8",
|
|
24
|
+
"@buffetjs/styles": "3.3.8",
|
|
25
|
+
"@buffetjs/utils": "3.3.8",
|
|
26
|
+
"@purest/providers": "^1.0.2",
|
|
27
|
+
"bcryptjs": "^2.4.3",
|
|
28
|
+
"grant-koa": "5.4.8",
|
|
29
|
+
"immutable": "^3.8.2",
|
|
30
|
+
"jsonwebtoken": "^8.1.0",
|
|
31
|
+
"koa2-ratelimit": "1.1.2",
|
|
32
|
+
"lodash": "4.17.21",
|
|
33
|
+
"purest": "3.1.0",
|
|
34
|
+
"react": "^16.14.0",
|
|
35
|
+
"react-dom": "^16.9.0",
|
|
36
|
+
"react-intl": "4.5.0",
|
|
37
|
+
"react-redux": "7.2.3",
|
|
38
|
+
"react-router": "^5.2.0",
|
|
39
|
+
"react-router-dom": "^5.0.0",
|
|
40
|
+
"reactstrap": "8.4.1",
|
|
41
|
+
"redux-saga": "^0.16.0",
|
|
42
|
+
"request": "^2.83.0",
|
|
43
|
+
"uuid": "^3.1.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"koa": "^2.13.1"
|
|
47
|
+
},
|
|
48
|
+
"author": {
|
|
49
|
+
"name": "Akemona team",
|
|
50
|
+
"email": "strapi@akemona.com",
|
|
51
|
+
"url": "https://strapi.akemona.com"
|
|
52
|
+
},
|
|
53
|
+
"maintainers": [
|
|
54
|
+
{
|
|
55
|
+
"name": "Akemona team",
|
|
56
|
+
"email": "strapi@akemona.com",
|
|
57
|
+
"url": "https://strapi.akemona.com"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git://github.com/akemona/strapi.git"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=10.16.0 <=14.x.x",
|
|
66
|
+
"npm": ">=6.0.0"
|
|
67
|
+
},
|
|
68
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
69
|
+
"gitHead": "129a8d6191b55810fd66448dcc47fee829df986c"
|
|
70
|
+
}
|
package/services/Jwt.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Jwt.js service
|
|
5
|
+
*
|
|
6
|
+
* @description: A set of functions similar to controller's actions to avoid code duplication.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const _ = require('lodash');
|
|
10
|
+
const jwt = require('jsonwebtoken');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
getToken(ctx) {
|
|
14
|
+
const params = _.assign({}, ctx.request.body, ctx.request.query);
|
|
15
|
+
|
|
16
|
+
let token = '';
|
|
17
|
+
|
|
18
|
+
if (ctx.request && ctx.request.header && ctx.request.header.authorization) {
|
|
19
|
+
const parts = ctx.request.header.authorization.split(' ');
|
|
20
|
+
|
|
21
|
+
if (parts.length === 2) {
|
|
22
|
+
const scheme = parts[0];
|
|
23
|
+
const credentials = parts[1];
|
|
24
|
+
if (/^Bearer$/i.test(scheme)) {
|
|
25
|
+
token = credentials;
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
throw new Error(
|
|
29
|
+
'Invalid authorization header format. Format is Authorization: Bearer [token]'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
} else if (params.token) {
|
|
33
|
+
token = params.token;
|
|
34
|
+
} else {
|
|
35
|
+
throw new Error('No authorization header was found');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return this.verify(token);
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
issue(payload, jwtOptions = {}) {
|
|
42
|
+
_.defaults(jwtOptions, strapi.plugins['users-permissions'].config.jwt);
|
|
43
|
+
return jwt.sign(
|
|
44
|
+
_.clone(payload.toJSON ? payload.toJSON() : payload),
|
|
45
|
+
_.get(strapi.plugins, ['users-permissions', 'config', 'jwtSecret']),
|
|
46
|
+
jwtOptions
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
verify(token) {
|
|
51
|
+
return new Promise(function(resolve, reject) {
|
|
52
|
+
jwt.verify(
|
|
53
|
+
token,
|
|
54
|
+
_.get(strapi.plugins, ['users-permissions', 'config', 'jwtSecret']),
|
|
55
|
+
{},
|
|
56
|
+
function(err, tokenPayload = {}) {
|
|
57
|
+
if (err) {
|
|
58
|
+
return reject(new Error('Invalid token.'));
|
|
59
|
+
}
|
|
60
|
+
resolve(tokenPayload);
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|