mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-25 21:21:35 +00:00
Add 'completed' field in Interactive Auth API (#1469)
This field must be present even after authentication failure, as tested by sytest. This is needed by #1455. Signed-off-by: Loïck Bonniot <git@lesterpig.com>
This commit is contained in:
parent
fb9a8f215b
commit
439bc235d7
@ -103,7 +103,8 @@ type userInteractiveFlow struct {
|
|||||||
// the user already has a valid access token, but we want to double-check
|
// the user already has a valid access token, but we want to double-check
|
||||||
// that it isn't stolen by re-authenticating them.
|
// that it isn't stolen by re-authenticating them.
|
||||||
type UserInteractive struct {
|
type UserInteractive struct {
|
||||||
Flows []userInteractiveFlow
|
Completed []string
|
||||||
|
Flows []userInteractiveFlow
|
||||||
// Map of login type to implementation
|
// Map of login type to implementation
|
||||||
Types map[string]Type
|
Types map[string]Type
|
||||||
// Map of session ID to completed login types, will need to be extended in future
|
// Map of session ID to completed login types, will need to be extended in future
|
||||||
@ -117,6 +118,7 @@ func NewUserInteractive(getAccByPass GetAccountByPassword, cfg *config.ClientAPI
|
|||||||
}
|
}
|
||||||
// TODO: Add SSO login
|
// TODO: Add SSO login
|
||||||
return &UserInteractive{
|
return &UserInteractive{
|
||||||
|
Completed: []string{},
|
||||||
Flows: []userInteractiveFlow{
|
Flows: []userInteractiveFlow{
|
||||||
{
|
{
|
||||||
Stages: []string{typePassword.Name()},
|
Stages: []string{typePassword.Name()},
|
||||||
@ -140,6 +142,7 @@ func (u *UserInteractive) IsSingleStageFlow(authType string) bool {
|
|||||||
|
|
||||||
func (u *UserInteractive) AddCompletedStage(sessionID, authType string) {
|
func (u *UserInteractive) AddCompletedStage(sessionID, authType string) {
|
||||||
// TODO: Handle multi-stage flows
|
// TODO: Handle multi-stage flows
|
||||||
|
u.Completed = append(u.Completed, authType)
|
||||||
delete(u.Sessions, sessionID)
|
delete(u.Sessions, sessionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,11 +151,13 @@ func (u *UserInteractive) Challenge(sessionID string) *util.JSONResponse {
|
|||||||
return &util.JSONResponse{
|
return &util.JSONResponse{
|
||||||
Code: 401,
|
Code: 401,
|
||||||
JSON: struct {
|
JSON: struct {
|
||||||
Flows []userInteractiveFlow `json:"flows"`
|
Completed []string `json:"completed"`
|
||||||
Session string `json:"session"`
|
Flows []userInteractiveFlow `json:"flows"`
|
||||||
|
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,
|
u.Flows,
|
||||||
sessionID,
|
sessionID,
|
||||||
make(map[string]interface{}),
|
make(map[string]interface{}),
|
||||||
|
Loading…
Reference in New Issue
Block a user