Make the challenge response available to other packages

This commit is contained in:
Till Faelligen 2022-02-25 15:06:01 +01:00
parent 5510ccaa78
commit d9b1d0129f

View file

@ -144,21 +144,23 @@ func (u *UserInteractive) AddCompletedStage(sessionID, authType string) {
delete(u.Sessions, sessionID) delete(u.Sessions, sessionID)
} }
// Challenge returns an HTTP 401 with the supported flows for authenticating type Challenge struct {
func (u *UserInteractive) Challenge(sessionID string) *util.JSONResponse {
return &util.JSONResponse{
Code: 401,
JSON: struct {
Completed []string `json:"completed"` Completed []string `json:"completed"`
Flows []userInteractiveFlow `json:"flows"` Flows []userInteractiveFlow `json:"flows"`
Session string `json:"session"` Session string `json:"session"`
// TODO: Return any additional `params` // TODO: Return any additional `params`
Params map[string]interface{} `json:"params"` Params map[string]interface{} `json:"params"`
}{ }
u.Completed,
u.Flows, // Challenge returns an HTTP 401 with the supported flows for authenticating
sessionID, func (u *UserInteractive) Challenge(sessionID string) *util.JSONResponse {
make(map[string]interface{}), return &util.JSONResponse{
Code: 401,
JSON: Challenge{
Completed: u.Completed,
Flows: u.Flows,
Session: sessionID,
Params: make(map[string]interface{}),
}, },
} }
} }