mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-09 03:20:56 +00:00
Base64-encode GITHUB_APP_PRIVATE_KEY in .env
Write the private key as base64 to avoid multiline quoting issues. Add getGitHubAppPrivateKey() that accepts both raw PEM and base64. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f1bf37349d
commit
b0e65423ae
2 changed files with 13 additions and 2 deletions
|
|
@ -14,3 +14,14 @@ export function getGitHubOAuth() {
|
|||
export function isGitHubAppConfigured(): boolean {
|
||||
return !!process.env.GITHUB_APP_CLIENT_ID;
|
||||
}
|
||||
|
||||
export function getGitHubAppPrivateKey(): string {
|
||||
const raw = process.env.GITHUB_APP_PRIVATE_KEY;
|
||||
if (!raw) {
|
||||
throw new Error("GITHUB_APP_PRIVATE_KEY is not configured");
|
||||
}
|
||||
if (raw.startsWith("-----BEGIN")) {
|
||||
return raw;
|
||||
}
|
||||
return Buffer.from(raw, "base64").toString("utf-8");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||
`export GITHUB_APP_CLIENT_ID=${data.client_id}`,
|
||||
`export GITHUB_APP_CLIENT_SECRET=${data.client_secret}`,
|
||||
`export GITHUB_APP_WEBHOOK_SECRET=${data.webhook_secret}`,
|
||||
`export GITHUB_APP_PRIVATE_KEY="${data.pem}"`,
|
||||
`export GITHUB_APP_PRIVATE_KEY=${Buffer.from(data.pem).toString("base64")}`,
|
||||
].join("\n");
|
||||
|
||||
const envContent = existing ? `${existing.trimEnd()}\n\n${newVars}\n` : `${newVars}\n`;
|
||||
|
|
@ -57,7 +57,7 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||
process.env.GITHUB_APP_CLIENT_ID = data.client_id;
|
||||
process.env.GITHUB_APP_CLIENT_SECRET = data.client_secret;
|
||||
process.env.GITHUB_APP_WEBHOOK_SECRET = data.webhook_secret;
|
||||
process.env.GITHUB_APP_PRIVATE_KEY = data.pem;
|
||||
process.env.GITHUB_APP_PRIVATE_KEY = Buffer.from(data.pem).toString("base64");
|
||||
|
||||
throw redirect("/auth/login");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue