fix log
This commit is contained in:
parent
9eb539b451
commit
61ec81687c
8 changed files with 365 additions and 358 deletions
|
|
@ -3,6 +3,8 @@ import { createDecoder, createVerifier } from "fast-jwt";
|
|||
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import { addLogSequence } from "../interfaces/utils";
|
||||
import { RequestWithUser } from "./user";
|
||||
|
||||
if (!process.env.AUTH_PUBLIC_KEY && !process.env.AUTH_REALM_URL) {
|
||||
throw new Error("Require keycloak AUTH_PUBLIC_KEY or AUTH_REALM_URL.");
|
||||
|
|
@ -22,7 +24,7 @@ const jwtVerify = createVerifier({
|
|||
const jwtDecode = createDecoder();
|
||||
|
||||
export async function expressAuthentication(
|
||||
request: express.Request,
|
||||
request: RequestWithUser,
|
||||
securityName: string,
|
||||
_scopes?: string[],
|
||||
) {
|
||||
|
|
@ -56,6 +58,11 @@ export async function expressAuthentication(
|
|||
request.app.locals.logData = {};
|
||||
}
|
||||
|
||||
addLogSequence(request, {
|
||||
action: "database",
|
||||
status: "success",
|
||||
description: "Query Data.",
|
||||
});
|
||||
request.app.locals.logData.userId = payload.sub;
|
||||
request.app.locals.logData.userName = payload.name;
|
||||
request.app.locals.logData.user = payload.preferred_username;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue