Skip to content

Commit 3e95919

Browse files
Fix issues caused by the previous PR
1 parent 2e9b2de commit 3e95919

8 files changed

Lines changed: 15 additions & 15 deletions

File tree

backend/src/db/crypto.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import crypto, { createCipheriv, createDecipheriv } from "node:crypto";
22

33
const separator = "|";
44

5-
const unwrapKey = (masterKey: string, wrapped: string): Buffer => {
5+
const unwrapKey = (masterKey: Buffer, wrapped: string): Buffer => {
66
const iv = Buffer.alloc(8, 0xa6); // Recommended default initial value
77
const decipher = createDecipheriv("aes256-wrap", masterKey, iv);
88
return Buffer.concat([decipher.update(wrapped, "base64"), decipher.final()]);
99
};
1010

11-
const wrapKey = (masterKey: string, key: Buffer): string => {
11+
const wrapKey = (masterKey: Buffer, key: Buffer): string => {
1212
const iv = Buffer.alloc(8, 0xa6);
1313
const cipher = createCipheriv("aes256-wrap", masterKey, iv);
1414
return cipher.update(key, undefined, "base64") + cipher.final("base64");
@@ -40,7 +40,7 @@ const genKey = (): Buffer => {
4040
};
4141

4242
export const encryptEnv = (
43-
masterKey: string,
43+
masterKey: Buffer,
4444
plaintext: PrismaJson.EnvVar[],
4545
key: string,
4646
) => {
@@ -52,7 +52,7 @@ export const encryptEnv = (
5252
};
5353

5454
export const decryptEnv = (
55-
masterKey: string,
55+
masterKey: Buffer,
5656
ciphertext: PrismaJson.EnvVar[],
5757
key: string,
5858
) => {
@@ -63,4 +63,4 @@ export const decryptEnv = (
6363
}));
6464
};
6565

66-
export const generateKey = (masterKey: string) => wrapKey(masterKey, genKey());
66+
export const generateKey = (masterKey: Buffer) => wrapKey(masterKey, genKey());

backend/src/db/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ export class PrismaDatabase extends Database {
5555
user: UserRepo;
5656
sessionStore: session.Store;
5757

58-
constructor(client: PrismaClientType, masterKey: string) {
58+
constructor(client: PrismaClientType, masterKey: Buffer) {
5959
super();
6060
this.client = client;
61-
this.app = new AppRepo(this.client, this.deployment);
6261
this.appGroup = new AppGroupRepo(this.client);
6362
this.cache = new CacheRepo(this.client);
6463
this.deployment = new DeploymentRepo(
6564
this.client,
6665
this.publish.bind(this),
6766
masterKey,
6867
);
68+
this.app = new AppRepo(this.client, this.deployment);
6969
this.invitation = new InvitationRepo(this.client);
7070
this.org = new OrganizationRepo(this.client);
7171
this.repoImportState = new RepoImportStateRepo(this.client);
@@ -88,7 +88,7 @@ export class PrismaDatabase extends Database {
8888
export class PgDatabase extends PrismaDatabase {
8989
private pool: Pool;
9090

91-
constructor(connectionString: string, masterKey: string) {
91+
constructor(connectionString: string, masterKey: Buffer) {
9292
const prismaPostgresAdapter = new PrismaPg({ connectionString });
9393

9494
const client = new PrismaClient({

backend/src/db/repo/deployment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ type PrismaWorkloadConfigCreate = Omit<WorkloadConfigCreate, "appType">;
2828
export class DeploymentRepo {
2929
private client: PrismaClientType;
3030
private publish: (topic: string, payload: string) => Promise<void>;
31-
private masterKey: string;
31+
private masterKey: Buffer;
3232

3333
constructor(
3434
client: PrismaClientType,
3535
publish: (topic: string, payload: string) => Promise<void>,
36-
masterKey: string,
36+
masterKey: Buffer,
3737
) {
3838
this.client = client;
3939
this.publish = publish;

backend/src/service/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export class AuthService {
3030
) {
3131
this.userRepo = userRepo;
3232
this.rancherService = rancherService;
33-
this.config = this.getOIDCConfig();
3433
this.usingRancherOIDC =
3534
this.rancherService.isRancherManaged() && useRancherOIDC;
3635
this.baseURL = baseURL;
@@ -39,6 +38,7 @@ export class AuthService {
3938
this.clientId = clientId;
4039
this.clientSecret = clientSecret;
4140
this.loginClaim = loginClaim;
41+
this.config = this.getOIDCConfig();
4242
}
4343

4444
usingCILogon() {

backend/src/service/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import { UpdateDeploymentService } from "./updateDeployment.ts";
6060
export const db: Database = new PgDatabase(
6161
env.DATABASE_URL ??
6262
`postgresql://${env.POSTGRES_USER}:${env.POSTGRES_PASSWORD}@${env.POSTGRES_HOSTNAME}/${env.POSTGRES_DB}`,
63-
env.FIELD_ENCRYPTION_KEY,
63+
Buffer.from(env.FIELD_ENCRYPTION_KEY, "base64"),
6464
);
6565

6666
export const cacheService = new KVCacheService(db.cache);

backend/test/util/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class PgliteDatabase extends PrismaDatabase {
1717
constructor(client: PGlite) {
1818
const adapter = new PrismaPGlite(client);
1919
const db = new PrismaClient({ adapter }) satisfies PrismaClientType;
20-
super(db, randomBytes(32).toString("base64"));
20+
super(db, randomBytes(32));
2121
this.pglite = client;
2222
}
2323

builders/dockerfile/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloa
55
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
66
--mount=type=cache,target=/var/lib/apt,sharing=locked \
77
apt-get update && \
8-
apt-get install -y --no-install-recommends software-properties-common=0.99.49.4 wget=1.21.4-1ubuntu4.1 libssl3=3.0.13-0ubuntu3.7 ca-certificates=20240203 && \
8+
apt-get install -y --no-install-recommends software-properties-common=0.99.49.4 wget=1.21.4-1ubuntu4.1 libssl3=3.0.13-0ubuntu3.9 ca-certificates=20240203 && \
99
# ^ This package includes `add-apt-repository`
1010
add-apt-repository ppa:git-core/ppa && \
1111
apt-get update && \

builders/railpack/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloa
77
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
88
--mount=type=cache,target=/var/lib/apt,sharing=locked \
99
apt-get update && \
10-
apt-get install -y --no-install-recommends software-properties-common=0.99.49.4 wget=1.21.4-1ubuntu4.1 libssl3=3.0.13-0ubuntu3.7 ca-certificates=20240203 jq=1.7.1-3ubuntu0.24.04.1 && \
10+
apt-get install -y --no-install-recommends software-properties-common=0.99.49.4 wget=1.21.4-1ubuntu4.1 libssl3=3.0.13-0ubuntu3.9 ca-certificates=20240203 jq=1.7.1-3ubuntu0.24.04.1 && \
1111
# ^ This package includes `add-apt-repository`
1212
add-apt-repository ppa:git-core/ppa && \
1313
apt-get update && \

0 commit comments

Comments
 (0)