Add Keycloak as a Link login option
This commit is contained in:
parent
ac42d7df78
commit
e8f2cc4c50
2 changed files with 29 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import {
|
||||||
Google as GoogleIcon,
|
Google as GoogleIcon,
|
||||||
Microsoft as MicrosoftIcon,
|
Microsoft as MicrosoftIcon,
|
||||||
Key as KeyIcon,
|
Key as KeyIcon,
|
||||||
|
VpnKey as KeycloakIcon,
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
import { signIn, getProviders } from "next-auth/react";
|
import { signIn, getProviders } from "next-auth/react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
@ -200,6 +201,21 @@ export const Login: FC<LoginProps> = ({ session, baseURL }) => {
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
|
{provider === "keycloak" && (
|
||||||
|
<Grid item sx={{ width: "100%" }}>
|
||||||
|
<IconButton
|
||||||
|
sx={buttonStyles}
|
||||||
|
onClick={() =>
|
||||||
|
signIn("keycloak", {
|
||||||
|
callbackUrl,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<KeycloakIcon sx={{ mr: 1 }} />
|
||||||
|
Sign in with Keycloak
|
||||||
|
</IconButton>
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
{provider === "credentials" && (
|
{provider === "credentials" && (
|
||||||
<Grid item container spacing={3}>
|
<Grid item container spacing={3}>
|
||||||
<Grid item sx={{ width: "100%" }}>
|
<Grid item sx={{ width: "100%" }}>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import Google from "next-auth/providers/google";
|
||||||
import Credentials from "next-auth/providers/credentials";
|
import Credentials from "next-auth/providers/credentials";
|
||||||
import Apple from "next-auth/providers/apple";
|
import Apple from "next-auth/providers/apple";
|
||||||
import AzureADProvider from "next-auth/providers/azure-ad";
|
import AzureADProvider from "next-auth/providers/azure-ad";
|
||||||
|
import Keycloak from "next-auth/providers/keycloak";
|
||||||
import { createLogger } from "@link-stack/logger";
|
import { createLogger } from "@link-stack/logger";
|
||||||
|
|
||||||
const logger = createLogger('link-authentication');
|
const logger = createLogger('link-authentication');
|
||||||
|
|
@ -101,6 +102,18 @@ if (process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET) {
|
||||||
tenantId: process.env.AZURE_AD_TENANT_ID,
|
tenantId: process.env.AZURE_AD_TENANT_ID,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
} else if (
|
||||||
|
process.env.KEYCLOAK_CLIENT_ID &&
|
||||||
|
process.env.KEYCLOAK_CLIENT_SECRET &&
|
||||||
|
process.env.KEYCLOAK_ISSUER
|
||||||
|
) {
|
||||||
|
providers.push(
|
||||||
|
Keycloak({
|
||||||
|
clientId: process.env.KEYCLOAK_CLIENT_ID,
|
||||||
|
clientSecret: process.env.KEYCLOAK_CLIENT_SECRET,
|
||||||
|
issuer: process.env.KEYCLOAK_ISSUER,
|
||||||
|
}),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
providers.push(
|
providers.push(
|
||||||
Credentials({
|
Credentials({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue