check api-key
This commit is contained in:
parent
7737f09493
commit
5029890831
1 changed files with 8 additions and 0 deletions
|
|
@ -27,6 +27,14 @@ export async function expressAuthentication(
|
||||||
securityName: string,
|
securityName: string,
|
||||||
_scopes?: string[],
|
_scopes?: string[],
|
||||||
) {
|
) {
|
||||||
|
// API_KEY bypass logic (support api_key, x-api-key, apikey)
|
||||||
|
const apiKeyHeader =
|
||||||
|
request.headers["api-key"] || request.headers["x-api-key"] || request.headers["apikey"];
|
||||||
|
if (apiKeyHeader !== undefined) {
|
||||||
|
if (apiKeyHeader === process.env.API_KEY) {
|
||||||
|
return { preferred_username: "api_key_bypass", apiKeyBypass: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
if (process.env.NODE_ENV !== "production" && process.env.AUTH_BYPASS) {
|
if (process.env.NODE_ENV !== "production" && process.env.AUTH_BYPASS) {
|
||||||
return { preferred_username: "bypassed" };
|
return { preferred_username: "bypassed" };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue