keyboard interactive auth: respect hook disabled setting

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2023-11-18 11:26:37 +01:00
parent 5d9cda9d34
commit a132a21a38
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF

View file

@ -3742,18 +3742,25 @@ func executeKeyboardInteractiveProgram(user *User, authHook string, client ssh.K
} }
func doKeyboardInteractiveAuth(user *User, authHook string, client ssh.KeyboardInteractiveChallenge, ip, protocol string) (User, error) { func doKeyboardInteractiveAuth(user *User, authHook string, client ssh.KeyboardInteractiveChallenge, ip, protocol string) (User, error) {
if err := user.LoadAndApplyGroupSettings(); err != nil {
return *user, err
}
var authResult int var authResult int
var err error var err error
if plugin.Handler.HasAuthScope(plugin.AuthScopeKeyboardInteractive) { if !user.Filters.Hooks.ExternalAuthDisabled {
authResult, err = executeKeyboardInteractivePlugin(user, client, ip, protocol) if plugin.Handler.HasAuthScope(plugin.AuthScopeKeyboardInteractive) {
if authResult == 1 && err == nil { authResult, err = executeKeyboardInteractivePlugin(user, client, ip, protocol)
authResult, err = checkKeyboardInteractiveSecondFactor(user, client, protocol) if authResult == 1 && err == nil {
} authResult, err = checkKeyboardInteractiveSecondFactor(user, client, protocol)
} else if authHook != "" { }
if strings.HasPrefix(authHook, "http") { } else if authHook != "" {
authResult, err = executeKeyboardInteractiveHTTPHook(user, authHook, client, ip, protocol) if strings.HasPrefix(authHook, "http") {
authResult, err = executeKeyboardInteractiveHTTPHook(user, authHook, client, ip, protocol)
} else {
authResult, err = executeKeyboardInteractiveProgram(user, authHook, client, ip, protocol)
}
} else { } else {
authResult, err = executeKeyboardInteractiveProgram(user, authHook, client, ip, protocol) authResult, err = doBuiltinKeyboardInteractiveAuth(user, client, ip, protocol)
} }
} else { } else {
authResult, err = doBuiltinKeyboardInteractiveAuth(user, client, ip, protocol) authResult, err = doBuiltinKeyboardInteractiveAuth(user, client, ip, protocol)
@ -3764,10 +3771,6 @@ func doKeyboardInteractiveAuth(user *User, authHook string, client ssh.KeyboardI
if authResult != 1 { if authResult != 1 {
return *user, fmt.Errorf("keyboard interactive auth failed, result: %v", authResult) return *user, fmt.Errorf("keyboard interactive auth failed, result: %v", authResult)
} }
err = user.LoadAndApplyGroupSettings()
if err != nil {
return *user, err
}
err = user.CheckLoginConditions() err = user.CheckLoginConditions()
if err != nil { if err != nil {
return *user, err return *user, err