Skip to content

Commit bacf01b

Browse files
committed
include binaries for the release
1 parent 17e8df6 commit bacf01b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+9831
-0
lines changed

lambda-release/lambda.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const jwt = require('jsonwebtoken');
2+
const { CLIENT_SECRET, CLIENT_ALG } = require('./template');
3+
4+
function parseToken(headers) {
5+
//see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html
6+
const {authorization = []} = headers;
7+
if (authorization.length > 0) {
8+
for (let i = 0; i < authorization.length; i++) {
9+
const token = authorization[i].value || ''
10+
const prefix = 'Bearer ';
11+
if (token.startsWith(prefix)) {
12+
return token.substring(prefix.length)
13+
}
14+
}
15+
}
16+
17+
return null;
18+
}
19+
20+
function checkToken(token) {
21+
if (!token) return false
22+
23+
try {
24+
const payload = jwt.verify(token, CLIENT_SECRET, {algorithm: [CLIENT_ALG]});
25+
//TODO: check the token if necessary
26+
return true
27+
} catch (e) {
28+
// token exists but it-is invalid
29+
console.log('Failed to verify token', e);
30+
}
31+
return false;
32+
}
33+
34+
function handler(request, callback) {
35+
const token = parseToken(request.headers);
36+
if (checkToken(token)) {
37+
callback(null, request);
38+
} else {
39+
callback(null, {
40+
status: '403',
41+
statusDescription: 'Not Authorized by JetBrains',
42+
body: 'Not Authorized by JetBrains'
43+
});
44+
}
45+
}
46+
47+
exports.handler = (event, context, callback) => {
48+
const request = event.Records[0].cf.request;
49+
handler(request, callback)
50+
};

lambda-release/node_modules/.bin/semver

+160
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda-release/node_modules/buffer-equal-constant-time/.npmignore

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda-release/node_modules/buffer-equal-constant-time/.travis.yml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda-release/node_modules/buffer-equal-constant-time/LICENSE.txt

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda-release/node_modules/buffer-equal-constant-time/README.md

+50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda-release/node_modules/buffer-equal-constant-time/index.js

+41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda-release/node_modules/buffer-equal-constant-time/package.json

+58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)