add lidar

master
Paul Walko 2022-02-23 08:36:33 -05:00
parent ea50afa4ec
commit d3c68bc333
1 changed files with 16 additions and 15 deletions

View File

@ -4,6 +4,7 @@ const { S3Client, GetObjectCommand } = require('@aws-sdk/client-s3');
const KV = { const KV = {
'skydusky': SKYDUSKY 'skydusky': SKYDUSKY
}; };
const noauth = ['lidar'];
/************************************************************/ /************************************************************/
/* /*
@ -69,12 +70,10 @@ function BadRequestException(reason) {
* @throws {UnauthorizedException} * @throws {UnauthorizedException}
*/ */
async function verifyCredentials(store, user, pass) { async function verifyCredentials(store, user, pass) {
console.log(`STORE: ${store}`)
if (!KV.hasOwnProperty(store)) { if (!KV.hasOwnProperty(store)) {
throw new UnauthorizedException('Invalid password.'); throw new UnauthorizedException('Invalid password.');
} }
const KVpass = await KV[store].get(user); const KVpass = await KV[store].get(user);
console.log(`PASS: ${KVpass}`)
if (KVpass === 'null' || KVpass !== pass) { if (KVpass === 'null' || KVpass !== pass) {
throw new UnauthorizedException('Invalid password.'); throw new UnauthorizedException('Invalid password.');
} }
@ -89,6 +88,7 @@ async function handleRequest(request) {
const path = requestURL.pathname.substring(1); const path = requestURL.pathname.substring(1);
const area = path.split('/')[0]; const area = path.split('/')[0];
if (!noauth.includes(area)) {
// Prompt login // Prompt login
if (!request.headers.has('Authorization')) { if (!request.headers.has('Authorization')) {
return new Response('Please login.', { return new Response('Please login.', {
@ -104,6 +104,7 @@ async function handleRequest(request) {
} catch (e) { } catch (e) {
return e; return e;
} }
}
// S3 Client // S3 Client
const client = new S3Client({ const client = new S3Client({