mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-10 08:23:11 -06:00
Add stub login endpoint
This commit is contained in:
parent
060332587d
commit
baf97280f6
|
|
@ -0,0 +1,41 @@
|
||||||
|
package readers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||||
|
"github.com/matrix-org/util"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type loginFlows struct {
|
||||||
|
Flows []flow `json:"flows"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type flow struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Stages []string `json:"stages"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func passwordLogin() loginFlows {
|
||||||
|
f := loginFlows{}
|
||||||
|
s := flow{"m.login.password", []string{"m.login.password"}}
|
||||||
|
f.Flows = append(f.Flows, s)
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func Login(req *http.Request) util.JSONResponse {
|
||||||
|
if req.Method == "GET" {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: 200,
|
||||||
|
JSON: passwordLogin(),
|
||||||
|
}
|
||||||
|
} else if req.Method == "POST" {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: 403,
|
||||||
|
JSON: jsonerror.Forbidden("Not implemented"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: 405,
|
||||||
|
JSON: jsonerror.NotFound("Bad method"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/config"
|
"github.com/matrix-org/dendrite/clientapi/config"
|
||||||
"github.com/matrix-org/dendrite/clientapi/producers"
|
"github.com/matrix-org/dendrite/clientapi/producers"
|
||||||
|
"github.com/matrix-org/dendrite/clientapi/readers"
|
||||||
"github.com/matrix-org/dendrite/clientapi/writers"
|
"github.com/matrix-org/dendrite/clientapi/writers"
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
|
@ -42,6 +43,11 @@ func Setup(servMux *http.ServeMux, httpClient *http.Client, cfg config.ClientAPI
|
||||||
return writers.SendEvent(req, vars["roomID"], vars["eventType"], vars["txnID"], &stateKey, cfg, queryAPI, producer)
|
return writers.SendEvent(req, vars["roomID"], vars["eventType"], vars["txnID"], &stateKey, cfg, queryAPI, producer)
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
r0mux.Handle("/login",
|
||||||
|
make("login", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||||
|
return readers.Login(req)
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
|
||||||
servMux.Handle("/metrics", prometheus.Handler())
|
servMux.Handle("/metrics", prometheus.Handler())
|
||||||
servMux.Handle("/api/", http.StripPrefix("/api", apiMux))
|
servMux.Handle("/api/", http.StripPrefix("/api", apiMux))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue