Skip to content

Commit 39e8827

Browse files
geroplroboquat
authored andcommitted
[server] IAM: Report missing session as client error instead of system error
1 parent 2da149e commit 39e8827

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

components/server/src/auth/authenticator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export class Authenticator {
114114
return;
115115
}
116116
if (!req.session) {
117-
increaseLoginCounter("failed", authProvider.info.host);
117+
// The session is missing entirely: count as client error
118+
increaseLoginCounter("failed_client", authProvider.info.host);
118119
log.info({}, `No session.`, { "login-flow": true });
119120
res.redirect(this.getSorryUrl(`No session found. Please refresh the browser.`));
120121
return;

components/server/src/auth/generic-auth-provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ export class GenericAuthProvider implements AuthProvider {
336336

337337
// assert additional infomation is attached to current session
338338
if (!authFlow) {
339-
increaseLoginCounter("failed", this.host);
339+
// The auth flow state info is missing in the session: count as client error
340+
increaseLoginCounter("failed_client", this.host);
340341

341342
log.error(cxt, `(${strategyName}) No session found during auth callback.`, { clientInfo });
342343
response.redirect(this.getSorryUrl(`Please allow Cookies in your browser and try to log in again.`));

components/server/src/prometheus-metrics.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ const loginCounter = new prometheusClient.Counter({
3030
labelNames: ["status", "auth_host"],
3131
});
3232

33-
export function increaseLoginCounter(status: string, auth_host: string) {
33+
type LoginCounterStatus =
34+
// The login attempt failed due to a system error (picked up by alerts)
35+
| "failed"
36+
// The login attempt succeeded
37+
| "succeeded"
38+
// The login attempt failed, because the client failed to provide complete session information, for instance.
39+
| "failed_client";
40+
41+
export function increaseLoginCounter(status: LoginCounterStatus, auth_host: string) {
3442
loginCounter.inc({
3543
status,
3644
auth_host,

0 commit comments

Comments
 (0)