Skip to content

Commit 377ec11

Browse files
committed
add basic auth form
1 parent f4a2b56 commit 377ec11

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed

client/src/components/apps/form.vue

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,83 @@
440440
</v-expansion-panel-text>
441441
</v-expansion-panel>
442442

443+
<!-- AUTHENTICATION -->
444+
<v-expansion-panel bg-color="rgb(var(--v-theme-on-surface-variant))" :style="advanced ? 'display: block;' : 'display: none;'">
445+
<v-expansion-panel-title class="text-uppercase text-caption-2 font-weight-medium" color="secondary">Authentication</v-expansion-panel-title>
446+
<v-expansion-panel-text color="secondary">
447+
448+
449+
<v-row>
450+
<v-col
451+
cols="12"
452+
md="6"
453+
>
454+
<v-text-field
455+
v-model="basicAuth.realm"
456+
label="name"
457+
:counter="60"
458+
></v-text-field>
459+
</v-col>
460+
</v-row>
461+
462+
463+
<v-row v-for="(account, index) in basicAuth.accounts" :key="index">
464+
<v-col
465+
cols="12"
466+
md="5"
467+
>
468+
<v-text-field
469+
v-model="account.user"
470+
label="Username"
471+
:counter="60"
472+
></v-text-field>
473+
</v-col>
474+
<v-col
475+
cols="12"
476+
md="6"
477+
>
478+
<v-text-field
479+
v-model="account.pass"
480+
label="Password"
481+
></v-text-field>
482+
</v-col>
483+
<v-col
484+
cols="12"
485+
md="1"
486+
>
487+
<v-btn
488+
elevation="2"
489+
icon
490+
small
491+
@click="removeAuthLine(account.user)"
492+
>
493+
<v-icon dark >
494+
mdi-minus
495+
</v-icon>
496+
</v-btn>
497+
</v-col>
498+
</v-row>
499+
500+
<v-row>
501+
<v-col
502+
cols="12"
503+
>
504+
<v-btn
505+
elevation="2"
506+
icon
507+
small
508+
@click="addAuthLine()"
509+
>
510+
<v-icon dark >
511+
mdi-plus
512+
</v-icon>
513+
</v-btn>
514+
</v-col>
515+
</v-row>
516+
517+
</v-expansion-panel-text>
518+
</v-expansion-panel>
519+
443520
<!-- SECURITY -->
444521
<v-expansion-panel bg-color="rgb(var(--v-theme-on-surface-variant))" :style="advanced ? 'display: block;' : 'display: none;'">
445522
<v-expansion-panel-title class="text-uppercase text-caption-2 font-weight-medium" color="secondary">Security</v-expansion-panel-title>
@@ -1370,6 +1447,10 @@ export default defineComponent({
13701447
sleepEnabled: false,
13711448
envFile: [],
13721449
buildpacks: [] as { text: string, value: Buildpack }[],
1450+
basicAuth: {
1451+
realm: 'Authentication required',
1452+
accounts: [] as { user: string, pass: string }[],
1453+
},
13731454
buildpack: {
13741455
run: {
13751456
readOnlyAppStorage: true,
@@ -1969,6 +2050,7 @@ export default defineComponent({
19692050
this.buildstrategy = response.data.spec.buildstrategy || 'plain';
19702051
this.appname = response.data.spec.name;
19712052
this.sleep = response.data.spec.sleep;
2053+
this.basicAuth = response.data.spec.basicAuth || { realm: 'Authentication required', accounts: [] };
19722054
this.buildpack = {
19732055
run: response.data.spec.image.run,
19742056
build: response.data.spec.image.build,
@@ -2091,6 +2173,7 @@ export default defineComponent({
20912173
buildpack: this.buildpack,
20922174
appname: this.appname,
20932175
sleep: this.sleep,
2176+
basicAuth: this.basicAuth,
20942177
gitrepo: this.gitrepo,
20952178
branch: this.branch,
20962179
deploymentstrategy: this.deploymentstrategy,
@@ -2190,6 +2273,7 @@ export default defineComponent({
21902273
phase: this.phase,
21912274
appname: this.appname.toLowerCase(),
21922275
sleep: this.sleep,
2276+
basicAuth: this.basicAuth,
21932277
gitrepo: this.gitrepo,
21942278
branch: this.branch,
21952279
deploymentstrategy: this.deploymentstrategy,
@@ -2270,6 +2354,19 @@ export default defineComponent({
22702354
console.log(error);
22712355
});
22722356
},
2357+
addAuthLine() {
2358+
this.basicAuth.accounts.push({
2359+
user: '',
2360+
pass: '',
2361+
});
2362+
},
2363+
removeAuthLine(index: string) {
2364+
for (let i = 0; i < this.basicAuth.accounts.length; i++) {
2365+
if (this.basicAuth.accounts[i].user === index) {
2366+
this.basicAuth.accounts.splice(i, 1);
2367+
}
2368+
}
2369+
},
22732370
addEnvLine() {
22742371
this.envvars.push({
22752372
name: '',

server/src/kubero.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,10 @@ export class Kubero {
715715
autodeploy: true,
716716
podsize: this.config.podSizeList[0], //TODO select from podsizelist
717717
autoscale: false,
718+
basicAuth: {
719+
realm: '',
720+
accounts: []
721+
},
718722
envVars: pipeline.phases.find(p => p.name == phaseName)?.defaultEnvvars || [],
719723
extraVolumes: [], //TODO Not sure how to handlle extra Volumes on PR Apps
720724
serviceAccount: {

server/src/modules/application.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class App implements IApp{
3535
public podsize: IPodSize
3636
public autoscale: boolean
3737
//public envVars: {[key: string]: string} = {}
38+
public basicAuth: { realm: string; accounts: { user: string; password: string; }[]; };
3839
public envVars: {}[] = []
3940
public extraVolumes: IExtraVolume[] = []
4041
public cronjobs: ICronjob[] = []
@@ -152,6 +153,8 @@ export class App implements IApp{
152153
this.podsize = app.podsize
153154
this.autoscale = app.autoscale // TODO: may be redundant with autoscaling.enabled
154155

156+
this.basicAuth = app.basicAuth
157+
155158
this.envVars = app.envVars
156159

157160
this.serviceAccount = app.serviceAccount;

server/src/routes/apps.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ function createApp(req: Request) : IApp {
213213
autodeploy: req.body.autodeploy,
214214
podsize: req.body.podsize,
215215
autoscale: req.body.autoscale,
216+
basicAuth: req.body.basicAuth,
216217
envVars: req.body.envvars,
217218
extraVolumes: req.body.extraVolumes,
218219
serviceAccount: req.body.serviceAccount,
@@ -275,6 +276,7 @@ Router.put('/pipelines/:pipeline/:phase/:app', authMiddleware, async function (r
275276
podsize: req.body.podsize,
276277
autoscale: req.body.autoscale,
277278
extraVolumes: req.body.extraVolumes,
279+
basicAuth: req.body.basicAuth,
278280
envVars: req.body.envvars,
279281
serviceAccount: req.body.serviceAccount,
280282
image: {

server/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export interface IApp {
1212
autodeploy: boolean,
1313
podsize: IPodSize,
1414
autoscale: boolean,
15+
basicAuth: {
16+
realm: string,
17+
accounts: {
18+
user: string,
19+
password: string,
20+
}[]
21+
},
1522
envVars: {}[],
1623
image : {
1724
repository: string,

0 commit comments

Comments
 (0)