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

Added env var for disabling update checks #3986

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/backend/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ONE_SESSION_PER_USER=<If users are only allowed to be logged in on one browser,
CLASSIFICATION_BANNER_TEXT=<If a sensitivity classification banner should be shown to users, for example FOUO (if nothing is provided, no banner is shown)>
CLASSIFICATION_BANNER_TEXT_COLOR=<The color of the text on the sensitivity classification banner, if enabled (defaults to white)>
CLASSIFICATION_BANNER_COLOR=<The color of the sensitivity classification banner, if enabled (defaults to red)>
DISABLE_UPDATE_CHECK=<Disable checking GitHub for an updated version of Heimdall2 (defaults to false)>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please match other variable names

Suggested change
DISABLE_UPDATE_CHECK=<Disable checking GitHub for an updated version of Heimdall2 (defaults to false)>
UPDATE_CHECK_DISABLED=<Disable checking GitHub for an updated version of Heimdall2 (defaults to false)>



# Oauth Client IDs and Secrets, If a variable does not have client id values assigned then the feature is disabled.
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/src/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export class ConfigService {
oidcName: this.get('OIDC_NAME') || '',
ldap: this.get('LDAP_ENABLED')?.toLocaleLowerCase() === 'true' || false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ldap: this.get('LDAP_ENABLED')?.toLocaleLowerCase() === 'true' || false,
ldap: this.get('LDAP_ENABLED')?.toLowerCase() === 'true',

registrationEnabled: this.isRegistrationAllowed(),
localLoginEnabled: this.isLocalLoginAllowed()
localLoginEnabled: this.isLocalLoginAllowed(),
disableUpdateCheck: !!this.get('DISABLE_UPDATE_CHECK')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only check if there's a non-empty string. Also please propagate moving the 'disable' part to the end of the name.

$ node
Welcome to Node.js v18.12.1.
Type ".help" for more information.
> false
false
> 'false'
'false'
> !'false'
false
> !!'false'
true
Suggested change
disableUpdateCheck: !!this.get('DISABLE_UPDATE_CHECK')
updateCheckDisabled: this.get('UPDATE_CHECK_DISABLED')?.toLowerCase() === 'true'

});
}

Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/config/dto/startup-settings.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class StartupSettingsDto implements IStartupSettings {
readonly ldap: boolean;
readonly registrationEnabled: boolean;
readonly localLoginEnabled: boolean;
readonly disableUpdateCheck: boolean;

constructor(settings: IStartupSettings) {
this.banner = settings.banner;
Expand All @@ -21,5 +22,6 @@ export class StartupSettingsDto implements IStartupSettings {
this.ldap = settings.ldap;
this.registrationEnabled = settings.registrationEnabled;
this.localLoginEnabled = settings.localLoginEnabled;
this.disableUpdateCheck = settings.disableUpdateCheck;
}
}
3 changes: 2 additions & 1 deletion apps/frontend/src/store/app_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Mutation,
VuexModule
} from 'vuex-module-decorators';
import {ServerModule} from './server';

/** Configure this to match data set in vue.config.ts */
declare const process: {
Expand Down Expand Up @@ -54,7 +55,7 @@ export class AppInfo extends VuexModule implements IAppInfoState {

@Action
public async CheckForUpdates() {
if (this.checkedForUpdates === false) {
if (!ServerModule.disableUpdateCheck && this.checkedForUpdates === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this into its own guard clause where we can set 'SET_VERSION' to the deployed instance's version and 'SET_CHECKED_FOR_UPDATES' to true.

// Call axios.create() to skip the default interceptors setup in main.ts
axios
.create()
Expand Down
3 changes: 3 additions & 0 deletions apps/frontend/src/store/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface IServerState {
ldap: boolean;
localLoginEnabled: boolean;
userInfo: IUser;
disableUpdateCheck: boolean;
}

interface LoginData {
Expand All @@ -53,6 +54,7 @@ class Server extends VuexModule implements IServerState {
classificationBannerColor = '';
classificationBannerText = '';
classificationBannerTextColor = '';
disableUpdateCheck = false;
ldap = false;
serverUrl = '';
serverMode = false;
Expand Down Expand Up @@ -104,6 +106,7 @@ class Server extends VuexModule implements IServerState {
this.oidcName = settings.oidcName;
this.ldap = settings.ldap;
this.localLoginEnabled = settings.localLoginEnabled;
this.disableUpdateCheck = settings.disableUpdateCheck;
}

@Mutation
Expand Down
1 change: 1 addition & 0 deletions libs/interfaces/config/startup-settings.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface IStartupSettings {
readonly ldap: boolean;
readonly registrationEnabled: boolean;
readonly localLoginEnabled: boolean;
readonly disableUpdateCheck: boolean;
}