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

IS-1488: Added unleash api token file #996

Merged
merged 23 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b61b607
IS-1488: Added unleash api token file
vetlesolgaard Aug 21, 2023
fecf612
IS-1488: Fix url for unleash api
vetlesolgaard Aug 21, 2023
daa0ceb
IS-1488: Possible fix for unleash-apitoken.yaml
vetlesolgaard Aug 21, 2023
89a337a
IS-1488: Remove secrets
vetlesolgaard Aug 22, 2023
e9fc1a7
IS-1488: Readd secret
vetlesolgaard Aug 22, 2023
3bf201d
IS-1488: Added unleash next in backend for frontend
vetlesolgaard Aug 22, 2023
9739787
Merge branch 'master' into IS-1488-Migrate-to-unleash-next
vetlesolgaard Aug 23, 2023
4df9457
IS-1488: Test
vetlesolgaard Aug 23, 2023
bbda65c
Merge branch 'master' into IS-1488-Migrate-to-unleash-next
vetlesolgaard Aug 23, 2023
9b32687
IS-1488: Test
vetlesolgaard Aug 24, 2023
75cfd69
Merge branch 'master' into IS-1488-Migrate-to-unleash-next
vetlesolgaard Aug 24, 2023
46c7b76
IS-1488: Update unleash client
vetlesolgaard Aug 24, 2023
c2b4a2b
IS-1488: Possible fix
vetlesolgaard Aug 24, 2023
3607787
IS:1488: Remove comments + cleanup
vetlesolgaard Aug 25, 2023
9c29415
IS-1488: Add use of secrets for url and token to unleash
vetlesolgaard Aug 25, 2023
f527eea
IS-1488:
vetlesolgaard Aug 25, 2023
1f80d6e
IS-1488: Test using secret to get token and api url
vetlesolgaard Aug 28, 2023
8bc4e34
Merge branch 'master' into IS-1488-Migrate-to-unleash-next
vetlesolgaard Aug 28, 2023
be144ef
IS-1488: Test using environment variables for url and token
vetlesolgaard Aug 28, 2023
deea096
IS-1488: Add isBehandlerdialogLegeerklaring toggle
vetlesolgaard Aug 28, 2023
c2427b5
IS-1488: Removed unused toggles + added new one
vetlesolgaard Aug 29, 2023
48c140a
IS-1488: Merge from master
vetlesolgaard Aug 29, 2023
6b34e43
Merge branch 'master' into IS-1488-Migrate-to-unleash-next
vetlesolgaard Aug 29, 2023
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
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ SYFOVEILEDER_AAD_APP_CLIENT_ID=dev-fss.teamsykefravr.syfoveileder
SYFOVEILEDER_HOST=syfoveileder.dev.intern.nav.no
ESYFOVARSEL_AAD_APP_CLIENT_ID=dev-gcp.team-esyfo.esyfovarsel
ESYFOVARSEL_HOST=http://esyfovarsel.intern.dev.no

UNLEASH_SERVER_API_URL=https://teamsykefravr-unleash-api.nav.cloud.nais.io/api
UNLEASH_SERVER_API_TOKEN=kjempesikkert-token
LOG_LEVEL=debug
28 changes: 28 additions & 0 deletions .github/workflows/unleash-apitoken.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy unleash api-tokens
on:
push:
branches:
- master
paths:
- '.github/workflows/unleash-apitokens.yaml'
- '.nais/unleash/unleash-apitoken-dev.yaml'
- '.nais/unleash/unleash-apitoken-prod.yaml'
jobs:
apply-apitoken-unleash:
name: Apply ApiToken for Unleash to cluster
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to dev
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/unleash/unleash-apitoken-dev.yaml
- name: Deploy to prod
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: .nais/unleash/unleash-apitoken-prod.yaml
2 changes: 2 additions & 0 deletions .nais/naiserator-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ spec:
external:
- host: "login.microsoftonline.com"
- host: "unleash.nais.io"
- host: "teamsykefravr-unleash-api.nav.cloud.nais.io"
- host: "internarbeidsflatedecorator-q1.dev-fss-pub.nais.io"
- host: "modiacontextholder-q1.dev-fss-pub.nais.io"
- host: "ereg-services-q1.dev-fss-pub.nais.io"
Expand Down Expand Up @@ -78,6 +79,7 @@ spec:
envFrom:
- secret: syfomodiaperson-session-key
- secret: syfomodiaperson-redis-password
- secret: syfomodiaperson-unleash-api-token
ingresses:
- "https://syfomodiaperson.intern.dev.nav.no"
env:
Expand Down
2 changes: 2 additions & 0 deletions .nais/naiserator-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ spec:
external:
- host: "login.microsoftonline.com"
- host: "unleash.nais.io"
- host: "teamsykefravr-unleash-api.nav.cloud.nais.io"
- host: "internarbeidsflatedecorator.prod-fss-pub.nais.io"
- host: "modiacontextholder.prod-fss-pub.nais.io"
- host: "ereg-services.prod-fss-pub.nais.io"
Expand Down Expand Up @@ -78,6 +79,7 @@ spec:
envFrom:
- secret: syfomodiaperson-session-key
- secret: syfomodiaperson-redis-password
- secret: syfomodiaperson-unleash-api-token
ingresses:
- "https://syfomodiaperson.intern.nav.no"
env:
Expand Down
14 changes: 14 additions & 0 deletions .nais/unleash/unleash-apitoken-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: unleash.nais.io/v1
kind: ApiToken
metadata:
name: syfomodiaperson
namespace: teamsykefravr
labels:
team: teamsykefravr
spec:
unleashInstance:
apiVersion: unleash.nais.io/v1
kind: RemoteUnleash
name: teamsykefravr
secretName: syfomodiaperson-unleash-api-token
environment: development
14 changes: 14 additions & 0 deletions .nais/unleash/unleash-apitoken-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: unleash.nais.io/v1
kind: ApiToken
metadata:
name: syfomodiaperson
namespace: teamsykefravr
labels:
team: teamsykefravr
spec:
unleashInstance:
apiVersion: unleash.nais.io/v1
kind: RemoteUnleash
name: teamsykefravr
secretName: syfomodiaperson-unleash-api-token
environment: production
6 changes: 3 additions & 3 deletions mock/mockEndepunkter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { mockIspengestopp } from "./ispengestopp/mockIspengestopp";
import { mockIsdialogmote } from "./isdialogmote/mockIsdialogmote";
import { mockIsdialogmotekandidat } from "./isdialogmotekandidat/mockIsdialogmotekandidat";
import { mockSyfoveileder } from "./syfoveileder/mockSyfoveileder";
import { mockUnleash } from "./unleash/mockUnleash";
import { mockUnleashEndpoint } from "./unleashMocks";
import { mockIsdialogmelding } from "./isdialogmelding/mockIsdialogmelding";
import { mockIsaktivitetskrav } from "./isaktivitetskrav/mockIsaktivitetskrav";
import { mockIsbehandlerdialog } from "./isbehandlerdialog/mockIsbehandlerdialog";
import { mockEsyfovarsel } from "./esyfovarsel/mockEsyfovarsel";

