File tree Expand file tree Collapse file tree 4 files changed +445
-0
lines changed Expand file tree Collapse file tree 4 files changed +445
-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 = process . env . JWT_PUBLIC_KEY ;
5
+
6
+ exports . handler = async ( event ) => {
7
+ // Gets event header.
8
+ const header =
9
+ typeof event . header === "string" ? JSON . parse ( event . header ) : event . header ;
10
+
11
+ // Needs to be authorized by a given token.
12
+ const token = header . token ;
13
+
14
+ // Object that stores values used by 'jsonwebtoken - verify' function call.
15
+ const jwtSettings = {
16
+ publicKey : JWT_PUBLIC_KEY ,
17
+ options : {
18
+ algorithms : [ "RS256" ] ,
19
+ } ,
20
+ } ;
21
+
22
+ try {
23
+ // Verify and decode the JWT token.
24
+ const decoded = jwt . verify (
25
+ token ,
26
+ jwtSettings . publicKey ,
27
+ jwtSettings . options
28
+ ) ;
29
+
30
+ if ( decoded . sub == null ) {
31
+ return false ;
32
+ }
33
+
34
+ return true ;
35
+ } catch ( error ) {
36
+ return false ;
37
+ }
38
+ } ;
You can’t perform that action at this time.
0 commit comments