Skip to content

Commit a291723

Browse files
ACM-17274 include root certificates for routes (stolostron#4211)
* Include root certificates when accessing Routes Signed-off-by: Kevin Cormier <kcormier@redhat.com> * Add missing development proxies Signed-off-by: Kevin Cormier <kcormier@redhat.com> * Add /multicloud/virtualmachines dev proxy Signed-off-by: Kevin Cormier <kcormier@redhat.com> --------- Signed-off-by: Kevin Cormier <kcormier@redhat.com>
1 parent ea08c79 commit a291723

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

backend/src/lib/serviceAccountToken.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,28 @@ function base64DecodeValue(value: string): string {
5151

5252
type Certificates = string | string[]
5353

54-
function getCertificate(name: string, base64DefaultValue: string): Certificates {
54+
function getCertificate(name: string, base64DefaultValue: string, includeRoot?: boolean): Certificates {
5555
const internal_cert = readServiceAccountFile(name, base64DecodeValue(base64DefaultValue))
56-
return process.env.NODE_ENV === 'production'
57-
? internal_cert
58-
: [...(internal_cert ? [internal_cert] : []), ...rootCertificates] // include root certificates for development against clusters with signed certificates
56+
return [internal_cert, ...(includeRoot ? rootCertificates : [])] // include root certificates in addition to internal cluster certificates
5957
}
6058

6159
let ca_cert: Certificates
6260
export function getCACertificate(): Certificates {
6361
if (ca_cert === undefined) {
64-
ca_cert = getCertificate('ca.crt', process.env.CA_CERT)
62+
ca_cert = getCertificate('ca.crt', process.env.CA_CERT, true)
6563
}
6664
return ca_cert
6765
}
6866

6967
let service_ca_cert: Certificates
7068
export function getServiceCACertificate(): Certificates {
7169
if (service_ca_cert === undefined) {
72-
service_ca_cert = getCertificate('service-ca.crt', process.env.SERVICE_CA_CERT)
70+
// in dev mode, connections to Services need to be proxied via Routes, so they need root certificates
71+
service_ca_cert = getCertificate(
72+
'service-ca.crt',
73+
process.env.SERVICE_CA_CERT,
74+
process.env.NODE_ENV !== 'production'
75+
)
7376
}
7477
return service_ca_cert
7578
}

frontend/webpack.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,16 @@ module.exports = function (env: any, argv: { hot?: boolean; mode: string | undef
163163
'/multicloud/metrics',
164164
'/multicloud/login',
165165
'/multicloud/logout',
166+
'/multicloud/observability',
166167
'/multicloud/operatorCheck',
168+
'/multicloud/prometheus',
167169
'/multicloud/proxy/search',
168170
'/multicloud/aggregate',
169171
'/multicloud/username',
170172
'/multicloud/userpreference',
171173
'/multicloud/version',
174+
'/multicloud/virtualmachines',
175+
'/multicloud/virtualmachineinstances',
172176
].map((backendPath) => ({
173177
path: backendPath,
174178
target: `https://localhost:${process.env.BACKEND_PORT}`,

0 commit comments

Comments
 (0)