feature(auth): replace clerk.com with custom auth (#103)

* feature(auth): replace clerk.com with custom auth

* minor fixes

* remove notification preferences

* decrease live events interval

fix(api): cookies..

# Conflicts:
#	.gitignore
#	apps/api/src/index.ts
#	apps/dashboard/src/app/providers.tsx
#	packages/trpc/src/trpc.ts
This commit is contained in:
Carl-Gerhard Lindesvärd
2024-12-18 21:30:39 +01:00
committed by Carl-Gerhard Lindesvärd
parent f28802b1c2
commit d31d9924a5
151 changed files with 18484 additions and 12853 deletions

View File

@@ -116,15 +116,14 @@ function writeEnvFile(envs: {
REDIS_URL: string;
DATABASE_URL: string;
DOMAIN_NAME: string;
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: string;
CLERK_SECRET_KEY: string;
CLERK_SIGNING_SECRET: string;
COOKIE_SECRET: string;
}) {
const envTemplatePath = path.resolve(__dirname, '.env.template');
const envPath = path.resolve(__dirname, '.env');
const envTemplate = fs.readFileSync(envTemplatePath, 'utf-8');
const newEnvFile = envTemplate
.replace('COOKIE_SECRET', envs.COOKIE_SECRET)
.replace('$CLICKHOUSE_URL', envs.CLICKHOUSE_URL)
.replace('$REDIS_URL', envs.REDIS_URL)
.replace('$DATABASE_URL', envs.DATABASE_URL)
@@ -133,13 +132,7 @@ function writeEnvFile(envs: {
.replace(
'$NEXT_PUBLIC_API_URL',
`${stripTrailingSlash(envs.DOMAIN_NAME)}/api`,
)
.replace(
'$NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY',
envs.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
)
.replace('$CLERK_SECRET_KEY', envs.CLERK_SECRET_KEY)
.replace('$CLERK_SIGNING_SECRET', envs.CLERK_SIGNING_SECRET);
);
fs.writeFileSync(
envPath,
@@ -169,11 +162,7 @@ async function initiateOnboarding() {
'Before you continue, please make sure you have the following:',
`${T}1. Docker and Docker Compose installed on your machine.`,
`${T}2. A domain name that you can use for this setup and point it to this machine's ip`,
`${T}3. A Clerk.com account`,
`${T}${T}- If you don't have one, you can create one at https://clerk.dev`,
`${T}${T}- We'll need NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY, CLERK_SIGNING_SECRET`,
`${T}${T}- Create a webhook pointing to https://your_domain/api/webhook/clerk\n`,
'For more information you can read our article on self-hosting at https://docs.openpanel.dev/docs/self-hosting\n',
'For more information you can read our article on self-hosting at https://openpanel.dev/docs/self-hosting/self-hosting\n',
];
console.log(
@@ -279,50 +268,6 @@ async function initiateOnboarding() {
},
]);
// Clerk
const clerkResponse = await inquirer.prompt([
{
type: 'input',
name: 'NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY',
message: 'Enter your Clerk Publishable Key:',
default: process.env.DEBUG ? 'pk_test_1234567890' : undefined,
validate: (value) => {
if (value.startsWith('pk_live_') || value.startsWith('pk_test_')) {
return true;
}
return 'Please enter a valid Clerk Publishable Key. Should start with "pk_live_" or "pk_test_"';
},
},
{
type: 'input',
name: 'CLERK_SECRET_KEY',
message: 'Enter your Clerk Secret Key:',
default: process.env.DEBUG ? 'sk_test_1234567890' : undefined,
validate: (value) => {
if (value.startsWith('sk_live_') || value.startsWith('sk_test_')) {
return true;
}
return 'Please enter a valid Clerk Secret Key. Should start with "sk_live_" or "sk_test_"';
},
},
{
type: 'input',
name: 'CLERK_SIGNING_SECRET',
message: 'Enter your Clerk Signing Secret:',
default: process.env.DEBUG ? 'whsec_1234567890' : undefined,
validate: (value) => {
if (value.startsWith('whsec_')) {
return true;
}
return 'Please enter a valid Clerk Signing Secret. Should start with "whsec_"';
},
},
]);
// OS
const cpus = await inquirer.prompt([
@@ -379,10 +324,7 @@ async function initiateOnboarding() {
envs.DATABASE_URL ||
'postgresql://postgres:postgres@op-db:5432/postgres?schema=public',
DOMAIN_NAME: domainNameResponse.domainName,
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY:
clerkResponse.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY || '',
CLERK_SECRET_KEY: clerkResponse.CLERK_SECRET_KEY || '',
CLERK_SIGNING_SECRET: clerkResponse.CLERK_SIGNING_SECRET || '',
COOKIE_SECRET: generatePassword(32),
});
console.log('Updating docker-compose.yml file...\n');
@@ -417,18 +359,16 @@ async function initiateOnboarding() {
'======================================================================',
'Here are some good things to know before you continue:',
'',
`1. Make sure that your webhook is pointing at ${domainNameResponse.domainName}/api/webhook/clerk`,
'',
'2. Commands:',
'1. Commands:',
'\t- ./start (example: ./start)',
'\t- ./stop (example: ./stop)',
'\t- ./logs (example: ./logs)',
'\t- ./rebuild (example: ./rebuild op-dashboard)',
'',
'3. Danger zone!',
'2. Danger zone!',
'\t- ./danger_wipe_everything (example: ./danger_wipe_everything)',
'',
'4. More about self-hosting: https://docs.openpanel.dev/docs/self-hosting',
'3. More about self-hosting: https://openpanel.dev/docs/self-hosting/self-hosting',
'======================================================================',
'',
`Start OpenPanel with "./start" inside the self-hosting directory`,