Skip to content

Commit 4c4e868

Browse files
authored
Merge pull request #596 from kubero-dev/feature/add-basic-auth
use static hashes for basic auth
2 parents 160ddfd + f2172b4 commit 4c4e868

File tree

6 files changed

+127
-10
lines changed

6 files changed

+127
-10
lines changed

client/src/components/apps/form.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,17 @@
449449
<v-row>
450450
<v-col
451451
cols="12"
452-
md="6"
452+
md="3"
453+
>
454+
<v-switch
455+
v-model="basicAuth.enabled"
456+
label="Basic Auth Enabled"
457+
color="primary"
458+
></v-switch>
459+
</v-col>
460+
<v-col
461+
cols="12"
462+
md="3"
453463
>
454464
<v-text-field
455465
v-model="basicAuth.realm"
@@ -1448,6 +1458,7 @@ export default defineComponent({
14481458
envFile: [],
14491459
buildpacks: [] as { text: string, value: Buildpack }[],
14501460
basicAuth: {
1461+
enabled: false,
14511462
realm: 'Authentication required',
14521463
accounts: [] as { user: string, pass: string }[],
14531464
},

server/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@octokit/core": "^3.6.0",
2222
"@octokit/webhooks": "^9.26.0",
2323
"axios": "^0.28.0",
24+
"bcrypt": "^5.1.1",
2425
"bitbucket": "^2.9.0",
2526
"connect-history-api-fallback": "^1.6.0",
2627
"cookie-parser": "^1.4.6",
@@ -52,6 +53,7 @@
5253
"yaml": "^2.1.1"
5354
},
5455
"devDependencies": {
56+
"@types/bcrypt": "^5.0.2",
5557
"@types/connect-history-api-fallback": "^1.3.5",
5658
"@types/cookie-parser": "^1.4.6",
5759
"@types/cookie-session": "^2.0.44",

server/src/kubero.ts

+1
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ export class Kubero {
716716
podsize: this.config.podSizeList[0], //TODO select from podsizelist
717717
autoscale: false,
718718
basicAuth: {
719+
enabled: false,
719720
realm: '',
720721
accounts: []
721722
},

server/src/modules/application.ts

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { IApp, IKubectlMetadata, IKubectlApp, IKubectlTemplate, IGithubRepository, ICronjob, IPodSize, IExtraVolume, ISecurityContext, ITemplate} from '../types';
22
import { IAddon } from './addons';
33
import { Buildpack } from './config';
4+
import * as crypto from "crypto"
5+
//import { hashSync, genSaltSync } from 'bcrypt-ts';
6+
//import bcrypt from "bcrypt";
7+
import { hashSync, genSaltSync } from 'bcrypt';
48

59
export class KubectlApp implements IKubectlApp{
610
apiVersion: string;
@@ -35,7 +39,15 @@ export class App implements IApp{
3539
public podsize: IPodSize
3640
public autoscale: boolean
3741
//public envVars: {[key: string]: string} = {}
38-
public basicAuth: { realm: string; accounts: { user: string; password: string; }[]; };
42+
public basicAuth: {
43+
enabled: boolean;
44+
realm: string;
45+
accounts: {
46+
user: string;
47+
pass: string;
48+
hash?: string;
49+
}[];
50+
};
3951
public envVars: {}[] = []
4052
public extraVolumes: IExtraVolume[] = []
4153
public cronjobs: ICronjob[] = []
@@ -153,7 +165,21 @@ export class App implements IApp{
153165
this.podsize = app.podsize
154166
this.autoscale = app.autoscale // TODO: may be redundant with autoscaling.enabled
155167

156-
this.basicAuth = app.basicAuth
168+
const salt = genSaltSync(10);
169+
this.basicAuth = {
170+
realm: app.basicAuth.realm,
171+
enabled: app.basicAuth.enabled,
172+
accounts: app.basicAuth.accounts.map(account => {
173+
return {
174+
user: account.user,
175+
pass: account.pass,
176+
// generate hash with bcrypt from user and pass
177+
//hash: account.user+':$5$'+crypto.createHash('sha256').update(account.user+account.pass).digest('base64')
178+
//hash: account.user+':{SHA}'+crypto.createHash('sha1').update(account.pass).digest('base64') // works
179+
hash: account.user+':'+hashSync(account.pass, salt)
180+
}
181+
})
182+
}
157183

158184
this.envVars = app.envVars
159185

server/src/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ export interface IApp {
1313
podsize: IPodSize,
1414
autoscale: boolean,
1515
basicAuth: {
16+
enabled: boolean,
1617
realm: string,
1718
accounts: {
1819
user: string,
19-
password: string,
20+
pass: string,
21+
hash?: string,
2022
}[]
2123
},
2224
envVars: {}[],

server/yarn.lock

+81-6
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,21 @@
605605
optionalDependencies:
606606
openid-client "^5.3.0"
607607

608+
"@mapbox/node-pre-gyp@^1.0.11":
609+
version "1.0.11"
610+
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz#417db42b7f5323d79e93b34a6d7a2a12c0df43fa"
611+
integrity sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==
612+
dependencies:
613+
detect-libc "^2.0.0"
614+
https-proxy-agent "^5.0.0"
615+
make-dir "^3.1.0"
616+
node-fetch "^2.6.7"
617+
nopt "^5.0.0"
618+
npmlog "^5.0.1"
619+
rimraf "^3.0.2"
620+
semver "^7.3.5"
621+
tar "^6.1.11"
622+
608623
"@nerdvision/gitlab-js@^1.0.0-alpha.12":
609624
version "1.0.0-alpha.12"
610625
resolved "https://registry.yarnpkg.com/@nerdvision/gitlab-js/-/gitlab-js-1.0.0-alpha.12.tgz#2e869b9cb8302284bc2940b3878accc8db17a040"
@@ -844,6 +859,13 @@
844859
dependencies:
845860
"@babel/types" "^7.20.7"
846861

862+
"@types/bcrypt@^5.0.2":
863+
version "5.0.2"
864+
resolved "https://registry.yarnpkg.com/@types/bcrypt/-/bcrypt-5.0.2.tgz#22fddc11945ea4fbc3655b3e8b8847cc9f811477"
865+
integrity sha512-6atioO8Y75fNcbmj0G7UjI9lXN2pQ/IGJ2FWT4a/btd0Lk9lQalHLKhkgKVZ3r+spnmWUKfbMi1GEe9wyHQfNQ==
866+
dependencies:
867+
"@types/node" "*"
868+
847869
"@types/body-parser@*":
848870
version "1.19.5"
849871
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4"
@@ -1400,6 +1422,14 @@ anymatch@^3.0.3, anymatch@~3.1.2:
14001422
resolved "https://registry.yarnpkg.com/aproba/-/aproba-2.0.0.tgz#52520b8ae5b569215b354efc0caa3fe1e45a8adc"
14011423
integrity sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==
14021424

1425+
are-we-there-yet@^2.0.0:
1426+
version "2.0.0"
1427+
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz#372e0e7bd279d8e94c653aaa1f67200884bf3e1c"
1428+
integrity sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==
1429+
dependencies:
1430+
delegates "^1.0.0"
1431+
readable-stream "^3.6.0"
1432+
14031433
are-we-there-yet@^3.0.0:
14041434
version "3.0.1"
14051435
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz#679df222b278c64f2cdba1175cdc00b0d96164bd"
@@ -1575,6 +1605,14 @@ bcrypt-pbkdf@^1.0.0:
15751605
dependencies:
15761606
tweetnacl "^0.14.3"
15771607

1608+
bcrypt@^5.1.1:
1609+
version "5.1.1"
1610+
resolved "https://registry.yarnpkg.com/bcrypt/-/bcrypt-5.1.1.tgz#0f732c6dcb4e12e5b70a25e326a72965879ba6e2"
1611+
integrity sha512-AGBHOG5hPYZ5Xl9KXzU5iKq9516yEmvCKDg3ecP5kX2aB6UqTeXZxk2ELnDgDm6BQSMlLt9rDB4LoSMx0rYwww==
1612+
dependencies:
1613+
"@mapbox/node-pre-gyp" "^1.0.11"
1614+
node-addon-api "^5.0.0"
1615+
15781616
before-after-hook@^2.1.0, before-after-hook@^2.2.0:
15791617
version "2.2.3"
15801618
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c"
@@ -1902,7 +1940,7 @@ color-name@~1.1.4:
19021940
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
19031941
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
19041942

1905-
color-support@^1.1.3:
1943+
color-support@^1.1.2, color-support@^1.1.3:
19061944
version "1.1.3"
19071945
resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"
19081946
integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==
@@ -1939,7 +1977,7 @@ connect-history-api-fallback@^1.6.0:
19391977
resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc"
19401978
integrity sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==
19411979

1942-
console-control-strings@^1.1.0:
1980+
console-control-strings@^1.0.0, console-control-strings@^1.1.0:
19431981
version "1.1.0"
19441982
resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
19451983
integrity sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==
@@ -2551,6 +2589,21 @@ function-bind@^1.1.2:
25512589
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c"
25522590
integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==
25532591

2592+
gauge@^3.0.0:
2593+
version "3.0.2"
2594+
resolved "https://registry.yarnpkg.com/gauge/-/gauge-3.0.2.tgz#03bf4441c044383908bcfa0656ad91803259b395"
2595+
integrity sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==
2596+
dependencies:
2597+
aproba "^1.0.3 || ^2.0.0"
2598+
color-support "^1.1.2"
2599+
console-control-strings "^1.0.0"
2600+
has-unicode "^2.0.1"
2601+
object-assign "^4.1.1"
2602+
signal-exit "^3.0.0"
2603+
string-width "^4.2.3"
2604+
strip-ansi "^6.0.1"
2605+
wide-align "^1.1.2"
2606+
25542607
gauge@^4.0.3:
25552608
version "4.0.4"
25562609
resolved "https://registry.yarnpkg.com/gauge/-/gauge-4.0.4.tgz#52ff0652f2bbf607a989793d53b751bef2328dce"
@@ -3644,6 +3697,13 @@ lru-cache@^6.0.0:
36443697
dependencies:
36453698
yallist "^4.0.0"
36463699

3700+
make-dir@^3.1.0:
3701+
version "3.1.0"
3702+
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
3703+
integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==
3704+
dependencies:
3705+
semver "^6.0.0"
3706+
36473707
make-dir@^4.0.0:
36483708
version "4.0.0"
36493709
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e"
@@ -3865,6 +3925,11 @@ node-abi@^3.3.0:
38653925
dependencies:
38663926
semver "^7.3.5"
38673927

3928+
node-addon-api@^5.0.0:
3929+
version "5.1.0"
3930+
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.1.0.tgz#49da1ca055e109a23d537e9de43c09cca21eb762"
3931+
integrity sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==
3932+
38683933
node-addon-api@^7.0.0:
38693934
version "7.1.1"
38703935
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-7.1.1.tgz#1aba6693b0f255258a049d621329329322aad558"
@@ -3948,6 +4013,16 @@ npm-run-path@^4.0.1:
39484013
dependencies:
39494014
path-key "^3.0.0"
39504015

4016+
npmlog@^5.0.1:
4017+
version "5.0.1"
4018+
resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-5.0.1.tgz#f06678e80e29419ad67ab964e0fa69959c1eb8b0"
4019+
integrity sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==
4020+
dependencies:
4021+
are-we-there-yet "^2.0.0"
4022+
console-control-strings "^1.1.0"
4023+
gauge "^3.0.0"
4024+
set-blocking "^2.0.0"
4025+
39514026
npmlog@^6.0.0:
39524027
version "6.0.2"
39534028
resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-6.0.2.tgz#c8166017a42f2dea92d6453168dd865186a70830"
@@ -3968,7 +4043,7 @@ [email protected]:
39684043
resolved "https://registry.yarnpkg.com/oauth/-/oauth-0.10.0.tgz#3551c4c9b95c53ea437e1e21e46b649482339c58"
39694044
integrity sha512-1orQ9MT1vHFGQxhuy7E/0gECD3fd2fCC+PIX+/jgmU/gI3EpRocXtmtvxCO5x3WZ443FLTLFWNDjl5MPJf9u+Q==
39704045

3971-
object-assign@^4:
4046+
object-assign@^4, object-assign@^4.1.1:
39724047
version "4.1.1"
39734048
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
39744049
integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==
@@ -4530,7 +4605,7 @@ semver@^5.7.1:
45304605
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
45314606
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==
45324607

4533-
semver@^6.3.0, semver@^6.3.1:
4608+
semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
45344609
version "6.3.1"
45354610
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
45364611
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
@@ -4632,7 +4707,7 @@ side-channel@^1.0.6:
46324707
get-intrinsic "^1.2.4"
46334708
object-inspect "^1.13.1"
46344709

4635-
signal-exit@^3.0.3, signal-exit@^3.0.7:
4710+
signal-exit@^3.0.0, signal-exit@^3.0.3, signal-exit@^3.0.7:
46364711
version "3.0.7"
46374712
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
46384713
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
@@ -5242,7 +5317,7 @@ which@^2.0.1, which@^2.0.2:
52425317
dependencies:
52435318
isexe "^2.0.0"
52445319

5245-
wide-align@^1.1.5:
5320+
wide-align@^1.1.2, wide-align@^1.1.5:
52465321
version "1.1.5"
52475322
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.5.tgz#df1d4c206854369ecf3c9a4898f1b23fbd9d15d3"
52485323
integrity sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==

0 commit comments

Comments
 (0)