mirror of
https://github.com/goauthentik/authentik
synced 2026-04-28 02:18:11 +02:00
* packages/client-go: init Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * format Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove mod/sum Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix translate Signed-off-by: Jens Langhammer <jens@goauthentik.io> * no go replace Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update rust makefile with pwd Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix build Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * don't need a version ig? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * exclude go client from cspell Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix main docker build Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
59 lines
2.7 KiB
Go
59 lines
2.7 KiB
Go
package flow
|
|
|
|
import (
|
|
"errors"
|
|
"strconv"
|
|
|
|
api "goauthentik.io/packages/client-go"
|
|
)
|
|
|
|
func (fe *FlowExecutor) solveChallenge_Identification(challenge *api.ChallengeTypes, req api.ApiFlowsExecutorSolveRequest) (api.FlowChallengeResponseRequest, error) {
|
|
r := api.NewIdentificationChallengeResponseRequest()
|
|
r.SetUidField(fe.getAnswer(StageIdentification))
|
|
r.SetPassword(fe.getAnswer(StagePassword))
|
|
return api.IdentificationChallengeResponseRequestAsFlowChallengeResponseRequest(r), nil
|
|
}
|
|
|
|
func (fe *FlowExecutor) solveChallenge_Password(challenge *api.ChallengeTypes, req api.ApiFlowsExecutorSolveRequest) (api.FlowChallengeResponseRequest, error) {
|
|
r := api.NewPasswordChallengeResponseRequest(fe.getAnswer(StagePassword))
|
|
return api.PasswordChallengeResponseRequestAsFlowChallengeResponseRequest(r), nil
|
|
}
|
|
|
|
func (fe *FlowExecutor) solveChallenge_UserLogin(challenge *api.ChallengeTypes, req api.ApiFlowsExecutorSolveRequest) (api.FlowChallengeResponseRequest, error) {
|
|
r := api.NewUserLoginChallengeResponseRequest(true)
|
|
return api.UserLoginChallengeResponseRequestAsFlowChallengeResponseRequest(r), nil
|
|
}
|
|
|
|
func (fe *FlowExecutor) solveChallenge_AuthenticatorValidate(challenge *api.ChallengeTypes, req api.ApiFlowsExecutorSolveRequest) (api.FlowChallengeResponseRequest, error) {
|
|
// We only support duo and code-based authenticators, check if that's allowed
|
|
var deviceChallenge *api.DeviceChallenge
|
|
inner := api.NewAuthenticatorValidationChallengeResponseRequest()
|
|
for _, devCh := range challenge.AuthenticatorValidationChallenge.DeviceChallenges {
|
|
if devCh.DeviceClass == api.DEVICECLASSESENUM_DUO {
|
|
deviceChallenge = &devCh
|
|
devId, err := strconv.ParseInt(deviceChallenge.DeviceUid, 10, 32)
|
|
if err != nil {
|
|
return api.FlowChallengeResponseRequest{}, errors.New("failed to convert duo device id to int")
|
|
}
|
|
devId32 := int32(devId)
|
|
inner.SelectedChallenge = (*api.DeviceChallengeRequest)(deviceChallenge)
|
|
inner.Duo = &devId32
|
|
}
|
|
if devCh.DeviceClass == api.DEVICECLASSESENUM_STATIC ||
|
|
devCh.DeviceClass == api.DEVICECLASSESENUM_TOTP {
|
|
// Only use code-based devices if we have a code in the entered password,
|
|
// and we haven't selected a push device yet
|
|
if deviceChallenge == nil && fe.getAnswer(StageAuthenticatorValidate) != "" {
|
|
deviceChallenge = &devCh
|
|
inner.SelectedChallenge = (*api.DeviceChallengeRequest)(deviceChallenge)
|
|
code := fe.getAnswer(StageAuthenticatorValidate)
|
|
inner.Code = &code
|
|
}
|
|
}
|
|
}
|
|
if deviceChallenge == nil {
|
|
return api.FlowChallengeResponseRequest{}, errors.New("no compatible authenticator class found")
|
|
}
|
|
return api.AuthenticatorValidationChallengeResponseRequestAsFlowChallengeResponseRequest(inner), nil
|
|
}
|