Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit 21e073e

Browse files
committed
finished implementation, working on local machine
1 parent 05d048d commit 21e073e

File tree

2,838 files changed

+424988
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,838 files changed

+424988
-19
lines changed

index.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
1-
var http = require('http');
1+
const express = require('express');
2+
const async = require('async');
3+
const msRestAzure = require('ms-rest-azure');
4+
const KeyVault = require('azure-keyvault');
5+
const KeyVaultManagementClient = require('azure-arm-keyvault')
6+
const KEY_VAULT_URI = "https://wilxkv.vault.azure.net/";
27

3-
var server = http.createServer(function(request, response) {
8+
let app = express();
9+
let clientId = process.env['CLIENT_ID']; // service principal
10+
let domain = process.env['DOMAIN']; // tenant id
11+
let secret = process.env['APPLICATION_SECRET'];
412

5-
response.writeHead(200, {"Content-Type": "text/plain"});
6-
response.end("Hello World!");
13+
function get_key_vault_credentials(){
14+
if (process.env.APPSETTING_WEBSITE_SITE_NAME){
15+
return msRestAzure.loginWithAppServiceMSI();
16+
} else {
17+
return msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain);
18+
}
19+
}
720

21+
function get_key_vault_secret(credentials) {
22+
let keyVaultClient = new KeyVault.KeyVaultClient(credentials);
23+
return keyVaultClient.getSecret(KEY_VAULT_URI, 'secret', "");
24+
}
25+
26+
app.get('/', function (req, res) {
27+
get_key_vault_credentials().then(
28+
get_key_vault_secret
29+
).then(function (secret){
30+
res.send(`Your secret value is: ${secret.value}.`);
31+
}).catch(function (err) {
32+
res.send(err);
33+
});
34+
});
35+
36+
app.get('/ping', function (req, res) {
37+
res.send('Hello World!!!');
838
});
939

10-
var port = process.env.PORT || 1337;
11-
server.listen(port);
40+
let port = process.env.PORT || 3000;
1241

13-
console.log("Server running at http://localhost:%d", port);
42+
app.listen(port, function () {
43+
console.log(`Server running at http://localhost:${port}`);
44+
});

node_modules/.bin/mime

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mime.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-conv

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-conv.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-sign

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-sign.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-verify

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/sshpk-verify.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)