diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..419442e
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,2 @@
+HTTP_BASIC_AUTH=username:password
+MANAGEMENT_APP_API_URL=
diff --git a/.gitignore b/.gitignore
index 9471e17..363b8db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,7 @@
.idea
*.log
tmp/
-
+.env
.next/
test-results/
*.tern-port
diff --git a/environment.d.ts b/environment.d.ts
new file mode 100644
index 0000000..922fb6e
--- /dev/null
+++ b/environment.d.ts
@@ -0,0 +1,6 @@
+declare namespace NodeJS {
+ export interface ProcessEnv {
+ readonly HTTP_BASIC_AUTH: string
+ readonly MANAGEMENT_APP_API_URL: string
+ }
+}
diff --git a/next-env.d.ts b/next-env.d.ts
index 4f11a03..725dd6f 100644
--- a/next-env.d.ts
+++ b/next-env.d.ts
@@ -1,5 +1,6 @@
///
///
+///
// NOTE: This file should not be edited
-// see https://nextjs.org/docs/basic-features/typescript for more information.
+// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
diff --git a/package.json b/package.json
index 31df6c3..06397e6 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
- "name": "app-template",
+ "name": "trusted-output-app",
"version": "0.0.1",
- "description": "App Template",
+ "description": "Trusted Output App",
"main": "index.js",
"scripts": {
"dev": "next dev",
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index bd1a798..b7cce25 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -5,8 +5,8 @@ import '@mantine/core/styles.css'
import { Providers } from '@/components/providers'
export const metadata: Metadata = {
- title: 'SafeInsights App Template',
- description: 'An application',
+ title: 'SafeInsights - TOA',
+ description: 'SafeInsights - Trusted Output Application',
}
export default function RootLayout({
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 7c809a5..5ec0cec 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -3,7 +3,9 @@ import { footerStyles, mainStyles, pageStyles } from './page.css'
export default function Home() {
return (
-
Hello World
+
+ SafeInsights - Trusted Output App
+
)
diff --git a/src/middleware.ts b/src/middleware.ts
new file mode 100644
index 0000000..48ff11d
--- /dev/null
+++ b/src/middleware.ts
@@ -0,0 +1,39 @@
+import { NextResponse } from 'next/server'
+import type { NextRequest } from 'next/server'
+
+const [AUTH_USER, AUTH_PASS] = (process.env.HTTP_BASIC_AUTH || ':').split(':')
+
+function isAuthenticated(req: NextRequest) {
+ const authHeader = req.headers.get('authorization') || req.headers.get('Authorization')
+
+ if (!authHeader) {
+ return false
+ }
+
+ const auth = Buffer.from(authHeader.split(' ')[1], 'base64').toString().split(':')
+ const user = auth[0]
+ const pass = auth[1]
+
+ if (user == AUTH_USER && pass == AUTH_PASS) {
+ return true
+ } else {
+ return false
+ }
+}
+
+// This function can be marked `async` if using `await` inside
+export function middleware(request: NextRequest) {
+ if (!isAuthenticated(request)) {
+ return new NextResponse('Authentication required', {
+ status: 401,
+ headers: { 'WWW-Authenticate': 'Basic' },
+ })
+ }
+
+ return NextResponse.next()
+}
+
+// See "Matching Paths" below to learn more
+export const config = {
+ matcher: '/((?!favicon.ico).*)',
+}
diff --git a/tsconfig.json b/tsconfig.json
index d7e0e47..83d7867 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -22,6 +22,6 @@
"@/*": ["./src/*"]
}
},
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "vitest.config.mts"],
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "vitest.config.mjs"],
"exclude": ["node_modules"]
}