-
Notifications
You must be signed in to change notification settings - Fork 0
feat(modules/auth): semi-intergation of auth module #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
73a6b01
feat(modules/auth): semi-intergation of auth module
itssimmons 48baa64
feat: signup + login fixed
itssimmons d0c0c5a
feat(Root): native login + google oauth2 login
itssimmons 6b9f84a
fix(jwt.service): read token lifetimes from config; add +10s grace on…
Copilot 984d714
fix(auth): return 401 instead of 500 when OAuth user has no password …
Copilot 52cdf25
feat(auth): github & discord oauth2 integration
itssimmons 0ef509b
fix: biome check
itssimmons 1a114b0
fix(github-oauth): fall back to nickname when GitHub email is absent
Copilot bff4bc0
fix: github comments
itssimmons c8e6735
fix: biome check
itssimmons 79c368b
fix: some fixes
itssimmons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,28 @@ | ||
| NODE_ENV=development | ||
|
|
||
| DATABASE_URL=${DB_DRIVER}://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_SCHEMA} | ||
|
|
||
| DB_DRIVER= | ||
| DB_USER= | ||
| DB_SCHEMA= | ||
| DB_PASSWORD= | ||
| DB_HOST= | ||
| DB_PORT= | ||
| POSTGRES_USERNAME=postgres | ||
| POSTGRES_DATABASE= | ||
| POSTGRES_PASSWORD= | ||
| POSTGRES_HOST= | ||
| POSTGRES_PORT=5432 | ||
|
|
||
| DATABASE_URL=postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE} | ||
|
|
||
| REDIS_HOST= | ||
| REDIS_PORT=6379 | ||
| REDIS_USERNAME=default | ||
| REDIS_PASSWORD= | ||
|
|
||
| COOKIE_SECRET= | ||
|
|
||
| GOOGLE_CLIENT_ID= | ||
| GOOGLE_CLIENT_SECRET= | ||
| GOOGLE_REDIRECT_URI=https://example.com/auth/google/callback | ||
|
|
||
| GITHUB_CLIENT_ID= | ||
| GITHUB_CLIENT_SECRET= | ||
| GITHUB_REDIRECT_URI=https://example.com/auth/google/callback | ||
|
|
||
|
|
||
| DISCORD_CLIENT_ID= | ||
| DISCORD_CLIENT_SECRET= | ||
| DISCORD_REDIRECT_URI=https://example.com/auth/github/callback | ||
|
Comment on lines
+20
to
+28
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| declare namespace i18next { | ||
| export type TFunction = (key: string, options?: unknown) => string; | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| FROM oven/bun:1 | ||
| WORKDIR /usr/src/app | ||
|
|
||
| COPY package.json bun.lock ./ | ||
| ENV CI=true | ||
| RUN bun install | ||
|
|
||
| COPY . . | ||
| RUN DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" \ | ||
| bunx --bun prisma generate | ||
|
|
||
| ENV NODE_ENV=development | ||
|
|
||
| USER bun | ||
| EXPOSE 8080/tcp | ||
| CMD [ "bun", "dev" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: dojoh-api | ||
|
|
||
| services: | ||
| api: | ||
| container_name: dojoh-api | ||
| image: dojoh-api:latest | ||
| restart: unless-stopped | ||
| build: | ||
| dockerfile: ci/Dockerfile.dev | ||
| context: . | ||
| ports: | ||
| - "8080:8080" | ||
| env_file: .env | ||
| environment: | ||
| - NODE_ENV=development | ||
|
itssimmons marked this conversation as resolved.
|
||
| networks: | ||
| - dojoh-net | ||
| volumes: | ||
| - ./:/usr/src/app | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:8080/health"] | ||
|
itssimmons marked this conversation as resolved.
itssimmons marked this conversation as resolved.
|
||
| interval: 30s | ||
| timeout: 10s | ||
| retries: 3 | ||
| depends_on: | ||
| - pg | ||
| - redis | ||
|
|
||
| pg: | ||
| container_name: dojoh-pg | ||
| image: postgres:18 | ||
| environment: | ||
| - POSTGRES_USER=dojoh | ||
| - POSTGRES_PASSWORD=my_secret_password | ||
| - POSTGRES_DB=dojoh_dev | ||
| ports: | ||
| - "5432:5432" | ||
| networks: | ||
| - dojoh-net | ||
| volumes: | ||
| - pg_data:/var/lib/postgresql/18/docker | ||
|
itssimmons marked this conversation as resolved.
|
||
|
|
||
| redis: | ||
| container_name: dojoh-redis | ||
| image: redis:7 | ||
| ports: | ||
| - "6379:6379" | ||
| environment: | ||
| - REDIS_PASSWORD=my_secret_password | ||
| command: > | ||
| sh -c "redis-server --requirepass $$REDIS_PASSWORD" | ||
| networks: | ||
| - dojoh-net | ||
|
|
||
| networks: | ||
| dojoh-net: | ||
| driver: bridge | ||
|
|
||
| volumes: | ||
| pg_data: {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,16 @@ | ||
| import path from "node:path"; | ||
|
|
||
| import type * as i18next from "i18next"; | ||
|
|
||
| export default { | ||
| fallbackLng: "en-US", | ||
| supportedLngs: ["en-US", "es-ES", "fr-FR", "pt-BR"], | ||
| ns: ["messages", "errors"], | ||
| ns: ["messages", "errors", "zod"], | ||
| defaultNS: "messages", | ||
| backend: { | ||
| loadPath: path.join(process.cwd(), "locales/{{lng}}/{{ns}}.json"), | ||
| }, | ||
| interpolation: { | ||
| escapeValue: false, | ||
| }, | ||
| }; | ||
| } satisfies i18next.InitOptions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| -- AlterEnum | ||
| -- This migration adds more than one value to an enum. | ||
| -- With PostgreSQL versions 11 and earlier, this is not possible | ||
| -- in a single migration. This can be worked around by creating | ||
| -- multiple migrations, each migration adding only one value to | ||
| -- the enum. | ||
|
|
||
|
|
||
| ALTER TYPE "OAuthProvider" ADD VALUE 'DISCORD'; | ||
| ALTER TYPE "OAuthProvider" ADD VALUE 'NATIVE'; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "OAuthAccount" ADD COLUMN "provider_metadata" JSONB, | ||
| ALTER COLUMN "provider_avatar_url" DROP NOT NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "OAuthAccount" ALTER COLUMN "user_id" DROP NOT NULL; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "OAuthAccount" ADD CONSTRAINT "OAuthAccount_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export class ConflictError extends Error { | ||
| statusCode: number; | ||
| constructor(message: string) { | ||
| super(message); | ||
| this.name = "ConflictError"; | ||
| this.statusCode = 409; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from "./conflict.exception"; | ||
| export * from "./notfound.exception"; | ||
| export * from "./unauthorized.exception"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export class NotFoundError extends Error { | ||
| statusCode: number; | ||
| constructor(message: string) { | ||
| super(message); | ||
| this.name = "NotFoundError"; | ||
| this.statusCode = 404; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export class UnauthorizedError extends Error { | ||
| statusCode: number; | ||
| constructor(message: string) { | ||
| super(message); | ||
| this.name = "UnauthorizedError"; | ||
| this.statusCode = 401; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "nickname_rules": "The nickname must start and end with an alphanumeric character, and can contain dots, underscores, or hyphens in between. Consecutive dots, underscores, or hyphens are not allowed." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "Invalid credentials": "Credenciales inválidas", | ||
| "Server error": "Error del servidor" | ||
| "Server error": "Error del servidor", | ||
| "Email already in use": "El correo electrónico ya está en uso" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "nickname_rules": "El apodo debe comenzar y terminar con un carácter alfanumérico, y puede contener puntos, guiones bajos o guiones en el medio. No se permiten puntos, guiones bajos o guiones consecutivos." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.