mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
mas: reorganise endpoints
This commit is contained in:
parent
e943ba5c8d
commit
7eec60e2ef
1 changed files with 50 additions and 48 deletions
|
@ -330,14 +330,15 @@ func Setup(
|
||||||
}, httputil.WithAllowGuests()),
|
}, httputil.WithAllowGuests()),
|
||||||
).Methods(http.MethodPost, http.MethodOptions)
|
).Methods(http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
if m := mscCfg.MSC3861; mscCfg.Enabled("msc3861") && m != nil && m.Enabled {
|
if mscCfg.MSC3861Enabled() {
|
||||||
|
m := mscCfg.MSC3861
|
||||||
|
|
||||||
unstableMux.Handle("/org.matrix.msc2965/auth_issuer",
|
unstableMux.Handle("/org.matrix.msc2965/auth_issuer",
|
||||||
httputil.MakeExternalAPI("auth_issuer", func(r *http.Request) util.JSONResponse {
|
httputil.MakeExternalAPI("auth_issuer", func(r *http.Request) util.JSONResponse {
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: map[string]string{
|
return util.JSONResponse{Code: http.StatusOK, JSON: map[string]string{
|
||||||
"issuer": m.Issuer,
|
"issuer": m.Issuer,
|
||||||
}}
|
}}
|
||||||
})).Methods(http.MethodGet)
|
})).Methods(http.MethodGet)
|
||||||
|
|
||||||
synapseAdminRouter.Handle("/admin/v1/username_available",
|
synapseAdminRouter.Handle("/admin/v1/username_available",
|
||||||
httputil.MakeServiceAdminAPI("admin_username_available", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
httputil.MakeServiceAdminAPI("admin_username_available", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
||||||
return AdminCheckUsernameAvailable(r, userAPI, cfg)
|
return AdminCheckUsernameAvailable(r, userAPI, cfg)
|
||||||
|
@ -357,7 +358,6 @@ func Setup(
|
||||||
return util.JSONResponse{Code: http.StatusMethodNotAllowed, JSON: nil}
|
return util.JSONResponse{Code: http.StatusMethodNotAllowed, JSON: nil}
|
||||||
}
|
}
|
||||||
})).Methods(http.MethodPut, http.MethodGet)
|
})).Methods(http.MethodPut, http.MethodGet)
|
||||||
|
|
||||||
synapseAdminRouter.Handle("/admin/v2/users/{userID}/devices",
|
synapseAdminRouter.Handle("/admin/v2/users/{userID}/devices",
|
||||||
httputil.MakeServiceAdminAPI("admin_create_retrieve_user_devices", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
httputil.MakeServiceAdminAPI("admin_create_retrieve_user_devices", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
||||||
return AdminUserDeviceRetrieveCreate(r, userAPI, cfg)
|
return AdminUserDeviceRetrieveCreate(r, userAPI, cfg)
|
||||||
|
@ -370,11 +370,57 @@ func Setup(
|
||||||
httputil.MakeServiceAdminAPI("admin_delete_user_devices", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
httputil.MakeServiceAdminAPI("admin_delete_user_devices", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
||||||
return AdminUserDevicesDelete(r, userAPI, cfg)
|
return AdminUserDevicesDelete(r, userAPI, cfg)
|
||||||
})).Methods(http.MethodPost)
|
})).Methods(http.MethodPost)
|
||||||
|
|
||||||
synapseAdminRouter.Handle("/admin/v1/users/{userID}/_allow_cross_signing_replacement_without_uia",
|
synapseAdminRouter.Handle("/admin/v1/users/{userID}/_allow_cross_signing_replacement_without_uia",
|
||||||
httputil.MakeServiceAdminAPI("admin_allow_cross_signing_replacement_without_uia", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
httputil.MakeServiceAdminAPI("admin_allow_cross_signing_replacement_without_uia", m.AdminToken, func(r *http.Request) util.JSONResponse {
|
||||||
return AdminAllowCrossSigningReplacementWithoutUIA(r, userAPI)
|
return AdminAllowCrossSigningReplacementWithoutUIA(r, userAPI)
|
||||||
})).Methods(http.MethodPost)
|
})).Methods(http.MethodPost)
|
||||||
|
} else {
|
||||||
|
// If msc3861 is enabled, these endpoints are either redundant or replaced by Matrix Auth Service (MAS)
|
||||||
|
// Once we migrate to MAS completely, these edndpoints should be removed
|
||||||
|
|
||||||
|
v3mux.Handle("/register", httputil.MakeExternalAPI("register", func(req *http.Request) util.JSONResponse {
|
||||||
|
if r := rateLimits.Limit(req, nil); r != nil {
|
||||||
|
return *r
|
||||||
|
}
|
||||||
|
return Register(req, userAPI, cfg)
|
||||||
|
})).Methods(http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
|
v3mux.Handle("/register/available", httputil.MakeExternalAPI("registerAvailable", func(req *http.Request) util.JSONResponse {
|
||||||
|
if r := rateLimits.Limit(req, nil); r != nil {
|
||||||
|
return *r
|
||||||
|
}
|
||||||
|
return RegisterAvailable(req, cfg, userAPI)
|
||||||
|
})).Methods(http.MethodGet, http.MethodOptions)
|
||||||
|
|
||||||
|
// Stub endpoints required by Element
|
||||||
|
|
||||||
|
v3mux.Handle("/login",
|
||||||
|
httputil.MakeExternalAPI("login", func(req *http.Request) util.JSONResponse {
|
||||||
|
if r := rateLimits.Limit(req, nil); r != nil {
|
||||||
|
return *r
|
||||||
|
}
|
||||||
|
return Login(req, userAPI, cfg)
|
||||||
|
}),
|
||||||
|
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
|
v3mux.Handle("/auth/{authType}/fallback/web",
|
||||||
|
httputil.MakeHTTPAPI("auth_fallback", userVerifier, enableMetrics, func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
vars := mux.Vars(req)
|
||||||
|
AuthFallback(w, req, vars["authType"], cfg)
|
||||||
|
}),
|
||||||
|
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
|
v3mux.Handle("/logout",
|
||||||
|
httputil.MakeAuthAPI("logout", userVerifier, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
|
return Logout(req, userAPI, device)
|
||||||
|
}),
|
||||||
|
).Methods(http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
|
v3mux.Handle("/logout/all",
|
||||||
|
httputil.MakeAuthAPI("logout", userVerifier, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
|
return LogoutAll(req, userAPI, device)
|
||||||
|
}),
|
||||||
|
).Methods(http.MethodPost, http.MethodOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mscCfg.Enabled("msc2753") {
|
if mscCfg.Enabled("msc2753") {
|
||||||
|
@ -577,20 +623,6 @@ func Setup(
|
||||||
}, httputil.WithAllowGuests()),
|
}, httputil.WithAllowGuests()),
|
||||||
).Methods(http.MethodGet, http.MethodOptions)
|
).Methods(http.MethodGet, http.MethodOptions)
|
||||||
|
|
||||||
v3mux.Handle("/register", httputil.MakeExternalAPI("register", func(req *http.Request) util.JSONResponse {
|
|
||||||
if r := rateLimits.Limit(req, nil); r != nil {
|
|
||||||
return *r
|
|
||||||
}
|
|
||||||
return Register(req, userAPI, cfg)
|
|
||||||
})).Methods(http.MethodPost, http.MethodOptions)
|
|
||||||
|
|
||||||
v3mux.Handle("/register/available", httputil.MakeExternalAPI("registerAvailable", func(req *http.Request) util.JSONResponse {
|
|
||||||
if r := rateLimits.Limit(req, nil); r != nil {
|
|
||||||
return *r
|
|
||||||
}
|
|
||||||
return RegisterAvailable(req, cfg, userAPI)
|
|
||||||
})).Methods(http.MethodGet, http.MethodOptions)
|
|
||||||
|
|
||||||
v3mux.Handle("/directory/room/{roomAlias}",
|
v3mux.Handle("/directory/room/{roomAlias}",
|
||||||
httputil.MakeExternalAPI("directory_room", func(req *http.Request) util.JSONResponse {
|
httputil.MakeExternalAPI("directory_room", func(req *http.Request) util.JSONResponse {
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
|
@ -666,18 +698,6 @@ func Setup(
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
v3mux.Handle("/logout",
|
|
||||||
httputil.MakeAuthAPI("logout", userVerifier, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
|
||||||
return Logout(req, userAPI, device)
|
|
||||||
}),
|
|
||||||
).Methods(http.MethodPost, http.MethodOptions)
|
|
||||||
|
|
||||||
v3mux.Handle("/logout/all",
|
|
||||||
httputil.MakeAuthAPI("logout", userVerifier, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
|
||||||
return LogoutAll(req, userAPI, device)
|
|
||||||
}),
|
|
||||||
).Methods(http.MethodPost, http.MethodOptions)
|
|
||||||
|
|
||||||
v3mux.Handle("/rooms/{roomID}/typing/{userID}",
|
v3mux.Handle("/rooms/{roomID}/typing/{userID}",
|
||||||
httputil.MakeAuthAPI("rooms_typing", userVerifier, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
httputil.MakeAuthAPI("rooms_typing", userVerifier, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
if r := rateLimits.Limit(req, device); r != nil {
|
if r := rateLimits.Limit(req, device); r != nil {
|
||||||
|
@ -762,24 +782,6 @@ func Setup(
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodPost, http.MethodOptions)
|
).Methods(http.MethodPost, http.MethodOptions)
|
||||||
|
|
||||||
// Stub endpoints required by Element
|
|
||||||
|
|
||||||
v3mux.Handle("/login",
|
|
||||||
httputil.MakeExternalAPI("login", func(req *http.Request) util.JSONResponse {
|
|
||||||
if r := rateLimits.Limit(req, nil); r != nil {
|
|
||||||
return *r
|
|
||||||
}
|
|
||||||
return Login(req, userAPI, cfg)
|
|
||||||
}),
|
|
||||||
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
|
||||||
|
|
||||||
v3mux.Handle("/auth/{authType}/fallback/web",
|
|
||||||
httputil.MakeHTTPAPI("auth_fallback", userVerifier, enableMetrics, func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
vars := mux.Vars(req)
|
|
||||||
AuthFallback(w, req, vars["authType"], cfg)
|
|
||||||
}),
|
|
||||||
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
|
|
||||||
|
|
||||||
// Push rules
|
// Push rules
|
||||||
|
|
||||||
v3mux.Handle("/pushrules",
|
v3mux.Handle("/pushrules",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue