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