package-installer-cli 1.3.3 → 1.4.1

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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/dist/commands/email.js +1150 -0
  3. data/dist/email-templates/bugReport.js +108 -0
  4. data/dist/email-templates/collectors/bugReport.js +41 -0
  5. data/dist/email-templates/collectors/common.js +56 -0
  6. data/dist/email-templates/collectors/customMessage.js +48 -0
  7. data/dist/email-templates/collectors/docs.js +41 -0
  8. data/dist/email-templates/collectors/featureRequest.js +47 -0
  9. data/dist/email-templates/collectors/improvement.js +52 -0
  10. data/dist/email-templates/collectors/index.js +9 -0
  11. data/dist/email-templates/collectors/question.js +31 -0
  12. data/dist/email-templates/collectors/templateRequest.js +53 -0
  13. data/dist/email-templates/customMessage.js +135 -0
  14. data/dist/email-templates/docs.js +111 -0
  15. data/dist/email-templates/featureRequest.js +111 -0
  16. data/dist/email-templates/generator.js +67 -0
  17. data/dist/email-templates/improvement.js +121 -0
  18. data/dist/email-templates/index.js +15 -0
  19. data/dist/email-templates/question.js +101 -0
  20. data/dist/email-templates/styles.js +168 -0
  21. data/dist/email-templates/templateRequest.js +120 -0
  22. data/dist/email-templates/testEmail.js +56 -0
  23. data/dist/email-templates/types.js +1 -0
  24. data/dist/index.js +29 -1
  25. data/dist/utils/featureInstaller.js +4 -11
  26. data/features/ai/ai.json +547 -0
  27. data/features/analytics/analytics.json +4 -0
  28. data/features/auth/auth.json +473 -0
  29. data/features/auth/auth0/django/backend/apiexample/urls.py +10 -0
  30. data/features/auth/auth0/django/backend/apiexample/validator.py +21 -0
  31. data/features/auth/auth0/django/backend/apiexample/views.py +30 -0
  32. data/features/auth/auth0/django/backend/requirements.txt +4 -0
  33. data/features/auth/auth0/django/web-app/requirements.txt +4 -0
  34. data/features/auth/auth0/django/web-app/webappexample/settings.py +28 -0
  35. data/features/auth/auth0/django/web-app/webappexample/templates/index.html +16 -0
  36. data/features/auth/auth0/django/web-app/webappexample/urls.py +10 -0
  37. data/features/auth/auth0/django/web-app/webappexample/views.py +52 -0
  38. data/features/auth/auth0/go/backend/go.mod +8 -0
  39. data/features/auth/auth0/go/backend/main.go +60 -0
  40. data/features/auth/auth0/go/backend/middleware/jwt.go +81 -0
  41. data/features/auth/auth0/go/web-app/auth.go +56 -0
  42. data/features/auth/auth0/go/web-app/callback.go +52 -0
  43. data/features/auth/auth0/go/web-app/go.mod +11 -0
  44. data/features/auth/auth0/go/web-app/isAuthenticated.go +20 -0
  45. data/features/auth/auth0/go/web-app/login.go +47 -0
  46. data/features/auth/auth0/go/web-app/logout.go +38 -0
  47. data/features/auth/auth0/go/web-app/main.go +31 -0
  48. data/features/auth/auth0/go/web-app/router.go +44 -0
  49. data/features/auth/auth0/go/web-app/user.go +18 -0
  50. data/features/auth/auth0/ruby-on-rails/backend/Gemfile +1 -0
  51. data/features/auth/auth0/ruby-on-rails/backend/app/controllers/application_controller.rb +5 -0
  52. data/features/auth/auth0/ruby-on-rails/backend/app/controllers/concern/secured.rb +60 -0
  53. data/features/auth/auth0/ruby-on-rails/backend/app/controllers/private_controller.rb +6 -0
  54. data/features/auth/auth0/ruby-on-rails/backend/app/controllers/public-controller.rb +6 -0
  55. data/features/auth/auth0/ruby-on-rails/backend/app/lib/auth0_client.rb +59 -0
  56. data/features/auth/auth0/ruby-on-rails/web-app/Gemfile +2 -0
  57. data/features/auth/auth0/ruby-on-rails/web-app/auth0_controller.rb +41 -0
  58. data/features/auth/auth0/ruby-on-rails/web-app/config/auth0.yml +4 -0
  59. data/features/auth/auth0/ruby-on-rails/web-app/config/initializers/auth0.rb +14 -0
  60. data/features/auth/auth0/ruby-on-rails/web-app/config/routes.rb +6 -0
  61. data/features/auth/auth0/ruby-on-rails/web-app/config/secured.rb +11 -0
  62. data/features/auth/clerk/go/clerk_client.go +28 -0
  63. data/features/auth/clerk/go/go.mod +5 -0
  64. data/features/auth/clerk/go/main.go +82 -0
  65. data/features/auth/clerk/nextjs/typescript/app/layout.tsx +2 -2
  66. data/features/auth/clerk/ruby-on-rails/Gemfile +1 -0
  67. data/features/auth/clerk/ruby-on-rails/app.rb +50 -0
  68. data/features/auth/clerk/ruby-on-rails/config/initializers/clerk.rb +4 -0
  69. data/features/aws/aws.json +5207 -0
  70. data/features/database/database.json +246 -0
  71. data/features/docker/docker.json +108 -0
  72. data/features/features.json +44 -7321
  73. data/features/gitignore/gitignore.json +61 -0
  74. data/features/monitoring/monitoring.json +5 -0
  75. data/features/payment/payment.json +347 -0
  76. data/features/storage/storage.json +371 -0
  77. data/features/testing/jest/angularjs/typescript/tests/angularjs.test.ts +12 -0
  78. data/features/testing/jest/expressjs/javascript/tests/expressjs.test.js +10 -0
  79. data/features/testing/jest/expressjs/typescript/tests/expressjs.test.ts +10 -0
  80. data/features/testing/jest/nestjs/typescript/tests/nestjs.test.ts +10 -0
  81. data/features/testing/jest/nextjs/javascript/tests/nextjs.test.js +10 -0
  82. data/features/testing/jest/nextjs/typescript/tests/nextjs.test.ts +10 -0
  83. data/features/testing/jest/nuxtjs/typescript/tests/nuxtjs.test.ts +9 -0
  84. data/features/testing/jest/reactjs/javascript/tests/reactjs.test.js +10 -0
  85. data/features/testing/jest/reactjs/typescript/tests/reactjs.test.ts +10 -0
  86. data/features/testing/jest/reactjs-expressjs-shadcn/javascript/tests/reactjs.expressjs.shadcn.test.js +16 -0
  87. data/features/testing/jest/reactjs-expressjs-shadcn/typescript/tests/reactjs.expressjs.shadcn.test.ts +16 -0
  88. data/features/testing/jest/reactjs-nestjs-shadcn/typescript/tests/reactjs.nestjs.shadcn.test.ts +14 -0
  89. data/features/testing/jest/remixjs/typescript/tests/remixjs.test.ts +9 -0
  90. data/features/testing/jest/vuejs/javascript/tests/vuejs.test.ts +9 -0
  91. data/features/testing/jest/vuejs/typescript/tests/vuejs.test.ts +9 -0
  92. data/features/testing/testing.json +102 -0
  93. data/features/ui/ui.json +91 -0
  94. metadata +90 -8
  95. data/features/testing/jest/angularjs/tests/angularjs.test.js +0 -12
  96. data/features/testing/jest/expressjs/tests/javascript/expressjs.test.js +0 -12
  97. data/features/testing/jest/expressjs/tests/typescript/expressjs.test.ts +0 -12
  98. data/features/testing/jest/go/tests/go.test.js +0 -12
  99. data/features/testing/jest/nextjs/tests/javascript/nextjs.test.js +0 -12
  100. data/features/testing/jest/nextjs/tests/typescript/nextjs.test.ts +0 -12
