-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(verity): add auth-next and Keycloak provider
- Loading branch information
Showing
23 changed files
with
891 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
AUTH_KEYCLOAK_ID=verity_client | ||
AUTH_KEYCLOAK_SECRET=veritysecret | ||
AUTH_KEYCLOAK_ISSUER=http://localhost:8080/realms/verity | ||
AUTH_SECRET=authsecret | ||
|
||
DATABASE_URL=postgresql://verity:verity@localhost:5432/verity |
This file contains 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 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 @@ | ||
import { handlers } from '@verity/auth/server'; | ||
|
||
export const { GET, POST } = handlers; |
This file contains 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 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,10 @@ | ||
import NextAuth from 'next-auth'; | ||
import Keycloak from 'next-auth/providers/keycloak'; | ||
|
||
export const middleware = NextAuth({ | ||
providers: [Keycloak], | ||
}).auth; | ||
|
||
export const config = { | ||
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'], | ||
}; |
This file contains 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 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,63 @@ | ||
version: '3.8' | ||
|
||
services: | ||
keycloakdb: | ||
image: postgres:latest | ||
container_name: postgres | ||
environment: | ||
POSTGRES_DB: keycloak | ||
POSTGRES_USER: keycloak | ||
POSTGRES_PASSWORD: keycloak | ||
volumes: | ||
- keycloakdb_data:/var/lib/postgresql/data | ||
networks: | ||
- keycloak-network | ||
|
||
keycloak: | ||
image: quay.io/keycloak/keycloak:latest | ||
container_name: keycloak | ||
command: | ||
- start-dev | ||
- -Dkeycloak.migration.action=import | ||
- -Dkeycloak.migration.provider=singleFile | ||
- -Dkeycloak.migration.file=/opt/keycloak/data/import/realm-export.json | ||
- -Dkeycloak.migration.strategy=IGNORE_EXISTING | ||
environment: | ||
DB_VENDOR: POSTGRES | ||
DB_ADDR: keycloakdb | ||
DB_DATABASE: keycloak | ||
DB_USER: keycloak | ||
DB_PASSWORD: keycloak | ||
KEYCLOAK_ADMIN: admin | ||
KEYCLOAK_ADMIN_PASSWORD: admin | ||
KEYCLOAK_IMPORT: /opt/keycloak/data/import/realm-export.json | ||
volumes: | ||
- ./realm-export.json:/opt/keycloak/data/import/realm-export.json | ||
ports: | ||
- 8080:8080 | ||
depends_on: | ||
- keycloakdb | ||
networks: | ||
- keycloak-network | ||
|
||
verity_db: | ||
image: postgres:latest | ||
container_name: verity_db | ||
environment: | ||
POSTGRES_DB: verity | ||
POSTGRES_USER: verity | ||
POSTGRES_PASSWORD: verity | ||
volumes: | ||
- verity_db_data:/var/lib/postgresql/data | ||
networks: | ||
- keycloak-network | ||
ports: | ||
- 5432:5432 | ||
|
||
networks: | ||
keycloak-network: | ||
driver: bridge | ||
|
||
volumes: | ||
keycloakdb_data: | ||
verity_db_data: |
This file contains 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,18 @@ | ||
{ | ||
"extends": ["plugin:@nx/react", "../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains 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,7 @@ | ||
# auth | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test auth` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains 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,9 @@ | ||
{ | ||
"name": "auth", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/auth/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"// targets": "to see all targets run: nx show project auth --web", | ||
"targets": {} | ||
} |
This file contains 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 @@ | ||
export { signIn, signOut } from 'next-auth/react'; |
This file contains 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,13 @@ | ||
import NextAuth from 'next-auth'; | ||
import Keycloak from 'next-auth/providers/keycloak'; | ||
|
||
import { PrismaAdapter } from '@auth/prisma-adapter'; | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
export const { handlers, signIn, signOut, auth } = NextAuth({ | ||
adapter: PrismaAdapter(prisma), | ||
providers: [Keycloak], | ||
session: { strategy: 'jwt' }, | ||
}); |
This file contains 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 @@ | ||
import 'server-only'; | ||
|
||
export * from './lib/auth'; |
This file contains 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,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"allowJs": false, | ||
"esModuleInterop": false, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
} | ||
], | ||
"extends": "../../tsconfig.base.json" | ||
} |
This file contains 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,25 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"types": [ | ||
"node", | ||
"@nx/react/typings/cssmodule.d.ts", | ||
"@nx/react/typings/image.d.ts", | ||
"next", | ||
"@nx/next/typings/image.d.ts" | ||
] | ||
}, | ||
"exclude": [ | ||
"jest.config.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.tsx", | ||
"src/**/*.test.tsx", | ||
"src/**/*.spec.js", | ||
"src/**/*.test.js", | ||
"src/**/*.spec.jsx", | ||
"src/**/*.test.jsx" | ||
], | ||
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] | ||
} |
Oops, something went wrong.