File tree Expand file tree Collapse file tree 4 files changed +453
-0
lines changed Expand file tree Collapse file tree 4 files changed +453
-0
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,134 @@ override.tf.json
32
32
# Ignore CLI configuration files
33
33
.terraformrc
34
34
terraform.rc
35
+
36
+ # Logs
37
+ logs
38
+ * .log
39
+ npm-debug.log *
40
+ yarn-debug.log *
41
+ yarn-error.log *
42
+ lerna-debug.log *
43
+ .pnpm-debug.log *
44
+
45
+ # Diagnostic reports (https://nodejs.org/api/report.html)
46
+ report. [0-9 ]* . [0-9 ]* . [0-9 ]* . [0-9 ]* .json
47
+
48
+ # Runtime data
49
+ pids
50
+ * .pid
51
+ * .seed
52
+ * .pid.lock
53
+
54
+ # Directory for instrumented libs generated by jscoverage/JSCover
55
+ lib-cov
56
+
57
+ # Coverage directory used by tools like istanbul
58
+ coverage
59
+ * .lcov
60
+
61
+ # nyc test coverage
62
+ .nyc_output
63
+
64
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
65
+ .grunt
66
+
67
+ # Bower dependency directory (https://bower.io/)
68
+ bower_components
69
+
70
+ # node-waf configuration
71
+ .lock-wscript
72
+
73
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
74
+ build /Release
75
+
76
+ # Dependency directories
77
+ node_modules /
78
+ jspm_packages /
79
+
80
+ # Snowpack dependency directory (https://snowpack.dev/)
81
+ web_modules /
82
+
83
+ # TypeScript cache
84
+ * .tsbuildinfo
85
+
86
+ # Optional npm cache directory
87
+ .npm
88
+
89
+ # Optional eslint cache
90
+ .eslintcache
91
+
92
+ # Optional stylelint cache
93
+ .stylelintcache
94
+
95
+ # Microbundle cache
96
+ .rpt2_cache /
97
+ .rts2_cache_cjs /
98
+ .rts2_cache_es /
99
+ .rts2_cache_umd /
100
+
101
+ # Optional REPL history
102
+ .node_repl_history
103
+
104
+ # Output of 'npm pack'
105
+ * .tgz
106
+
107
+ # Yarn Integrity file
108
+ .yarn-integrity
109
+
110
+ # dotenv environment variable files
111
+ .env
112
+ .env.development.local
113
+ .env.test.local
114
+ .env.production.local
115
+ .env.local
116
+
117
+ # parcel-bundler cache (https://parceljs.org/)
118
+ .cache
119
+ .parcel-cache
120
+
121
+ # Next.js build output
122
+ .next
123
+ out
124
+
125
+ # Nuxt.js build / generate output
126
+ .nuxt
127
+ dist
128
+
129
+ # Gatsby files
130
+ .cache /
131
+ # Comment in the public line in if your project uses Gatsby and not Next.js
132
+ # https://nextjs.org/blog/next-9-1#public-directory-support
133
+ # public
134
+
135
+ # vuepress build output
136
+ .vuepress /dist
137
+
138
+ # vuepress v2.x temp and cache directory
139
+ .temp
140
+ .cache
141
+
142
+ # Docusaurus cache and generated files
143
+ .docusaurus
144
+
145
+ # Serverless directories
146
+ .serverless /
147
+
148
+ # FuseBox cache
149
+ .fusebox /
150
+
151
+ # DynamoDB Local files
152
+ .dynamodb /
153
+
154
+ # TernJS port file
155
+ .tern-port
156
+
157
+ # Stores VSCode versions used for testing VSCode extensions
158
+ .vscode-test
159
+
160
+ # yarn v2
161
+ .yarn /cache
162
+ .yarn /unplugged
163
+ .yarn /build-state.yml
164
+ .yarn /install-state.gz
165
+ .pnp. *
Original file line number Diff line number Diff line change
1
+ const jwt = require ( "jsonwebtoken" ) ;
2
+
3
+ // Constants.
4
+ const JWT_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
5
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqoYzW56whkd3QZTZwV5c
6
+ Mg668Jesg4oxc+AIAHSuIMIcqYSR2gPMMAAdpBEfFFL4BMtd2AATHHL55Gsy7TjJ
7
+ QFXlyWcS5wOd045i2BgOG9V7lVfI6PJHvD59uoT03Ksyqp0C5XQYlqdqe9h1ylOw
8
+ 9+1aQROXif+OsaMfjgaz4YTLEXbGFuqEQB4QNuuwqtG8kh6N2rpBP/7ppGKqFga+
9
+ 8hgH5tt4DTqqQBQSykvxNwW+QBSqj/1AGXqY+PO1gNGWgyLWD+oOdyf7o9MiEwXX
10
+ G1/2QXXKW+6P8tDTljCcWO4VqvDQpA5C/RYZhFHHlxxNQC8Nr75fHtoBe2jkuvnY
11
+ GwIDAQAB
12
+ -----END PUBLIC KEY-----` ;
13
+
14
+ exports . handler = async ( event ) => {
15
+ // Gets event header.
16
+ const header =
17
+ typeof event . header === "string" ? JSON . parse ( event . header ) : event . header ;
18
+
19
+ // Needs to be authorized by a given token.
20
+ const token = header . token ;
21
+
22
+ // Object that stores values used by 'jsonwebtoken - verify' function call.
23
+ const jwtSettings = {
24
+ publicKey : JWT_PUBLIC_KEY ,
25
+ options : {
26
+ algorithms : [ "RS256" ] ,
27
+ } ,
28
+ } ;
29
+
30
+ try {
31
+ // Verify and decode the JWT token.
32
+ const decoded = jwt . verify (
33
+ token ,
34
+ jwtSettings . publicKey ,
35
+ jwtSettings . options
36
+ ) ;
37
+
38
+ if ( decoded . sub == null ) {
39
+ return false ;
40
+ }
41
+
42
+ return true ;
43
+ } catch ( error ) {
44
+ return false ;
45
+ }
46
+ } ;
You can’t perform that action at this time.
0 commit comments