Compare commits

...

2 Commits

Author SHA1 Message Date
6c19409567 Get variables from env 2023-04-13 22:38:35 +03:00
f0bce986f1 Add deployment.yaml to .dockerignore 2023-04-13 22:38:09 +03:00
3 changed files with 12 additions and 5 deletions

View File

@ -5,6 +5,7 @@ README.md
.git/ .git/
node_modules/ node_modules/
.drone.yml .drone.yml
deployment.yaml
# Editor directories and files # Editor directories and files
.vscode/* .vscode/*

10
app.js
View File

@ -7,12 +7,12 @@ async function run() {
app.use(bodyParser.urlencoded()); app.use(bodyParser.urlencoded());
app.use(bodyParser.json()) app.use(bodyParser.json())
const issuer = await Issuer.discover('https://gateway-gab7y.codemowers.ee/'); const issuer = await Issuer.discover(process.env.OIDC_GATEWAY_URI);
console.log('Discovered issuer %s %O', issuer.issuer, issuer.metadata); console.log('Discovered issuer %s %O', issuer.issuer, issuer.metadata);
const client = new issuer.Client({ const client = new issuer.Client({
client_id: 'foo', client_id: process.env.OIDC_CLIENT_ID,
redirect_uris: ['https://client-gab7y.codemowers.ee/cb'], redirect_uris: [process.env.OIDC_REDIRECT_URIS],
response_types: ['id_token'], response_types: ['id_token'],
// id_token_signed_response_alg (default "RS256") // id_token_signed_response_alg (default "RS256")
}) })
@ -20,7 +20,7 @@ async function run() {
app.get('/', async function (req, res) { app.get('/', async function (req, res) {
let url = client.authorizationUrl({ let url = client.authorizationUrl({
redirect_uri: 'https://client-gab7y.codemowers.ee/cb', redirect_uri: process.env.CLIENT_URL + '/cb',
scope: 'openid', scope: 'openid',
response_mode: 'form_post', response_mode: 'form_post',
nonce, nonce,
@ -30,7 +30,7 @@ async function run() {
}); });
app.post('/cb', async function (req, res) { app.post('/cb', async function (req, res) {
const params = client.callbackParams(req); const params = client.callbackParams(req);
const tokenSet = await client.callback('https://client-gab7y.codemowers.ee/ok', params, {nonce}); const tokenSet = await client.callback(process.env.CLIENT_URL + '/cb', params, {nonce});
console.log('received and validated tokens %j', tokenSet); console.log('received and validated tokens %j', tokenSet);
console.log('validated ID Token claims %j', tokenSet.claims()); console.log('validated ID Token claims %j', tokenSet.claims());
res.send(tokenSet.claims()); res.send(tokenSet.claims());

View File

@ -58,3 +58,9 @@ spec:
image: oidc-test-client image: oidc-test-client
ports: ports:
- containerPort: 3000 - containerPort: 3000
env:
- name: CLIENT_URL
value: https://client-gab7y.codemowers.ee
envFrom:
- secretRef:
name: oidc-client-implicit-id-token-sample-client-owner-secrets