Skip to content

Commit 1b96856

Browse files
reggeenrsmoser-ibm
authored andcommitted
Adjusted the auth app
1 parent a45be94 commit 1b96856

File tree

7 files changed

+264
-268
lines changed

7 files changed

+264
-268
lines changed

auth-oidc-proxy/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ In order to be able to authenticate using OIDC SSO, you'll need to choose and co
1414

1515
### Github.com OIDC SSO
1616

17-
Github.com provides a publicly available OIDC provider, that can be used to point to Code Engine applications, which you deployed in your IBM Cloud account. Use the following steps to configure an SSO app:
17+
GitHub.com provides a publicly available OIDC provider, that can be used to point to Code Engine applications, which you deployed in your IBM Cloud account. Use the following steps to configure an SSO app:
1818

1919
* Create Github OIDC app through https://github.com/settings/developers
2020
```
@@ -29,7 +29,7 @@ Github.com provides a publicly available OIDC provider, that can be used to poin
2929
```
3030
* Generate a random cookie secret that is used to encrypt the auth cookie value and add it to the `oidc.properties` file
3131
```
32-
echo "COOKIE_SIGNING_ENCRYPTION_KEY=$(openssl rand -base64 32)" >> oidc.properties
32+
echo "COOKIE_ENCRYPTION_KEY=$(openssl rand -base64 32)" >> oidc.properties
3333
```
3434
* From your OIDC provider obtain the following values and add them to the `oidc.properties` file
3535
```
@@ -40,12 +40,12 @@ Github.com provides a publicly available OIDC provider, that can be used to poin
4040
* To add authorization checks one can check for a specific user property
4141
```
4242
echo "AUTHZ_USER_PROPERTY=login" >> oidc.properties
43-
echo "AUTHZ_ALLOWED_USERS=<<comma-separated-list-of-github-users>" >> oidc.properties
43+
echo "AUTHZ_ALLOWED_USERS=<comma-separated-list-of-github-users>" >> oidc.properties
4444
```
4545
4646
### IBMers-only: w3Id OIDC SSO
4747
48-
To protect IBM's workforce, the SSO Provisioner provides the ability to configure an w3Id SSO. Note: This SSO provider can only be used by IBMers
48+
To protect IBM-owned, internal applications, the w3Id SSO Provisioner provides the ability to configure an w3Id SSO. Note: This SSO provider can only be used by IBMers
4949
5050
* Create w3Id OIDC configuration through https://w3.ibm.com/security/sso-provisioner
5151
```
@@ -60,7 +60,7 @@ To protect IBM's workforce, the SSO Provisioner provides the ability to configur
6060
```
6161
* Generate a random cookie secret that is used to encrypt the auth cookie value and add it to the `oidc.properties` file
6262
```
63-
echo "COOKIE_SIGNING_ENCRYPTION_KEY=$(openssl rand -base64 32)" >> oidc.properties
63+
echo "COOKIE_ENCRYPTION_KEY=$(openssl rand -base64 32)" >> oidc.properties
6464
```
6565
* From your OIDC provider obtain the following values and add them to the `oidc.properties` file
6666
```

auth-oidc-proxy/auth/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM registry.access.redhat.com/ubi9/nodejs-22:latest AS build-env
1+
FROM registry.access.redhat.com/ubi9/nodejs-24:latest AS build-env
22
WORKDIR /app
33
COPY package.json .
44
RUN npm install
55

66
# Use a small distroless image for as runtime image
7-
FROM gcr.io/distroless/nodejs22-debian12
7+
FROM gcr.io/distroless/nodejs24-debian12
88
COPY --from=build-env /app /app
99
WORKDIR /app
1010
COPY index.mjs public/ .

auth-oidc-proxy/auth/index.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const requiredEnvVars = [
1010
"OIDC_PROVIDER_TOKEN_ENDPOINT",
1111
"OIDC_PROVIDER_USERINFO_ENDPOINT",
1212
"OIDC_REDIRECT_URL",
13-
"COOKIE_SIGNING_ENCRYPTION_KEY",
13+
"COOKIE_ENCRYPTION_KEY",
1414
"COOKIE_DOMAIN",
1515
"REDIRECT_URL",
1616
];
@@ -23,14 +23,19 @@ requiredEnvVars.forEach((envVarName) => {
2323
});
2424

2525
const SESSION_COOKIE = process.env.COOKIE_NAME || "session_token";
26-
const ENCRYPTION_KEY = Buffer.from(process.env.COOKIE_SIGNING_ENCRYPTION_KEY, "base64");
27-
const ENCRYPTION_IV = crypto.randomBytes(16);
26+
let ENCRYPTION_KEY;
27+
if(process.env.COOKIE_ENCRYPTION_KEY)
28+
ENCRYPTION_KEY = Buffer.from(process.env.COOKIE_ENCRYPTION_KEY, "base64");
29+
let ENCRYPTION_IV = crypto.randomBytes(16);
30+
if (process.env.COOKIE_ENCRYPTION_IV) {
31+
ENCRYPTION_IV = Buffer.from(process.env.COOKIE_ENCRYPTION_IV, "base64");
32+
}
2833
const ENCRYPTION_ALGORITHM = "aes-256-cbc";
2934

3035
// check whether the KEY has got 32 bytes (256-bit)
31-
if (ENCRYPTION_KEY.length != 32) {
36+
if (process.env.COOKIE_ENCRYPTION_KEY && ENCRYPTION_KEY.length != 32) {
3237
console.log(
33-
`Environment variable 'COOKIE_SIGNING_ENCRYPTION_KEY' has wrong length. Current: ${ENCRYPTION_KEY.length}. Expected: 32`
38+
`Environment variable 'COOKIE_ENCRYPTION_KEY' has wrong length. Current: ${ENCRYPTION_KEY.length}. Expected: 32`
3439
);
3540
process.exit(1);
3641
}

0 commit comments

Comments
 (0)