Merge pull request #521 from chrisbsmith/authelia
Adds OIDC support for Authelia
This commit is contained in:
commit
189db27c5b
|
@ -75,6 +75,13 @@ AUTH0_ISSUER=
|
||||||
AUTH0_CLIENT_SECRET=
|
AUTH0_CLIENT_SECRET=
|
||||||
AUTH0_CLIENT_ID=
|
AUTH0_CLIENT_ID=
|
||||||
|
|
||||||
|
# Authelia
|
||||||
|
NEXT_PUBLIC_AUTHELIA_ENABLED=""
|
||||||
|
AUTHELIA_CLIENT_ID=""
|
||||||
|
AUTHELIA_CLIENT_SECRET=""
|
||||||
|
AUTHELIA_WELLKNOWN_URL=""
|
||||||
|
|
||||||
|
|
||||||
# Authentik
|
# Authentik
|
||||||
NEXT_PUBLIC_AUTHENTIK_ENABLED=
|
NEXT_PUBLIC_AUTHENTIK_ENABLED=
|
||||||
AUTHENTIK_CUSTOM_NAME=
|
AUTHENTIK_CUSTOM_NAME=
|
||||||
|
|
|
@ -98,19 +98,19 @@ if (
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: emailEnabled
|
where: emailEnabled
|
||||||
? {
|
? {
|
||||||
OR: [
|
OR: [
|
||||||
{
|
{
|
||||||
username: username.toLowerCase(),
|
username: username.toLowerCase(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
email: username?.toLowerCase(),
|
email: username?.toLowerCase(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
emailVerified: { not: null },
|
emailVerified: { not: null },
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
username: username.toLowerCase(),
|
username: username.toLowerCase(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let passwordMatches: boolean = false;
|
let passwordMatches: boolean = false;
|
||||||
|
@ -240,6 +240,37 @@ if (process.env.NEXT_PUBLIC_AUTH0_ENABLED === "true") {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Authelia
|
||||||
|
if (process.env.NEXT_PUBLIC_AUTHELIA_ENABLED === "true") {
|
||||||
|
providers.push(
|
||||||
|
{
|
||||||
|
id: "authelia",
|
||||||
|
name: "Authelia",
|
||||||
|
type: "oauth",
|
||||||
|
clientId: process.env.AUTHELIA_CLIENT_ID!,
|
||||||
|
clientSecret: process.env.AUTHELIA_CLIENT_SECRET!,
|
||||||
|
wellKnown: process.env.AUTHELIA_WELLKNOWN_URL!,
|
||||||
|
authorization: { params: { scope: "openid email profile" } },
|
||||||
|
idToken: true,
|
||||||
|
checks: ["pkce", "state"],
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Authentik
|
// Authentik
|
||||||
if (process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === "true") {
|
if (process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === "true") {
|
||||||
providers.push(
|
providers.push(
|
||||||
|
|
|
@ -391,10 +391,17 @@ export function getLogins() {
|
||||||
name: process.env.ZOOM_CUSTOM_NAME ?? "Zoom",
|
name: process.env.ZOOM_CUSTOM_NAME ?? "Zoom",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Authelia
|
||||||
|
if (process.env.NEXT_PUBLIC_AUTHELIA_ENABLED === "true") {
|
||||||
|
buttonAuths.push({
|
||||||
|
method: "authelia",
|
||||||
|
name: process.env.AUTHELIA_CUSTOM_NAME ?? "Authelia",
|
||||||
|
});
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
credentialsEnabled:
|
credentialsEnabled:
|
||||||
process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === "true" ||
|
process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === "true" ||
|
||||||
process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === undefined
|
process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === undefined
|
||||||
? "true"
|
? "true"
|
||||||
: "false",
|
: "false",
|
||||||
emailEnabled:
|
emailEnabled:
|
||||||
|
|
|
@ -76,6 +76,13 @@ declare global {
|
||||||
AUTH0_CLIENT_SECRET?: string;
|
AUTH0_CLIENT_SECRET?: string;
|
||||||
AUTH0_CLIENT_ID?: string;
|
AUTH0_CLIENT_ID?: string;
|
||||||
|
|
||||||
|
// Authelia
|
||||||
|
NEXT_PUBLIC_AUTHELIA_ENABLED?: string;
|
||||||
|
AUTHELIA_CUSTOM_NAME?: string;
|
||||||
|
AUTHELIA_CLIENT_ID?: string;
|
||||||
|
AUTHELIA_CLIENT_SECRET?: string;
|
||||||
|
AUTHELIA_WELLKNOWN_URL?: string;
|
||||||
|
|
||||||
// Authentik
|
// Authentik
|
||||||
NEXT_PUBLIC_AUTHENTIK_ENABLED?: string;
|
NEXT_PUBLIC_AUTHENTIK_ENABLED?: string;
|
||||||
AUTHENTIK_CUSTOM_NAME?: string;
|
AUTHENTIK_CUSTOM_NAME?: string;
|
||||||
|
@ -410,4 +417,4 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {};
|
export { };
|
||||||
|
|
Ŝarĝante…
Reference in New Issue