fix
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timo Hocker 2022-01-05 12:58:00 +01:00
parent c7708f4bc0
commit 80a98704af
Signed by: Timo
GPG Key ID: DFAC2CF4E1D1BEC9
2 changed files with 22 additions and 8 deletions

View File

@ -106,7 +106,7 @@ class GatewayClass {
return result;
}
public authenticate (req: IncomingMessage): boolean {
public try_access (req: IncomingMessage): boolean {
logger ('authenticating incoming request');
const cookies = this.get_cookie_auth (req);
let auth = this.get_header_auth (req);
@ -176,22 +176,36 @@ class GatewayClass {
return false;
}
public async authenticate (
req: IncomingMessage,
res: ServerResponse
): Promise<unknown> {
logger ('trying to authenticate http request');
if (this.try_access (req)) {
logger ('authenticated via access_token');
return true;
}
if (await this.try_refresh (req, res)) {
logger ('authenticated via refresh_token');
return true;
}
logger ('could not verify session');
return false;
}
public async process_request (
req: IncomingMessage,
res: ServerResponse,
next: AnyFunc
): Promise<unknown> {
logger ('processing incoming http request');
if (this.authenticate (req)) {
if (await this.authenticate (req, res)) {
logger ('authentification successful, calling next handler');
return next ();
}
if (await this.try_refresh (req, res)) {
logger ('refresh successful, calling next handler');
return next ();
}
logger ('could not verify session, redirecting to auth gateway');
logger ('failed to authenticate, redirecting client');
return this.redirect (res);
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@sapphirecode/auth-server-helper",
"version": "2.2.3",
"version": "2.2.4",
"main": "dist/index.js",
"author": {
"name": "Timo Hocker",