Allow empty SSO redirectUrl paths.

E.g. "https://hydrogen.element.io"
This commit is contained in:
Tommie Gannert 2022-10-04 12:19:32 +02:00
parent 1c17c20097
commit 808eb2279b
2 changed files with 16 additions and 1 deletions

View file

@ -63,7 +63,7 @@ func SSORedirect(
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidArgumentValue("Invalid redirectURL: " + err.Error()),
}
} else if ru.Scheme == "" || ru.Host == "" || ru.Path == "" {
} else if ru.Scheme == "" || ru.Host == "" {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidArgumentValue("Invalid redirectURL: " + redirectURL),

View file

@ -78,6 +78,21 @@ func TestSSORedirect(t *testing.T) {
WantLocationRE: `http://auth.example.com/authorize\?callbackURL=http.*%3Fprovider%3Dsomeprovider&nonce=.+&providerID=someprovider`,
WantSetCookieRE: "sso_nonce=[^;].*Path=/_matrix/v4/login/sso",
},
{
Name: "redirectEmptyredirectPath",
Req: http.Request{
Host: "matrix.example.com",
URL: &url.URL{
Path: "/_matrix/v4/login/sso/redirect",
RawQuery: url.Values{
"redirectUrl": []string{"http://example.com"},
}.Encode(),
},
},
IDPID: "someprovider",
WantLocationRE: `http://auth.example.com/authorize\?callbackURL=http.*%3Fprovider%3Dsomeprovider&nonce=.+&providerID=someprovider`,
WantSetCookieRE: "sso_nonce=[^;].*Path=/_matrix/v4/login/sso",
},
}
for _, tst := range tsts {
t.Run(tst.Name, func(t *testing.T) {