Skip to content

Commit

Permalink
feat: add authentication to yearly pages
Browse files Browse the repository at this point in the history
- added msal wrappers to [year]/ layout and page
  • Loading branch information
Jone-Torgersen committed Jan 23, 2025
1 parent 347de06 commit c93677d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions frontend/src/app/[year]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Fragment, PropsWithChildren } from "react";
import { PropsWithChildren } from "react";
import Footer from "../components/Footer/Footer";
import { Header } from "../components/Header";
import AuthProvider from "../auth/authProvider";

export default function Layout({ children }: PropsWithChildren) {
return (
<Fragment>
<AuthProvider>
<Header />
{children}
<Footer />
</Fragment>
</AuthProvider>
);
}
10 changes: 7 additions & 3 deletions frontend/src/app/[year]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Hero from "@/app/components/hero/Hero";
import Summary from "@/app/components/summary/Summary";
import { useParams } from "next/navigation";
import Link from "next/link";
import { MsalAuthenticationTemplate } from "@azure/msal-react";
import { InteractionType } from "@azure/msal-browser";

export default function SurveyPage() {
const { year } = useParams<{ year: string }>();
Expand All @@ -23,9 +25,11 @@ export default function SurveyPage() {
);
return (
<main>
<Hero />
<Summary />
<Survey />
<MsalAuthenticationTemplate interactionType={InteractionType.Redirect}>
<Hero />
<Summary />
<Survey />
</MsalAuthenticationTemplate>
</main>
);
}
17 changes: 8 additions & 9 deletions frontend/src/app/auth/authConfig.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
const scope = 'api://62b05a5f-4b57-4bc2-99d7-af91cc1694c8/user_impersonation';
import { Configuration } from "@azure/msal-browser";

const scope = "api://62b05a5f-4b57-4bc2-99d7-af91cc1694c8/user_impersonation";
export const scopes = [scope];

export const msalConfig = {
export const msalConfig: Configuration = {
auth: {
clientId: '2f3f1b63-3f3d-4389-bf65-c43d09ff8aa5',
authority: `https://login.microsoftonline.com/c317fa72-b393-44ea-a87c-ea272e8d963d`,
clientId: "2f3f1b63-3f3d-4389-bf65-c43d09ff8aa5",
authority: `https://login.microsoftonline.com/c317fa72-b393-44ea-a87c-ea272e8d963d`,
},
cache: {
cacheLocation: "localStorage",
storeAuthStateInCookie: true,
},
request: {
scopes,
cacheLocation: "localStorage",
storeAuthStateInCookie: true,
},
};

Expand Down

0 comments on commit c93677d

Please sign in to comment.