From b3b5fa8a0672a6c5c65c67a739a724b9136da3a1 Mon Sep 17 00:00:00 2001 From: Jamie Slome Date: Fri, 9 Feb 2024 13:54:18 +0000 Subject: [PATCH] chore: add new config features and associated functions --- proxy.config.json | 9 +++++- src/config/index.js | 73 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/proxy.config.json b/proxy.config.json index 9eb16a1c..6279625b 100644 --- a/proxy.config.json +++ b/proxy.config.json @@ -1,5 +1,7 @@ { "proxyUrl": "https://github.com", + "cookieSecret": "cookie secret", + "sessionMaxAgeHours": 12, "tempPassword": { "sendEmail": false, "emailConfig": {} @@ -25,7 +27,7 @@ "options": { "useNewUrlParser": true, "useUnifiedTopology": true, - "sslValidate": false, + "tlsAllowInvalidCertificates": false, "ssl": true }, "enabled": false @@ -48,6 +50,11 @@ } } ], + "api": { + "github": { + "baseUrl": "https://api.github.com" + } + }, "commitConfig": { "author": { "email": { diff --git a/src/config/index.js b/src/config/index.js index e94f38c9..87b6e677 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -11,6 +11,24 @@ let _authorisedList = defaultSettings.authorisedList; let _database = defaultSettings.sink; let _authentication = defaultSettings.authentication; let _tempPassword = defaultSettings.tempPassword; +let _proxyUrl = defaultSettings.proxyUrl; +let _api = defaultSettings.api; +let _cookieSecret = defaultSettings.cookieSecret; +let _sessionMaxAgeHours = defaultSettings.sessionMaxAgeHours; +const _commitConfig = defaultSettings.commitConfig; +const _attestationConfig = defaultSettings.attestationConfig; +const _privateOrganizations = defaultSettings.privateOrganizations; +const _urlShortener = defaultSettings.urlShortener; +const _contactEmail = defaultSettings.contactEmail; + +// Get configured proxy URL +const getProxyUrl = () => { + if (_userSettings !== null && _userSettings.proxyUrl) { + _proxyUrl = _userSettings.proxyUrl; + } + + return _proxyUrl; +}; // Gets a list of authorised repositories const getAuthorisedList = () => { @@ -70,10 +88,63 @@ const logConfiguration = () => { console.log(`authentication = ${JSON.stringify(getAuthentication())}`); }; -// logConfiguration(); +const getAPIs = () => { + if (_userSettings && _userSettings.api) { + _api = _userSettings.api; + } + return _api; +}; + +const getCookieSecret = () => { + if (_userSettings && _userSettings.cookieSecret) { + _cookieSecret = _userSettings.cookieSecret; + } + return _cookieSecret; +}; + +const getSessionMaxAgeHours = () => { + if (_userSettings && _userSettings.sessionMaxAgeHours) { + _sessionMaxAgeHours = _userSettings.sessionMaxAgeHours; + } + return _sessionMaxAgeHours; +}; + +// Get commit related configuration +const getCommitConfig = () => { + return _commitConfig; +}; + +// Get attestation related configuration +const getAttestationConfig = () => { + return _attestationConfig; +}; + +// Get private organizations related configuration +const getPrivateOrganizations = () => { + return _privateOrganizations; +}; + +// Get URL shortener +const getURLShortener = () => { + return _urlShortener; +}; + +// Get contact e-mail address +const getContactEmail = () => { + return _contactEmail; +}; +exports.getAPIs = getAPIs; +exports.getProxyUrl = getProxyUrl; exports.getAuthorisedList = getAuthorisedList; exports.getDatabase = getDatabase; exports.logConfiguration = logConfiguration; exports.getAuthentication = getAuthentication; exports.getTempPasswordConfig = getTempPasswordConfig; +exports.getCookieSecret = getCookieSecret; +exports.getSessionMaxAgeHours = getSessionMaxAgeHours; +exports.getCommitConfig = getCommitConfig; +exports.getAttestationConfig = getAttestationConfig; +exports.getPrivateOrganizations = getPrivateOrganizations; +exports.getURLShortener = getURLShortener; +exports.getContactEmail = getContactEmail;