Skip to content

Commit

Permalink
Merge pull request #107 from rmarscher/lucia-auth
Browse files Browse the repository at this point in the history
Update to lucia v3, oslo, arctic
  • Loading branch information
timothymiller authored Nov 15, 2023
2 parents 46fa379 + d9a776e commit c07d351
Show file tree
Hide file tree
Showing 51 changed files with 3,017 additions and 343 deletions.
20 changes: 19 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,22 @@ PUBLIC_EAS_PROJECT_ID="85fc6ccd-0ce1-4e4d-804c-b15df989f97e"

# Cloudflare Wrangler
JWT_VERIFICATION_KEY=
DATABASE_ID=aa5e3923-0f1b-469a-8bb8-d10fb866efe0
DATABASE_ID=aa5e3923-0f1b-469a-8bb8-d10fb866efe0

# Optional for OAuth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
APPLE_CLIENT_ID=
APPLE_TEAM_ID=
APPLE_KEY_ID=
APPLE_CERTIFICATE=
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=

# Optional for password reset emails
RESEND_API_KEY=

# Optional for paassword reset codes / OTP
# Use the password reset feature locally to generate a secret in the API terminal console
# Then copy and paste it here in .env.local
TOTP_SECRET=
8 changes: 3 additions & 5 deletions .github/scripts/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const autogeneratedComment =
const outputName = '.env.local'

// Read the .env file
const envFilePath = path.join(__dirname, '../../' + outputName)
const envFilePath = path.join(__dirname, `../../${outputName}`)
if (!fs.existsSync(envFilePath)) {
console.log('🛑 .env.local file does not exist')
process.exit(0)
Expand Down Expand Up @@ -58,10 +58,8 @@ const wranglerOutputPath = path.join(__dirname, '../../packages/api', '.dev.vars
const wranglerFileContent = envFileContent
.split('\n')
.map((line) => {
if (line.startsWith('PUBLIC_APP_URL')) return line.replace(/^PUBLIC_APP_URL/, 'APP_URL')
if (!line.startsWith('PUBLIC_')) {
return line
}
if (line.startsWith('PUBLIC_APP_URL')) return `${line.replace(/^PUBLIC_APP_URL/, 'APP_URL')}\n${line}`
return line
})
.join('\n')
const noD1Warning = 'NO_D1_WARNING=true'
Expand Down
11 changes: 7 additions & 4 deletions apps/expo/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'expo-router/entry'
import { LogBox } from 'react-native'
console.disableYellowBox = true
LogBox.ignoreAllLogs()
import "react-native-url-polyfill/auto";
// ^^ Remove after upgrade to Expo v50
// https://github.com/expo/expo/pull/24941
import "expo-router/entry";
import { LogBox } from "react-native";
console.disableYellowBox = true;
LogBox.ignoreAllLogs();
13 changes: 13 additions & 0 deletions apps/next/pages/oauth/[provider].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { OAuthSignInScreen } from 'app/features/oauth/screen'
import Head from 'next/head'

export default function Page() {
return (
<>
<Head>
<title>OAuth Sign In</title>
</Head>
<OAuthSignInScreen />
</>
)
}
Binary file modified bun.lockb
Binary file not shown.
12 changes: 6 additions & 6 deletions packages/api/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Config } from 'drizzle-kit'
import { defineConfig } from 'drizzle-kit/utils'

export default {
schema: './src/db/schema.ts',
out: './migrations',
export default defineConfig({
driver: 'd1',
dbCredentials: {
wranglerConfigPath: 'wrangler.toml',
dbName: 'production',
},
verbose: false,
schema: './src/db/schema.ts',
out: './migrations',
verbose: true,
strict: true,
} satisfies Config
})
30 changes: 30 additions & 0 deletions packages/api/migrations/0004_famous_ultimates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE TABLE `AuthMethod` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`hashed_password` text,
`hash_method` text,
`created_at` text DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `Session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`expires_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `VerificationCode` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`code` text NOT NULL,
`expires` integer NOT NULL,
`timeout_until` integer,
`timeout_seconds` integer DEFAULT 0 NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `idx_userKey_userId` ON `AuthMethod` (`user_id`);--> statement-breakpoint
CREATE INDEX `idx_session_userId` ON `Session` (`user_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `VerificationCode_user_id_unique` ON `VerificationCode` (`user_id`);--> statement-breakpoint
CREATE INDEX `idx_verificationCode_userId` ON `VerificationCode` (`user_id`);
Loading

0 comments on commit c07d351

Please sign in to comment.