Skip to content

Commit

Permalink
more sso stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Dec 1, 2023
1 parent 4f2a69a commit b9b3914
Show file tree
Hide file tree
Showing 7 changed files with 858 additions and 219 deletions.
47 changes: 27 additions & 20 deletions apps/client/layouts/adminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,37 @@ export default function AdminLayout({ children }: any) {
href: "/admin/email",
current: router.pathname === "/admin/email",
},
{
name: "SSO",
href: "/admin/sso",
current: router.pathname === "/admin/sso",
},
];

return (
<div className="flex md:divide-x-2 h-[85vh]">
<div className="hidden md:flex w-56 mt-11">
<nav className="space-y-1 w-full pr-4" aria-label="Sidebar">
{navigation.map((item) => (
<Link
key={item.name}
href={item.href}
className={classNames(
item.current
? "bg-green-500 text-white hover:text-white"
: "text-gray-800 hover:bg-gray-200 hover:text-gray-900",
"flex items-center px-3 py-2 text-sm font-medium rounded-md w-full"
)}
aria-current={item.current ? "page" : undefined}
>
<span className="truncate">{item.name}</span>
</Link>
))}
</nav>
<div className="flex justify-center">
<div className="flex xl:divide-x-2 justify-center h-[85vh] max-w-5xl pr-4">
<div className="hidden xl:flex w-56 mt-11 pr-4">
<nav className="space-y-1 w-full pr-4" aria-label="Sidebar">
{navigation.map((item) => (
<Link
key={item.name}
href={item.href}
className={classNames(
item.current
? "bg-green-500 text-white hover:text-white"
: "text-gray-800 hover:bg-gray-200 hover:text-gray-900",
"flex items-center px-3 py-2 text-sm font-medium rounded-md w-full"
)}
aria-current={item.current ? "page" : undefined}
>
<span className="truncate">{item.name}</span>
</Link>
))}
</nav>
</div>
<div className="flex-1 px-6 xl:w-[800px]">{children}</div>
</div>
<div className="flex-1 px-4">{children}</div>
</div>
);
}
1 change: 1 addition & 0 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@mantine/notifications": "^6.0.13",
"@mantine/spotlight": "^6.0.13",
"@mantine/tiptap": "^6.0.13",
"@radix-ui/themes": "^2.0.1",
"@tabler/icons-react": "^2.20.0",
"@tailwindcss/forms": "^0.4.0",
"@tiptap/extension-highlight": "^2.0.3",
Expand Down
72 changes: 39 additions & 33 deletions apps/client/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "@radix-ui/themes/styles.css";
import "../styles/globals.css";

import {
Expand All @@ -9,6 +10,7 @@ import {
import { MantineProvider } from "@mantine/core";
import { Notifications } from "@mantine/notifications";
import { SpotlightProvider } from "@mantine/spotlight";
import { Theme } from "@radix-ui/themes";
import { useRouter } from "next/router";
import { QueryClient, QueryClientProvider } from "react-query";

Expand Down Expand Up @@ -102,23 +104,25 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }: any) {
if (router.pathname.includes("/admin")) {
return (
<SessionProvider>
<MantineProvider withNormalizeCSS withGlobalStyles>
<SpotlightProvider
shortcut={["mod + P", "mod + K", "/"]}
actions={actions}
>
<QueryClientProvider client={queryClient}>
<Auth>
<NewLayout>
<AdminLayout>
<Notifications position="top-right" />
<Component {...pageProps} />
</AdminLayout>
</NewLayout>
</Auth>
</QueryClientProvider>
</SpotlightProvider>
</MantineProvider>
<Theme>
<MantineProvider withNormalizeCSS withGlobalStyles>
<SpotlightProvider
shortcut={["mod + P", "mod + K", "/"]}
actions={actions}
>
<QueryClientProvider client={queryClient}>
<Auth>
<NewLayout>
<AdminLayout>
<Notifications position="top-right" />
<Component {...pageProps} />
</AdminLayout>
</NewLayout>
</Auth>
</QueryClientProvider>
</SpotlightProvider>
</MantineProvider>
</Theme>
</SessionProvider>
);
}
Expand Down Expand Up @@ -193,22 +197,24 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }: any) {

return (
<SessionProvider>
<MantineProvider withNormalizeCSS withGlobalStyles>
<SpotlightProvider
shortcut={["mod + P", "mod + K", "/"]}
actions={actions}
searchPlaceholder="Search ..."
>
<QueryClientProvider client={queryClient}>
<Auth>
<NewLayout>
<Notifications position="top-right" />
<Component {...pageProps} />
</NewLayout>
</Auth>
</QueryClientProvider>
</SpotlightProvider>
</MantineProvider>
<Theme>
<MantineProvider withNormalizeCSS withGlobalStyles>
<SpotlightProvider
shortcut={["mod + P", "mod + K", "/"]}
actions={actions}
searchPlaceholder="Search ..."
>
<QueryClientProvider client={queryClient}>
<Auth>
<NewLayout>
<Notifications position="top-right" />
<Component {...pageProps} />
</NewLayout>
</Auth>
</QueryClientProvider>
</SpotlightProvider>
</MantineProvider>
</Theme>
</SessionProvider>
);
}
Expand Down
50 changes: 34 additions & 16 deletions apps/client/pages/admin/sso.js → apps/client/pages/admin/sso.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { Fragment, useState } from "react";
import { Menu, Transition, Switch } from "@headlessui/react";
import { EllipsisVerticalIcon } from "@heroicons/react/20/solid";
import { useRouter } from "next/router";
import { useState } from "react";

