-
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.
Signed-off-by: Paul Hildebrandt <[email protected]>
- Loading branch information
Showing
14 changed files
with
366 additions
and
46 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 |
---|---|---|
@@ -1 +1,6 @@ | ||
API_URL=https://capi-jsgen.moin.k8s.scs.community | ||
API_URL=https://capi-jsgen.moin.k8s.scs.community | ||
|
||
AUTH_SECRET= | ||
DEX_URL=https://dex.k8s.scs.community | ||
DEX_CLIENT_ID= | ||
DEX_CLIENT_SECRET= |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 @@ | ||
import { handlers } from "@/app/auth"; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import NextAuth from "next-auth"; | ||
import type { NextAuthConfig } from "next-auth"; | ||
|
||
declare module "next-auth" { | ||
interface Session { | ||
accessToken?: string; | ||
profile?: any; | ||
} | ||
} | ||
|
||
const config = { | ||
providers: [ | ||
{ | ||
id: "dex", | ||
name: "SCS Dex", | ||
type: "oidc", | ||
authorization: { | ||
params: { scope: ["openid profile email groups"] }, | ||
}, | ||
issuer: process.env.DEX_URL, | ||
clientId: process.env.DEX_CLIENT_ID, | ||
client: { | ||
token_endpoint_auth_method: "none", | ||
}, | ||
profile(profile) { | ||
return { | ||
id: profile.sub, | ||
name: profile.name, | ||
email: profile.email, | ||
groups: profile.groups, | ||
username: profile.preferred_username, | ||
}; | ||
}, | ||
}, | ||
], | ||
basePath: "/api/auth", | ||
session: { strategy: "jwt" }, | ||
callbacks: { | ||
jwt({ token, user, profile }) { | ||
if (user) token.user = user; | ||
if (profile) token.profile = profile; | ||
return token; | ||
}, | ||
async session({ session, token, user }) { | ||
if (session.user) session.profile = token.profile; | ||
return session; | ||
}, | ||
}, | ||
debug: process.env.NODE_ENV !== "production" ? true : false, | ||
} satisfies NextAuthConfig; | ||
|
||
export const { handlers, auth, signIn, signOut } = NextAuth(config); |
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
Oops, something went wrong.