⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
feat: add generic OIDC provider
Idar Lafish9f1f37da5822
diff --git a/.env.sample b/.env.sampleindex e6a9bf62..09086c76 100644--- a/.env.sample+++ b/.env.sample@@ -474,3 +474,11 @@ NEXT_PUBLIC_ZOOM_ENABLED=ZOOM_CUSTOM_NAME=ZOOM_CLIENT_ID=ZOOM_CLIENT_SECRET=++# Generic OIDC+NEXT_PUBLIC_OIDC_ENABLED=+OIDC_CUSTOM_NAME=+OIDC_WELLKNOWN_URL=+OIDC_CLIENT_ID=+OIDC_CLIENT_SECRET=+OIDC_SCOPES=diff --git a/apps/web/pages/api/v1/auth/[...nextauth].ts b/apps/web/pages/api/v1/auth/[...nextauth].tsindex 7623159e..bacf3066 100644--- a/apps/web/pages/api/v1/auth/[...nextauth].ts+++ b/apps/web/pages/api/v1/auth/[...nextauth].ts@@ -1310,6 +1310,40 @@ if (process.env.NEXT_PUBLIC_ZOOM_ENABLED_ENABLED === "true") {};}+// Generic OIDC+if (process.env.NEXT_PUBLIC_OIDC_ENABLED === "true") {+ providers.push({+ id: "oidc",+ name: process.env.OIDC_CUSTOM_NAME ?? "OIDC",+ type: "oauth",+ clientId: process.env.OIDC_CLIENT_ID!,+ clientSecret: process.env.OIDC_CLIENT_SECRET!,+ wellKnown: process.env.OIDC_WELLKNOWN_URL!,+ authorization: {+ params: { scope: process.env.OIDC_SCOPES ?? "openid email profile" },+ },+ idToken: true,+ checks: ["pkce", "state"],+ httpOptions: {+ timeout: 10000,+ },+ profile(profile) {+ return {+ id: profile.sub,+ name: profile.name,+ email: profile.email,+ username: profile.preferred_username,+ };+ },+ });++ const _linkAccount = adapter.linkAccount;+ adapter.linkAccount = (account) => {+ const { "not-before-policy": _, refresh_expires_in, ...data } = account;+ return _linkAccount ? _linkAccount(data) : undefined;+ };+}+export default async function auth(req: NextApiRequest, res: NextApiResponse) {return await NextAuth(req, res, {adapter: adapter as Adapter,diff --git a/apps/web/pages/api/v1/logins/index.ts b/apps/web/pages/api/v1/logins/index.tsindex bbd3e08d..7fe71126 100644--- a/apps/web/pages/api/v1/logins/index.ts+++ b/apps/web/pages/api/v1/logins/index.ts@@ -419,6 +419,13 @@ export function getLogins() {name: process.env.AUTHELIA_CUSTOM_NAME ?? "Authelia",});}+ // Generic OIDC+ if (process.env.NEXT_PUBLIC_OIDC_ENABLED === "true") {+ buttonAuths.push({+ method: "oidc",+ name: process.env.OIDC_CUSTOM_NAME ?? "OIDC",+ });+ }return {credentialsEnabled:process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED !== "false"