Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow all default config to be replaced by user config #742

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: allow all default config to be replaced by user config
Currently most config options can be replaced, this change adjusts the rest
to also allow for this.
  • Loading branch information
06kellyjac committed Oct 7, 2024
commit fea02a8e8c10f5afae37b7fcea2e142bf3a37f72
36 changes: 27 additions & 9 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
let _sessionMaxAgeHours = defaultSettings.sessionMaxAgeHours;
let _sslKeyPath = defaultSettings.sslKeyPemPath;
let _sslCertPath = defaultSettings.sslCertPemPath;
const _commitConfig = defaultSettings.commitConfig;
const _attestationConfig = defaultSettings.attestationConfig;
const _privateOrganizations = defaultSettings.privateOrganizations;
const _urlShortener = defaultSettings.urlShortener;
const _contactEmail = defaultSettings.contactEmail;
const _csrfProtection = defaultSettings.csrfProtection;
let _commitConfig = defaultSettings.commitConfig;
let _attestationConfig = defaultSettings.attestationConfig;
let _privateOrganizations = defaultSettings.privateOrganizations;
let _urlShortener = defaultSettings.urlShortener;
let _contactEmail = defaultSettings.contactEmail;
let _csrfProtection = defaultSettings.csrfProtection;

// Get configured proxy URL
const getProxyUrl = () => {
Expand Down Expand Up @@ -114,31 +114,49 @@

// Get commit related configuration
const getCommitConfig = () => {
if (_userSettings && _userSettings.commitConfig) {
_commitConfig = _userSettings.commitConfig;
}
return _commitConfig;
};

// Get attestation related configuration
const getAttestationConfig = () => {
if (_userSettings && _userSettings.attestationConfig) {
_attestationConfig = _userSettings.attestationConfig;

Check warning on line 126 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L125-L126

Added lines #L125 - L126 were not covered by tests
}
return _attestationConfig;
};

// Get private organizations related configuration
const getPrivateOrganizations = () => {
if (_userSettings && _userSettings.privateOrganizations) {
_privateOrganizations = _userSettings.privateOrganizations;
}
return _privateOrganizations;
};

// Get URL shortener
const getURLShortener = () => {
if (_userSettings && _userSettings.urlShortener) {
_urlShortener = _userSettings.urlShortener;

Check warning on line 142 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L141-L142

Added lines #L141 - L142 were not covered by tests
}
return _urlShortener;
};

// Get contact e-mail address
const getContactEmail = () => {
if (_userSettings && _userSettings.contactEmail) {
_contactEmail = _userSettings.contactEmail;

Check warning on line 150 in src/config/index.js

View check run for this annotation

Codecov / codecov/patch

src/config/index.js#L149-L150

Added lines #L149 - L150 were not covered by tests
}
return _contactEmail;
};

// Get CSRF protection flag
const getCSRFProtection = () => {
if (_userSettings && _userSettings.csrfProtection) {
_csrfProtection = _userSettings.csrfProtection;
}
return _csrfProtection;
};

Expand All @@ -147,7 +165,7 @@
_sslKeyPath = _userSettings.sslKeyPemPath;
}
if (!_sslKeyPath) {
return "../../certs/key.pem";
return '../../certs/key.pem';
}
return _sslKeyPath;
};
Expand All @@ -157,7 +175,7 @@
_sslCertPath = _userSettings.sslCertPemPath;
}
if (!_sslCertPath) {
return "../../certs/cert.pem";
return '../../certs/cert.pem';
}
return _sslCertPath;
};
Expand All @@ -178,4 +196,4 @@
exports.getContactEmail = getContactEmail;
exports.getCSRFProtection = getCSRFProtection;
exports.getSSLKeyPath = getSSLKeyPath;
exports.getSSLCertPath = getSSLCertPath;
exports.getSSLCertPath = getSSLCertPath;
Loading