Skip to content

Commit

Permalink
fix: working node vault
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens committed May 29, 2024
1 parent f5b40b4 commit ba254f1
Show file tree
Hide file tree
Showing 5 changed files with 373 additions and 74 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ENV NEXT_TELEMETRY_DISABLED 1
ARG NEXT_PUBLIC_HASURA_URL
ENV NEXT_PUBLIC_HASURA_URL $NEXT_PUBLIC_HASURA_URL

ENV SENTRY_PROJECT=fabnum-carnets
ENV SENTRY_ORG=incubateur
# ENV SENTRY_PROJECT=fabnum-carnets
# ENV SENTRY_ORG=incubateur

RUN --mount=type=secret,id=sentry_auth_token \
export SENTRY_AUTH_TOKEN=$(cat /run/secrets/sentry_auth_token); \
Expand Down
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = withSentryConfig(
// Suppresses source map uploading logs during build
silent: true,
org: "incubateur",
project: "carnets",
project: "fabnum-carnets",
url: "https://sentry.fabrique.social.gouv.fr/",
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
},
"dependencies": {
"@codegouvfr/react-dsfr": "1.2.2",
"@litehex/node-vault": "0.2.4",
"@opentelemetry/exporter-trace-otlp-http": "^0.50.0",
"@opentelemetry/resources": "^1.23.0",
"@opentelemetry/sdk-node": "^0.50.0",
Expand All @@ -35,6 +34,7 @@
"jsonwebtoken": "9.0.2",
"next": "14.1.3",
"next-auth": "4.24.5",
"node-vault": "0.10.2",
"react": "18.2.0",
"react-chartjs-2": "5.2.0",
"react-dom": "18.2.0",
Expand Down
24 changes: 13 additions & 11 deletions src/app/api/vault/route.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { Client } from "@litehex/node-vault";
import Vault from "node-vault";

// Get a new instance of the client
const vc = new Client({
var options = {
apiVersion: "v1",
endpoint: "https://vaul.fabrique.fr",
});
};

export async function GET() {
const init = await vc.init({ secret_shares: 1, secret_threshold: 1 });
console.log(init);
var vault = Vault(options);

const { keys, root_token } = init;
vc.token = root_token;
try {
const result = await vault.init({ secret_shares: 1, secret_threshold: 1 });
var keys = result.keys;
vault.token = result.root_token;
const secrets = vault.unseal({ secret_shares: 1, key: keys[0] });
console.log("SECRETS:", secrets);
} catch (error) {
console.log(error);
}

const unsealed = await vc.unseal({ key: keys[0] });

console.log(unsealed);
return new Response("It Works!", { status: 200 });
}
Loading

0 comments on commit ba254f1

Please sign in to comment.