const express = require("express");
import express from "express";

const mockEndepunkter = (server: any) => {
server.use(express.json());
Expand Down Expand Up @@ -49,7 +49,7 @@ const mockEndepunkter = (server: any) => {
mockIsdialogmotekandidat,
mockIsdialogmelding,
mockSyfoveileder,
mockUnleash,
mockUnleashEndpoint,
].forEach((func) => {
func(server);
});
Expand Down
14 changes: 0 additions & 14 deletions mock/unleash/mockUnleash.ts

This file was deleted.

8 changes: 0 additions & 8 deletions mock/unleash/unleashMock.ts

This file was deleted.

20 changes: 20 additions & 0 deletions mock/unleashMocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { UNLEASH_ROOT } from "@/apiConstants";
import { ToggleNames } from "@/data/unleash/unleash_types";
import express from "express";

export const mockUnleashEndpoint = (server: any) => {
server.get(
`${UNLEASH_ROOT}/toggles`,
(req: express.Request, res: express.Response) => {
res.setHeader("Content-Type", "application/json");
res.send(JSON.stringify(mockUnleashResponse));
}
);
};

export const mockUnleashResponse = Object.values(ToggleNames).reduce(
(accumulator, toggleName) => {
return { ...accumulator, [toggleName]: true };
},
{}
);
20 changes: 8 additions & 12 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import helmet = require("helmet");
import path = require("path");
import prometheus = require("prom-client");

import * as Config from "./server/config";
import { getOpenIdClient, getOpenIdIssuer } from "./server/authUtils";
import { setupProxy } from "./server/proxy";
import { setupSession } from "./server/session";

import unleashRoutes = require("./server/routes/unleashRoutes");
import Config = require("./server/config");
import unleash = require("./server/unleash");

// Prometheus metrics
const collectDefaultMetrics = prometheus.collectDefaultMetrics;
Expand Down Expand Up @@ -65,18 +64,15 @@ const setupServer = async () => {

server.use("/static", express.static(DIST_DIR));

server.post(
server.get(
"/unleash/toggles",
redirectIfUnauthorized,
(req: express.Request, res: express.Response) => {
const toggles = req.body.toggles;
const unleashToggles = unleashRoutes.unleashToggles(
toggles,
req.query.valgtEnhet,
req.query.userId
(req: express.Request, res: express.Response<unleash.Toggles>) => {
const togglesResponse = unleash.getToggles(
req.query.veilederId,
req.query.enhetId
);

res.status(200).send(unleashToggles);
res.status(200).send(togglesResponse);
}
);

Expand Down
7 changes: 7 additions & 0 deletions server/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dotenv = require("dotenv");

dotenv.config();

const hasEnvVar = (name: any) => {
Expand Down Expand Up @@ -313,10 +314,16 @@ export const redis = {
}),
};

export const unleash: { serverApiUrl: string; serverApiToken: string } = {
serverApiUrl: envVar({ name: "UNLEASH_SERVER_API_URL" }),
serverApiToken: envVar({ name: "UNLEASH_SERVER_API_TOKEN" }),
};

module.exports = {
auth: auth,
isDev: isDev,
isProd: isProd,
redis: redis,
unleash: unleash,
server: server,
};
109 changes: 0 additions & 109 deletions server/routes/unleashRoutes.ts

This file was deleted.

Loading