-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Felix Hoops <9974641+jfelixh@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
47 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2024 Software Engineering for Business Information Systems (sebis) <matthes@tum.de> . | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
import { NextResponse } from "next/server"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
export function middleware(req: NextRequest) { | ||
// enforce authorization for sensitive endpoints needed for dynamic authorization | ||
if (req.nextUrl.pathname.startsWith("/api/dynamic")) { | ||
const authHeader = req.headers.get("Authorization"); | ||
const apiKey = authHeader?.split(" ")[1]; | ||
if (apiKey !== process.env.API_KEY) { | ||
return new Response("Unauthorized", { status: 401 }); | ||
} | ||
} | ||
// would like to do logging here but because nextjs middleware runs in Edge Runtime | ||
// it does not seem to like pino logger | ||
return NextResponse.next(); | ||
} | ||
|
||
export const config = { | ||
matcher: "/(api/.*)", | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters