Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: access token env #490

Merged
merged 8 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cloud/lab/wireguard/env/example.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
U2FsdGVkX1/EKYD6q6uN82RaXr/dmMmnV2+kO5aBHDC2Wpc/Jp7WcHy9IwCI5UCy
a8Z1ffmDQ7mzrc4tvd9J5XhSDsHr9P3KWJgqt0ScWukZ8uEoJV9X4KNBpQc+PC/7
0CJhKID0+zTEhj9Uq/oyjF1X4aL1ZMb5BXw+82DWYalpKBo6RGJTUFYtjbIMYHwZ
gkqkHdFzy5U6XroH0yfYB2BXdab+0Wx7FzWw3CPb1lEwgpRha/FT4oE0Fb7+rA+D
OzvNqjonT3s/sfTd4oXN6m+cYEH7O4UfwmQ9aTASciw72KbbdfxvKAPZEIQSUM75
k/Ryo/bBSuGj/hPvYdUGPW9yMXJ9R4I11m0P4uzh6dyeddtNxCZvuYxQk+MsjmIC
GgzV87awC0CRa7XouSxzIg==
U2FsdGVkX1+5qQykfphrBmm/Md5/h4D5rSpWSB93dnMO4GNUe9gpW2/DmNuMl+dR
+W3Yce7QZjFgEoiApUMnJ37y8N98SrtgSarTGIuQGWfVetWe665WucrMCIidUkPg
c5+qmIRgiCUFOvRT589zfKrsDPHZxAR/9beYyq+SNa3qmE0TQmlBrxt/kieQr0xP
Wm3HFeCEgCeWpCHcDi+Ha68v+nIZqqvg0Tow4eghnV+YxFux2b5GYgEyeDQ9Yi4g
4xz4QLTcHQCxE+iL8LRuBrtpM/2AFlr0RYlUVQl8KUCK3P+ni3EuKB2PNPXpkFod
uq8435COxM7jN53jhnCbNZ86wVwQNRtnJ4cq0aunfwScrHpDF0391l/Y8vOaoM1y
Y0L8ky+xPtMGKKOEmQH8NA==
2 changes: 1 addition & 1 deletion services/comment/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const config = {
host: process.env.HOST ?? '0.0.0.0',
port: process.env.PORT != null ? +process.env.PORT : 8000,
allowAllOrigin: true,
token: process.env.TOKEN ?? 'YOUR_SECRET_TOKEN',
accessToken: process.env.ACCESS_TOKEN ?? 'YOUR_SECRET_TOKEN',
},
storage: {
host: process.env.STORAGE_HOST ?? '127.0.0.1',
Expand Down
2 changes: 1 addition & 1 deletion services/comment/src/route/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nanoServer.route('GET', '/all', getAllComment);
async function getAllComment(connection: AlwatrConnection): Promise<void> {
logger.logMethod('getAllComment');

const token = connection.requireToken(config.nanoServer.token);
const token = connection.requireToken(config.nanoServer.accessToken);
if (token == null) return;

const params = connection.requireQueryParams<{storage: string}>({storage: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/comment/src/route/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nanoServer.route('PATCH', '/', setComment);
async function setComment(connection: AlwatrConnection): Promise<void> {
logger.logMethod('setComment');

const token = connection.requireToken(config.nanoServer.token);
const token = connection.requireToken(config.nanoServer.accessToken);
if (token == null) return;

const params = connection.requireQueryParams<{storage: string}>({storage: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/storage-server/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const config = {
host: process.env.HOST ?? '0.0.0.0',
port: process.env.PORT != null ? +process.env.PORT : 9000,
storagePath: process.env.STORAGE_PATH ?? 'db',
token: process.env.TOKEN ?? 'YOUR_SECRET_TOKEN',
accessToken: process.env.ACCESS_TOKEN ?? 'YOUR_SECRET_TOKEN',
};

logger.logProperty('config', {...config, token: '***'});
2 changes: 1 addition & 1 deletion services/storage-server/src/route/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nanoServer.route('GET', '/all', getAllDocument);
async function getAllDocument(connection: AlwatrConnection): Promise<void> {
logger.logMethod('getAllDocument');

const token = connection.requireToken(config.token);
const token = connection.requireToken(config.accessToken);
if (token == null) return;

const params = connection.requireQueryParams<{storage: string}>({storage: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/storage-server/src/route/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nanoServer.route('DELETE', 'all', removeDocument);
async function removeDocument(connection: AlwatrConnection): Promise<void> {
logger.logMethodArgs('updateDocument', {method: connection.method});

const token = connection.requireToken(config.token);
const token = connection.requireToken(config.accessToken);
if (token == null) return;

const param = connection.requireQueryParams<{storage: string; id: string}>({storage: 'string', id: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/storage-server/src/route/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getDocument(connection: AlwatrConnection): void {
});
}

const token = connection.requireToken(config.token);
const token = connection.requireToken(config.accessToken);
if (token == null) return;

const params = connection.requireQueryParams<{storage: string; id: string}>({storage: 'string', id: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/storage-server/src/route/has.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nanoServer.route('GET', '/has', has);
async function has(connection: AlwatrConnection): Promise<void> {
logger.logMethod('has');

const token = connection.requireToken(config.token);
const token = connection.requireToken(config.accessToken);
if (token == null) return;

const params = connection.requireQueryParams<{storage: string; id: string}>({storage: 'string', id: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/storage-server/src/route/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nanoServer.route('GET', '/keys', getStorageKeys);
async function getStorageKeys(connection: AlwatrConnection): Promise<void> {
logger.logMethod('getStorageKeys');

const token = connection.requireToken(config.token);
const token = connection.requireToken(config.accessToken);
if (token == null) return;

const params = connection.requireQueryParams<{storage: string}>({storage: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/storage-server/src/route/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nanoServer.route('PATCH', 'all', updateDocument);
async function updateDocument(connection: AlwatrConnection): Promise<void> {
logger.logMethod('updateDocument');

const token = connection.requireToken(config.token);
const token = connection.requireToken(config.accessToken);
if (token == null) return;

const param = connection.requireQueryParams<{storage: string}>({storage: 'string'});
Expand Down
2 changes: 1 addition & 1 deletion services/telegram-notifier/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const config = {
nanoServer: {
host: process.env.HOST ?? '0.0.0.0',
port: process.env.PORT != null ? +process.env.PORT : 8001,
token: process.env.TOKEN ?? 'YOUR_SECRET_TOKEN',
accessToken: process.env.ACCESS_TOKEN ?? 'YOUR_SECRET_TOKEN',
},
storage: {
path: process.env.STORAGE_PATH ?? 'db',
Expand Down
2 changes: 1 addition & 1 deletion services/telegram-notifier/src/route/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nanoServer.route('POST', '/', notify);
async function notify(connection: AlwatrConnection): Promise<void> {
logger.logMethod('notify');

if (connection.requireToken(config.nanoServer.token) == null) return;
if (connection.requireToken(config.nanoServer.accessToken) == null) return;

const bodyJson = await connection.requireJsonBody<{to: string; message: string}>();
if (bodyJson == null) return;
Expand Down
2 changes: 1 addition & 1 deletion uniquely/flight-finder-api/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const config = {
nanoServer: {
host: process.env.HOST ?? '0.0.0.0',
port: process.env.PORT != null ? +process.env.PORT : 8000,
token: process.env.TOKEN ?? 'YOUR_SECRET_TOKEN',
accessToken: process.env.ACCESS_TOKEN ?? 'YOUR_SECRET_TOKEN',
},
};

Expand Down
2 changes: 1 addition & 1 deletion uniquely/flight-finder-api/src/route/job/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nanoServer.route('DELETE', '/job', deleteJob);
async function deleteJob(connection: AlwatrConnection): Promise<void> {
logger.logMethod('deleteJob');

if (connection.requireToken(config.nanoServer.token) == null) return;
if (connection.requireToken(config.nanoServer.accessToken) == null) return;

const params = connection.requireQueryParams<{id: string}>({id: 'string'});
if (params === null) return;
Expand Down
2 changes: 1 addition & 1 deletion uniquely/flight-finder-api/src/route/job/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nanoServer.route('GET', '/job', getJob);
async function getJob(connection: AlwatrConnection): Promise<void> {
logger.logMethod('getJob');

if (connection.requireToken(config.nanoServer.token) == null) return;
if (connection.requireToken(config.nanoServer.accessToken) == null) return;

try {
connection.reply({
Expand Down
2 changes: 1 addition & 1 deletion uniquely/flight-finder-api/src/route/job/put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nanoServer.route('PUT', '/job', newJob);
async function newJob(connection: AlwatrConnection): Promise<void> {
logger.logMethod('newJob');

if (connection.requireToken(config.nanoServer.token) == null) return;
if (connection.requireToken(config.nanoServer.accessToken) == null) return;

const job = await connection.requireJsonBody<Job>();
if (job === null) return;
Expand Down