function classNames(...classes) {
return classes.filter(Boolean).join(" ");
}

export default function Notifications() {
export default function SSO() {
const router = useRouter();

const [enabled, setEnabled] = useState(false);
const [provider, setProvider] = useState();
const [clientId, setClientId] = useState();
const [clientSecret, setClientSecret] = useState();
const [tenantId, setTenantId] = useState();
const [issuer, setIssuer] = useState();
const [provider, setProvider] = useState("");
const [clientId, setClientId] = useState("");
const [clientSecret, setClientSecret] = useState("");
const [tenantId, setTenantId] = useState("");
const [issuer, setIssuer] = useState("");
const [redirectUri, setRedirectUri] = useState(
`${window.location.origin}/auth/oauth`
);

async function postData() {
const res = await fetch("/api/v1/admin/sso/update", {
Expand Down Expand Up @@ -43,8 +47,8 @@ export default function Notifications() {
SSO Settings
</h1>
</div>
<div className="px-4 sm:px-6 md:px-0">
<div className="py-6">
<div className="px-4 sm:px-6 md:px-0 my-4">
<div className="py-6 bg-white shadow-md p-4 rounded-md">
<div className="w-full lg:w-1/2">
<h2 className="text-base font-semibold leading-7 text-gray-900">
Provider
Expand All @@ -68,9 +72,6 @@ export default function Notifications() {
<option>Discord</option>
<option>Gitlab</option>
<option>Google</option>
<option>Atlassian</option>
<option>Apple</option>
{/* <option>Amazon Cognito</option> */}
</select>
</div>
{provider !== undefined && (
Expand All @@ -80,7 +81,7 @@ export default function Notifications() {
htmlFor="email"
className="block text-sm font-medium leading-6 text-gray-900"
>
clientId
Client Id
</label>
<div className="mt-2">
<input
Expand All @@ -97,7 +98,7 @@ export default function Notifications() {
htmlFor="email"
className="block text-sm font-medium leading-6 text-gray-900"
>
clientSecret
Client Secret
</label>
<div className="mt-2">
<input
Expand All @@ -109,6 +110,23 @@ export default function Notifications() {
/>
</div>
</div>
<div>
<label
htmlFor="email"
className="block text-sm font-medium leading-6 text-gray-900"
>
Redirect Uri
</label>
<div className="mt-2">
<input
type="text"
id="redirecturi"
className="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
onChange={(e) => setRedirectUri(e.target.value)}
value={redirectUri}
/>
</div>
</div>
{provider === "Azure Active Directory" && (
<div>
<label
Expand Down
Loading

0 comments on commit b9b3914

Please sign in to comment.