Skip to content

Commit

Permalink
examplebroker: Add parameter for filtering MFA modes
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Nov 14, 2024
1 parent 4f61d0b commit 5fb7052
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examplebroker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type authMode struct {
email string
phone string
wantedCode string
isMFA bool
}

type sessionInfo struct {
Expand Down Expand Up @@ -153,6 +154,7 @@ var (
selectionLabel: "Authentication code",
phone: "+33…",
wantedCode: "temporary pass",
isMFA: true,
ui: map[string]string{
layouts.Type: layouts.Form,
layouts.Label: "Enter your one time credential",
Expand All @@ -165,6 +167,7 @@ var (
id: "phoneack1",
selectionLabel: "Use your phone +33…",
phone: "+33…",
isMFA: true,
ui: map[string]string{
layouts.Type: layouts.Form,
layouts.Label: "Unlock your phone +33… or accept request on web interface:",
Expand All @@ -186,6 +189,7 @@ var (
fidoDeviceMode = authMode{
id: "fidodevice1",
selectionLabel: "Use your fido device foo",
isMFA: true,
ui: map[string]string{
layouts.Type: layouts.Form,
layouts.Label: "Plug your fido device and press with your thumb",
Expand Down Expand Up @@ -459,10 +463,14 @@ func getSupportedModes(sessionInfo sessionInfo, supportedUILayouts []map[string]

func getMfaModes(info sessionInfo, supportedModes map[string]authMode) map[string]authMode {
mfaModes := make(map[string]authMode)
for _, mode := range []string{phoneAck1Mode.id, totpWithButtonMode.id, fidoDeviceMode.id} {
if _, exists := supportedModes[mode]; exists && info.currentAuthMode != mode {
mfaModes[mode] = supportedModes[mode]
for _, mode := range supportedModes {
if !mode.isMFA {
continue
}
if info.currentAuthMode == mode.id {
continue
}
mfaModes[mode.id] = mode
}
return mfaModes
}
Expand Down

0 comments on commit 5fb7052

Please sign in to comment.