Skip to content

Commit

Permalink
feat: #OBS-I529: authenticates for each login
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakshitha-D committed Jan 29, 2025
1 parent 0bcec6c commit 9d86470
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/services/keycloakAuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,21 @@ export class KeycloakAuthProvider implements BaseAuthProvider {
return this.keycloak.middleware();
}

authenticate(): (req: Request, res: Response, next: NextFunction) => void {
return this.keycloak.protect();
authenticate(): (req: any, res: Response, next: NextFunction) => void {
const protect = this.keycloak.protect();

return async (req: any, res: Response, next: NextFunction) => {
protect(req, res, async () => {
try {
if (req.kauth?.grant) {
await authenticated(req);
}
next();
} catch (error) {
next(error);
}
});
};
}

async logout(req: Request, res: Response): Promise<void> {
Expand Down

0 comments on commit 9d86470

Please sign in to comment.