From 40aef76b79bdeebbc23115e4088385f236291939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sun, 19 Jul 2026 13:53:43 +0200 Subject: [PATCH] examplebroker: Always set the needed auth steps on new session We were setting the needed auth steps only for users that are unknown, but not for the ones we already tracked internally. This implied that accessing again with the same MFA user did not lead to another MFA session --- examplebroker/broker.go | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/examplebroker/broker.go b/examplebroker/broker.go index 11556787cb..8a853b8fbc 100644 --- a/examplebroker/broker.go +++ b/examplebroker/broker.go @@ -305,31 +305,41 @@ func (b *Broker) NewSession(ctx context.Context, username, lang, mode, providerI exampleUsers[username] = userInfoBroker{Password: "goodpass"} } - if _, ok := exampleUsers[username]; !ok && strings.HasPrefix(username, UserIntegrationMfaPrefix) { - exampleUsers[username] = userInfoBroker{Password: "goodpass"} + if strings.HasPrefix(username, UserIntegrationMfaPrefix) { + if _, ok := exampleUsers[username]; !ok { + exampleUsers[username] = userInfoBroker{Password: "goodpass"} + } info.neededAuthSteps = 3 } - if _, ok := exampleUsers[username]; !ok && strings.HasPrefix(username, UserIntegrationMfaNeedsResetPrefix) { - exampleUsers[username] = userInfoBroker{Password: "goodpass"} + if strings.HasPrefix(username, UserIntegrationMfaNeedsResetPrefix) { + if _, ok := exampleUsers[username]; !ok { + exampleUsers[username] = userInfoBroker{Password: "goodpass"} + } info.neededAuthSteps = 3 info.pwdChange = mustReset } - if _, ok := exampleUsers[username]; !ok && strings.HasPrefix(username, UserIntegrationMfaWithResetPrefix) { - exampleUsers[username] = userInfoBroker{Password: "goodpass"} + if strings.HasPrefix(username, UserIntegrationMfaWithResetPrefix) { + if _, ok := exampleUsers[username]; !ok { + exampleUsers[username] = userInfoBroker{Password: "goodpass"} + } info.neededAuthSteps = 3 info.pwdChange = canReset } - if _, ok := exampleUsers[username]; !ok && strings.HasPrefix(username, UserIntegrationNeedsResetPrefix) { - exampleUsers[username] = userInfoBroker{Password: "goodpass"} + if strings.HasPrefix(username, UserIntegrationNeedsResetPrefix) { + if _, ok := exampleUsers[username]; !ok { + exampleUsers[username] = userInfoBroker{Password: "goodpass"} + } info.neededAuthSteps = 2 info.pwdChange = mustReset } - if _, ok := exampleUsers[username]; !ok && strings.HasPrefix(username, UserIntegrationCanResetPrefix) { - exampleUsers[username] = userInfoBroker{Password: "goodpass"} + if strings.HasPrefix(username, UserIntegrationCanResetPrefix) { + if _, ok := exampleUsers[username]; !ok { + exampleUsers[username] = userInfoBroker{Password: "goodpass"} + } info.neededAuthSteps = 2 info.pwdChange = canReset }