Skip to content

Commit

Permalink
add missing files. oopsie.
Browse files Browse the repository at this point in the history
  • Loading branch information
andnorda authored and Oddsor committed Mar 19, 2024
1 parent 44c9b73 commit 1d5c8cc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/src/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as oasis from '@navikt/oasis';
import { IncomingMessage } from 'http';

export const requestOboToken = async (audience: string, req: IncomingMessage) => {
const token = oasis.getToken(req);
if (!token) {
// TODO: handle missing token
throw Error('missing token in req');
}

const validation = await oasis.validateToken(token);
if (!validation.ok) {
// TODO: handle validation error
throw validation.error;
}

const obo = await oasis.requestOboToken(token, audience);
if (!obo.ok) {
// TODO: handle obo error
throw obo.error;
}

return obo.token;
};
23 changes: 23 additions & 0 deletions server/src/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { getMiljo, Miljo } from './paths/miljo';
import labsProxy from './proxy/labs-proxy';
import apiProxy from './proxy/api-proxy';
import decoratorInternProxy from './proxy/decorator-intern-proxy';
import notifikasjonProxy from './proxy/notifikasjoner-proxy';
import decoratorEksternProxy from './proxy/decorator-ekstern-proxy';
import { Express } from 'express';

export const setupRoutes = async (server: Express) => {
const miljo: Miljo = getMiljo();

if (miljo === Miljo.DEV_GCP || miljo === Miljo.PROD_GCP) {
apiProxy.azureSetup(server);

if (process.env.INTERN_INGRESS) {
decoratorInternProxy.setup(server);
} else {
notifikasjonProxy.setup(server);
decoratorEksternProxy.setup(server);
}
}
labsProxy.setup(server);
};

0 comments on commit 1d5c8cc

Please sign in to comment.