Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding keycloak sso button. #9

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading