Skip to content

Commit

Permalink
Merge pull request #9 from jbouder/comet-keycloak-nextauth
Browse files Browse the repository at this point in the history
Adding keycloak sso button.
  • Loading branch information
jbouder authored Aug 2, 2024
2 parents 1ff357b + 4471404 commit 1b504dc
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 4 deletions.
140 changes: 137 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"axios": "^1.7.2",
"axios-mock-adapter": "^1.22.0",
"next": "latest",
"next-auth": "^4.24.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.52.1",
Expand Down
16 changes: 16 additions & 0 deletions src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import NextAuth from "next-auth";
import KeycloakProvider from "next-auth/providers/keycloak";

const authOptions = {
providers: [
KeycloakProvider({
clientId: process.env.KEYCLOAK_CLIENT_ID ?? "",
clientSecret: process.env.KEYCLOAK_CLIENT_SECRET ?? "",
issuer: process.env.KEYCLOAK_ISSUER ?? "",
}),
],
};

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };
2 changes: 1 addition & 1 deletion src/app/details/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useAuth from "../../../hooks/use-auth";
import axios from "@utils/axios";

const Details = (): React.ReactElement => {
const { id } = useParams();
const { id } = useParams() as Record<string, string>;
const { isSignedIn } = useAuth();
const { isLoading, error, data } = useQuery<Spacecraft, { message: string }>({
queryKey: ["details", id],
Expand Down
9 changes: 9 additions & 0 deletions src/app/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
TextInput,
} from "@components/comet";

import { signIn as nextAuthSignIn } from 'next-auth/react'

export default function SignIn() {
const router = useRouter();
const { signIn, error } = useAuth();
Expand Down Expand Up @@ -99,6 +101,13 @@ export default function SignIn() {
>
Cancel
</Button>
<Button
id = "keycloak"
type="button"
variant="default"
onClick={() => nextAuthSignIn('keycloak')}>
SSO Keycloak
</Button>
{/* {hasSsoConfig() && (
<Button
id="sign-in-sso"
Expand Down

0 comments on commit 1b504dc

Please sign in to comment.