Skip to content

Commit

Permalink
Merge pull request #78 from diggerhq/feat/auth-dynamic-providers
Browse files Browse the repository at this point in the history
supporting dynamic providers
  • Loading branch information
motatoes authored Nov 19, 2024
2 parents 726c7ca + e72984c commit 2b9d09e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"packageManager": "[email protected]",
"dependencies": {
"@ai-sdk/openai": "^0.0.13",
"@auth/core": "^0.37.4",
"@dnd-kit/core": "^6.1.0",
"@headlessui/react": "^1.7.18",
"@headlessui/tailwindcss": "^0.2.0",
Expand Down
41 changes: 41 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import type { OAuthConfig } from '@auth/core/providers';
import NextAuth from 'next-auth';
import Auth0 from 'next-auth/providers/auth0';
import Okta from 'next-auth/providers/okta';

function getAuthProviders() : OAuthConfig<any>[] {
const providers : OAuthConfig<any>[] = []
if (process.env.AUTH_PROVIDER_AUTH0_ENABLED==="1") {
providers.push(Auth0({
authorization: { params: { prompt: 'login' } },
}))
}
if (process.env.AUTH_PROVIDER_OKTA_ENABLED==="1") {
providers.push(Okta({
authorization: { params: { prompt: 'login' } },
}))
}
return providers
}

export const { handlers, signIn, signOut, auth } = NextAuth({
//providers: [WorkOS({ connection: 'conn_01HVH5N4RFQVD9DH5QWGYT844V' })],
providers: [
Auth0({
authorization: { params: { prompt: 'login' } },
}),
],
providers: getAuthProviders(),
callbacks: {
authorized: async ({ auth }) => {
// Logged in users are authenticated, otherwise redirect to login page
Expand Down

0 comments on commit 2b9d09e

Please sign in to comment.