Skip to content

Commit 1b27fe9

Browse files
committed
Update basicAuth object properties in app form with enabled flag and handle missing basicAuth object in application settings.
1 parent 17b0d07 commit 1b27fe9

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

client/src/components/apps/form.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ export default defineComponent({
21372137
this.buildstrategy = response.data.spec.buildstrategy || 'plain';
21382138
this.appname = response.data.spec.name;
21392139
this.sleep = response.data.spec.sleep;
2140-
this.basicAuth = response.data.spec.basicAuth || { realm: 'Authentication required', accounts: [] };
2140+
this.basicAuth = response.data.spec.basicAuth || { enabled: false, realm: 'Authentication required', accounts: [] };
21412141
this.buildpack = {
21422142
run: response.data.spec.image.run,
21432143
build: response.data.spec.image.build,

server/src/modules/application.ts

+21-13
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,27 @@ export class App implements IApp{
174174
this.autoscale = app.autoscale // TODO: may be redundant with autoscaling.enabled
175175

176176
const salt = genSaltSync(10);
177-
this.basicAuth = {
178-
realm: app.basicAuth.realm,
179-
enabled: app.basicAuth.enabled,
180-
accounts: app.basicAuth.accounts.map(account => {
181-
return {
182-
user: account.user,
183-
pass: account.pass,
184-
// generate hash with bcrypt from user and pass
185-
//hash: account.user+':$5$'+crypto.createHash('sha256').update(account.user+account.pass).digest('base64')
186-
//hash: account.user+':{SHA}'+crypto.createHash('sha1').update(account.pass).digest('base64') // works
187-
hash: account.user+':'+hashSync(account.pass, salt)
188-
}
189-
})
177+
if (app.basicAuth !== undefined) {
178+
this.basicAuth = {
179+
realm: app.basicAuth.realm,
180+
enabled: app.basicAuth.enabled,
181+
accounts: app.basicAuth.accounts.map(account => {
182+
return {
183+
user: account.user,
184+
pass: account.pass,
185+
// generate hash with bcrypt from user and pass
186+
//hash: account.user+':$5$'+crypto.createHash('sha256').update(account.user+account.pass).digest('base64')
187+
//hash: account.user+':{SHA}'+crypto.createHash('sha1').update(account.pass).digest('base64') // works
188+
hash: account.user+':'+hashSync(account.pass, salt)
189+
}
190+
})
191+
}
192+
} else {
193+
this.basicAuth = {
194+
realm: 'Authenticate',
195+
enabled: false,
196+
accounts: []
197+
}
190198
}
191199

192200
this.envVars = app.envVars

0 commit comments

Comments
 (0)