@@ -0,0 +1,473 @@
1
+ {
2
+ "auth0": {
3
+ "angularjs": {
4
+ "typescript": {
5
+ "package.json": {
6
+ "action": "install"
7
+ },
8
+ "src/app/login-button.ts": {
9
+ "action": "create"
10
+ },
11
+ "src/app/logout-button.ts": {
12
+ "action": "create"
13
+ },
14
+ "src/app/user-profile.ts": {
15
+ "action": "create"
16
+ },
17
+ "src/main.ts": {
18
+ "action": "overwrite"
19
+ }
20
+ }
21
+ },
22
+ "expressjs": {
23
+ "javascript": {
24
+ "index.js": {
25
+ "action": "prepend"
26
+ },
27
+ "package.json": {
28
+ "action": "install"
29
+ }
30
+ },
31
+ "typescript": {
32
+ "index.ts": {
33
+ "action": "prepend"
34
+ },
35
+ "package.json": {
36
+ "action": "install"
37
+ }
38
+ }
39
+ },
40
+ "nextjs": {
41
+ "javascript": {
42
+ ".env": {
43
+ "action": "append"
44
+ },
45
+ "app/page.jsx": {
46
+ "action": "overwrite"
47
+ },
48
+ "lib/auth0.js": {
49
+ "action": "create"
50
+ },
51
+ "middleware.js": {
52
+ "action": "create"
53
+ },
54
+ "package.json": {
55
+ "action": "install"
56
+ }
57
+ },
58
+ "typescript": {
59
+ ".env": {
60
+ "action": "append"
61
+ },
62
+ "app/page.tsx": {
63
+ "action": "overwrite"
64
+ },
65
+ "lib/auth0.ts": {
66
+ "action": "create"
67
+ },
68
+ "middleware.ts": {
69
+ "action": "overwrite"
70
+ },
71
+ "package.json": {
72
+ "action": "install"
73
+ }
74
+ }
75
+ },
76
+ "vuejs": {
77
+ "javascript": {
78
+ "package.json": {
79
+ "action": "install"
80
+ },
81
+ "src/components/LoginButton.vue": {
82
+ "action": "create"
83
+ },
84
+ "src/components/LogoutButton.vue": {
85
+ "action": "create"
86
+ },
87
+ "src/components/UserProfile.vue": {
88
+ "action": "create"
89
+ },
90
+ "src/components/login.vue": {
91
+ "action": "create"
92
+ },
93
+ "src/components/logout.vue": {
94
+ "action": "create"
95
+ },
96
+ "src/components/profile.vue": {
97
+ "action": "create"
98
+ },
99
+ "src/main.js": {
100
+ "action": "overwrite"
101
+ }
102
+ },
103
+ "typescript": {
104
+ "package.json": {
105
+ "action": "install"
106
+ },
107
+ "src/components/LoginButton.vue": {
108
+ "action": "create"
109
+ },
110
+ "src/components/LogoutButton.vue": {
111
+ "action": "create"
112
+ },
113
+ "src/components/UserProfile.vue": {
114
+ "action": "create"
115
+ },
116
+ "src/components/login.vue": {
117
+ "action": "create"
118
+ },
119
+ "src/components/logout.vue": {
120
+ "action": "create"
121
+ },
122
+ "src/components/profile.vue": {
123
+ "action": "create"
124
+ },
125
+ "src/main.ts": {
126
+ "action": "overwrite"
127
+ },
128
+ "main.ts": {
129
+ "action": "prepend"
130
+ }
131
+ }
132
+ },
133
+ "django": {
134
+ "backend": {
135
+ "apiexample/validator.py": {
136
+ "action": "create"
137
+ },
138
+ "apiexample/urls.py": {
139
+ "action": "create"
140
+ },
141
+ "apiexample/views.py": {
142
+ "action": "create"
143
+ },
144
+ "requirements.txt": {
145
+ "action": "install"
146
+ },
147
+ ".env": {
148
+ "action": "append"
149
+ }
150
+ },
151
+ "web-app": {
152
+ "webappexample/settings.py": {
153
+ "action": "create"
154
+ },
155
+ "webappexample/urls.py": {
156
+ "action": "create"
157
+ },
158
+ "webappexample/views.py": {
159
+ "action": "create"
160
+ },
161
+ "webappexample/templates/index.html": {
162
+ "action": "create"
163
+ },
164
+ "requirements.txt": {
165
+ "action": "install"
166
+ },
167
+ ".env": {
168
+ "action": "append"
169
+ }
170
+ }
171
+ },
172
+ "go": {
173
+ "backend": {
174
+ "middleware/jwt.go": {
175
+ "action": "create"
176
+ },
177
+ "main.go": {
178
+ "action": "append"
179
+ },
180
+ "go.mod": {
181
+ "action": "install"
182
+ },
183
+ ".env": {
184
+ "action": "append"
185
+ }
186
+ },
187
+ "web-app": {
188
+ "main.go": {
189
+ "action": "append"
190
+ },
191
+ "auth.go": {
192
+ "action": "create"
193
+ },
194
+ "callback.go": {
195
+ "action": "create"
196
+ },
197
+ "isAuthenticated.go": {
198
+ "action": "create"
199
+ },
200
+ "login.go": {
201
+ "action": "create"
202
+ },
203
+ "logout.go": {
204
+ "action": "create"
205
+ },
206
+ "router.go": {
207
+ "action": "create"
208
+ },
209
+ "user.go": {
210
+ "action": "create"
211
+ },
212
+ "go.mod": {
213
+ "action": "install"
214
+ },
215
+ ".env": {
216
+ "action": "append"
217
+ }
218
+ }
219
+ },
220
+ "ruby-on-rails": {
221
+ "backend": {
222
+ "app/controllers/concern/secured.rb": {
223
+ "action": "create"
224
+ },
225
+ "app/controllers/application_controller.rb": {
226
+ "action": "create"
227
+ },
228
+ "app/controllers/private_controller.rb": {
229
+ "action": "create"
230
+ },
231
+ "app/controllers/public_controller.rb": {
232
+ "action": "create"
233
+ },
234
+ "app/lib/auth0_client.rb": {
235
+ "action": "create"
236
+ },
237
+ "Gemfile": {
238
+ "action": "install"
239
+ }
240
+ },
241
+ "web-app": {
242
+ "config/initializers/auth0.rb": {
243
+ "action": "create"
244
+ },
245
+ "config/auth0.yml": {
246
+ "action": "create"
247
+ },
248
+ "config/routes.rb": {
249
+ "action": "create"
250
+ },
251
+ "config/secured.rb": {
252
+ "action": "create"
253
+ },
254
+ "auth0_controller.rb": {
255
+ "action": "create"
256
+ },
257
+ "Gemfile": {
258
+ "action": "install"
259
+ }
260
+ }
261
+ }
262
+ },
263
+ "clerk": {
264
+ "expressjs": {
265
+ "javascript": {
266
+ ".env": {
267
+ "action": "append"
268
+ },
269
+ "index.js": {
270
+ "action": "prepend"
271
+ },
272
+ "package.json": {
273
+ "action": "install"
274
+ }
275
+ },
276
+ "typescript": {
277
+ ".env": {
278
+ "action": "append"
279
+ },
280
+ "index.ts": {
281
+ "action": "prepend"
282
+ },
283
+ "package.json": {
284
+ "action": "install"
285
+ },
286
+ "types/global.d.ts": {
287
+ "action": "create"
288
+ }
289
+ }
290
+ },
291
+ "nextjs": {
292
+ "javascript": {
293
+ ".env": {
294
+ "action": "append"
295
+ },
296
+ "app/layout.js": {
297
+ "action": "overwrite"
298
+ },
299
+ "middleware.js": {
300
+ "action": "create"
301
+ },
302
+ "package.json": {
303
+ "action": "install"
304
+ }
305
+ },
306
+ "typescript": {
307
+ ".env": {
308
+ "action": "append"
309
+ },
310
+ "app/layout.tsx": {
311
+ "action": "overwrite"
312
+ },
313
+ "middleware.ts": {
314
+ "action": "create"
315
+ },
316
+ "package.json": {
317
+ "action": "install"
318
+ }
319
+ }
320
+ },
321
+ "reactjs": {
322
+ "javascript": {
323
+ ".env": {
324
+ "action": "append"
325
+ },
326
+ "package.json": {
327
+ "action": "install"
328
+ },
329
+ "src/App.jsx": {
330
+ "action": "overwrite"
331
+ },
332
+ "src/main.jsx": {
333
+ "action": "overwrite"
334
+ }
335
+ },
336
+ "typescript": {
337
+ ".env": {
338
+ "action": "append"
339
+ },
340
+ "package.json": {
341
+ "action": "install"
342
+ },
343
+ "src/App.tsx": {
344
+ "action": "overwrite"
345
+ },
346
+ "src/main.tsx": {
347
+ "action": "overwrite"
348
+ }
349
+ }
350
+ },
351
+ "remixjs": {
352
+ "typescript": {
353
+ ".env": {
354
+ "action": "append"
355
+ },
356
+ "app/root.tsx": {
357
+ "action": "overwrite"
358
+ },
359
+ "package.json": {
360
+ "action": "install"
361
+ },
362
+ "routes/_index.tsx": {
363
+ "action": "create"
364
+ },
365
+ "app/routes/_index.tsx": {
366
+ "action": "prepend"
367
+ }
368
+ }
369
+ },
370
+ "vuejs": {
371
+ "javascript": {
372
+ ".env": {
373
+ "action": "append"
374
+ },
375
+ "package.json": {
376
+ "action": "install"
377
+ },
378
+ "src/App.vue": {
379
+ "action": "overwrite"
380
+ },
381
+ "src/main.js": {
382
+ "action": "overwrite"
383
+ }
384
+ },
385
+ "typescript": {
386
+ ".env": {
387
+ "action": "append"
388
+ },
389
+ "package.json": {
390
+ "action": "install"
391
+ },
392
+ "src/App.vue": {
393
+ "action": "overwrite"
394
+ },
395
+ "src/main.ts": {
396
+ "action": "overwrite"
397
+ }
398
+ }
399
+ },
400
+ "go": {
401
+ "main.go": {
402
+ "action": "append"
403
+ },
404
+ "clerk_client.go": {
405
+ "action": "create"
406
+ },
407
+ "go.mod": {
408
+ "action": "install"
409
+ }
410
+ },
411
+ "ruby-on-rails": {
412
+ "Gemfile": {
413
+ "action": "install"
414
+ },
415
+ "app.rb": {
416
+ "action": "prepend"
417
+ },
418
+ "config/initializers/clerk.rb": {
419
+ "action": "create"
420
+ }
421
+ }
422
+ },
423
+ "next-auth": {
424
+ "nextjs": {
425
+ "javascript": {
426
+ ".env": {
427
+ "action": "append"
428
+ },
429
+ "app/api/auth/[...nextauth]/route.js": {
430
+ "action": "create"
431
+ },
432
+ "app/layout.jsx": {
433
+ "action": "overwrite"
434
+ },
435
+ "lib/auth-provider.jsx": {
436
+ "action": "create"
437
+ },
438
+ "lib/auth.js": {
439
+ "action": "create"
440
+ },
441
+ "middleware.js": {
442
+ "action": "create"
443
+ },
444
+ "package.json": {
445
+ "action": "install"
446
+ }
447
+ },
448
+ "typescript": {
449
+ ".env": {
450
+ "action": "append"
451
+ },
452
+ "app/api/auth/[...nextauth]/route.ts": {
453
+ "action": "create"
454
+ },
455
+ "app/layout.tsx": {
456
+ "action": "overwrite"
457
+ },
458
+ "lib/auth-provider.tsx": {
459
+ "action": "create"
460
+ },
461
+ "lib/auth.ts": {
462
+ "action": "create"
463
+ },
464
+ "middleware.ts": {
465
+ "action": "create"
466
+ },
467
+ "package.json": {
468
+ "action": "install"
469
+ }
470
+ }
471
+ }
472
+ }
473
+ }
@@ -0,0 +1,10 @@
1
+ from django.contrib import admin
2
+ from django.urls import path
3
+ from . import views
4
+
5
+ urlpatterns = [
6
+ path('admin/', admin.site.urls),
7
+ path('api/public', views.public),
8
+ path('api/private', views.private),
9
+ path('api/private-scoped', views.private_scoped)
10
+ ]
@@ -0,0 +1,21 @@
1
+ import json
2
+ from urllib.request import urlopen
3
+
4
+ from authlib.oauth2.rfc7523 import JWTBearerTokenValidator
5
+ from authlib.jose.rfc7517.jwk import JsonWebKey
6
+
7
+ class Auth0JWTBearerTokenValidator(JWTBearerTokenValidator):
8
+ def __init__(self, domain, audience):
9
+ issuer = f"https://{domain}/"
10
+ jsonurl = urlopen(f"{issuer}.well-known/jwks.json")
11
+ public_key = JsonWebKey.import_key_set(
12
+ json.loads(jsonurl.read())
13
+ )
14
+ super(Auth0JWTBearerTokenValidator, self).__init__(
15
+ public_key
16
+ )
17
+ self.claims_options = {
18
+ "exp": {"essential": True},
19
+ "aud": {"essential": True, "value": audience},
20
+ "iss": {"essential": True, "value": issuer},
21
+ }
@@ -0,0 +1,30 @@
1
+ from authlib.integrations.django_oauth2 import ResourceProtector
2
+ from django.http import JsonResponse
3
+ from . import validator
4
+
5
+ require_auth = ResourceProtector()
6
+ validator = validator.Auth0JWTBearerTokenValidator(
7
+ "{yourDomain}",
8
+ "{yourApiIdentifier}"
9
+ )
10
+ require_auth.register_token_validator(validator)
11
+
12
+ def public(request):
13
+ """No access token required to access this route
14
+ """
15
+ response = "Hello from a public endpoint! You don't need to be authenticated to see this."
16
+ return JsonResponse(dict(message=response))
17
+
18
+ @require_auth(None)
19
+ def private(request):
20
+ """A valid access token is required to access this route
21
+ """
22
+ response = "Hello from a private endpoint! You need to be authenticated to see this."
23
+ return JsonResponse(dict(message=response))
24
+
25
+ @require_auth("read:messages")
26
+ def private_scoped(request):
27
+ """A valid access token and an appropriate scope are required to access this route
28
+ """
29
+ response = "Hello from a private endpoint! You need to be authenticated and have a scope of read:messages to see this."
30
+ return JsonResponse(dict(message=response))
@@ -0,0 +1,4 @@
1
+ authlib ~= 1.0
2
+ django ~= 4.0
3
+ python-dotenv ~= 0.19
4
+ requests ~= 2.27
@@ -0,0 +1,4 @@
1
+ authlib ~= 1.0
2
+ django ~= 4.0
3
+ python-dotenv ~= 0.19
4
+ requests ~= 2.27
@@ -0,0 +1,28 @@
1
+ import os
2
+ from pathlib import Path
3
+ from dotenv import load_dotenv, find_dotenv
4
+
5
+ # Build paths inside the project like this: BASE_DIR / 'subdir'.
6
+ BASE_DIR = Path(__file__).resolve().parent.parent
7
+ TEMPLATE_DIR = os.path.join(BASE_DIR, "webappexample", "templates")
8
+
9
+ # ... other settings ...
10
+
11
+ TEMPLATES = [
12
+ {
13
+ # Leave other lines as they are; we're just updating `DIRS`.
14
+ "DIRS": [TEMPLATE_DIR],
15
+ },
16
+ ]
17
+
18
+ # ... other settings ...
19
+
20
+ # Load environment definition file
21
+ ENV_FILE = find_dotenv()
22
+ if ENV_FILE:
23
+ load_dotenv(ENV_FILE)
24
+
25
+ # Load Auth0 application settings into memory
26
+ AUTH0_DOMAIN = os.environ.get("AUTH0_DOMAIN")
27
+ AUTH0_CLIENT_ID = os.environ.get("AUTH0_CLIENT_ID")
28
+ AUTH0_CLIENT_SECRET = os.environ.get("AUTH0_CLIENT_SECRET")
@@ -0,0 +1,16 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8" />
4
+ <title>Auth0 Example</title>
5
+ </head>
6
+ <body>
7
+ {% if session %}
8
+ <h1>Welcome {{session.userinfo.name}}!</h1>
9
+ <p><a href="{% url 'logout' %}">Logout</a></p>
10
+ <div><pre>{{pretty}}</pre></div>
11
+ {% else %}
12
+ <h1>Welcome Guest</h1>
13
+ <p><a href="{% url 'login' %}">Login</a></p>
14
+ {% endif %}
15
+ </body>
16
+ </html>
@@ -0,0 +1,10 @@
1
+ from django.urls import path
2
+
3
+ from . import views
4
+
5
+ urlpatterns = [
6
+ path("", views.index, name="index"),
7
+ path("login", views.login, name="login"),
8
+ path("logout", views.logout, name="logout"),
9
+ path("callback", views.callback, name="callback"),
10
+ ]
@@ -0,0 +1,52 @@
1
+ import json
2
+ from authlib.integrations.django_client import OAuth
3
+ from django.conf import settings
4
+ from django.shortcuts import redirect, render, redirect
5
+ from django.urls import reverse
6
+ from urllib.parse import quote_plus, urlencode
7
+
8
+ oauth = OAuth()
9
+
10
+ oauth.register(
11
+ "auth0",
12
+ client_id=settings.AUTH0_CLIENT_ID,
13
+ client_secret=settings.AUTH0_CLIENT_SECRET,
14
+ client_kwargs={
15
+ "scope": "openid profile email",
16
+ },
17
+ server_metadata_url=f"https://{settings.AUTH0_DOMAIN}/.well-known/openid-configuration",
18
+ )
19
+
20
+ def login(request):
21
+ return oauth.auth0.authorize_redirect(
22
+ request, request.build_absolute_uri(reverse("callback"))
23
+ )
24
+
25
+ def callback(request):
26
+ token = oauth.auth0.authorize_access_token(request)
27
+ request.session["user"] = token
28
+ return redirect(request.build_absolute_uri(reverse("index")))
29
+
30
+ def logout(request):
31
+ request.session.clear()
32
+
33
+ return redirect(
34
+ f"https://{settings.AUTH0_DOMAIN}/v2/logout?"
35
+ + urlencode(
36
+ {
37
+ "returnTo": request.build_absolute_uri(reverse("index")),
38
+ "client_id": settings.AUTH0_CLIENT_ID,
39
+ },
40
+ quote_via=quote_plus,
41
+ ),
42
+ )
43
+
44
+ def index(request):
45
+ return render(
46
+ request,
47
+ "index.html",
48
+ context={
49
+ "session": request.session.get("user"),
50
+ "pretty": json.dumps(request.session.get("user"), indent=4),
51
+ },
52
+ )
@@ -0,0 +1,8 @@
1
+ module 01-Authorization-RS256
2
+ go 1.25.1
3
+ require (
4
+ github.com/auth0/go-jwt-middleware/v2 v2.2.0
5
+
6
+ github.com/joho/godotenv v1.5.1
7
+
8
+ )