Switched docker build to path based to allow .dockerignore to work. Implemented OIDC support. Updated README.md

This commit is contained in:
Glenn de Haan
2024-08-23 16:42:07 +02:00
parent 89bc27aef0
commit bfe2d3998d
8 changed files with 729 additions and 30 deletions

View File

@@ -21,7 +21,7 @@ const settings = {
};
/**
* Exports the UniFi voucher functions
* Exports the JWT functions
*/
module.exports = {
/**

41
modules/oidc.js Normal file
View File

@@ -0,0 +1,41 @@
/**
* Import base packages
*/
const crypto = require('crypto');
const oidc = require('express-openid-connect');
/**
* Import own modules
*/
const log = require('./log');
/**
* OIDC Settings
*
* @type {{baseURL: string, idpLogout: boolean, authRequired: boolean, clientID: string, issuerBaseURL: string, secret: string}}
*/
const settings = {
issuerBaseURL: process.env.AUTH_OIDC_ISSUER_BASE_URL,
baseURL: process.env.AUTH_OIDC_APP_BASE_URL,
clientID: process.env.AUTH_OIDC_CLIENT_ID,
secret: '',
idpLogout: true,
authRequired: false
};
/**
* Exports the OIDC functions
*/
module.exports = {
/**
* Set the OIDC secret & setup OIDC middleware
*
* @param app
*/
init: (app) => {
settings.secret = crypto.randomBytes(20).toString('hex');
log.info(`[OIDC] Set secret: ${settings.secret}`);
app.use(oidc.auth(settings));
log.info(`[OIDC] Issuer: ${settings.issuerBaseURL}, Client: ${settings.clientID}`);
}
};