mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-01 16:01:26 +02:00
proxy: restrict programmatic URLs to localhost (#2047)
Co-authored-by: Caleb Doxsey <cdoxsey@pomerium.com>
This commit is contained in:
parent
ec60fcd32f
commit
fff798d0e0
14 changed files with 802 additions and 107 deletions
|
@ -305,11 +305,48 @@ func TestProxy_ProgrammaticLogin(t *testing.T) {
|
|||
wantStatus int
|
||||
wantBody string
|
||||
}{
|
||||
{"good body not checked", opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil, map[string]string{urlutil.QueryRedirectURI: "http://localhost"}, http.StatusOK, ""},
|
||||
{"good body not checked", opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil, map[string]string{urlutil.QueryRedirectURI: "http://localhost"}, http.StatusOK, ""},
|
||||
{"router miss, bad redirect_uri query", opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil, map[string]string{"bad_redirect_uri": "http://localhost"}, http.StatusNotFound, ""},
|
||||
{"bad redirect_uri missing scheme", opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil, map[string]string{urlutil.QueryRedirectURI: "localhost"}, http.StatusBadRequest, "{\"Status\":400,\"Error\":\"Bad Request: localhost url does contain a valid scheme\"}\n"},
|
||||
{"bad http method", opts, http.MethodPost, "https", "corp.example.example", "/.pomerium/api/v1/login", nil, map[string]string{urlutil.QueryRedirectURI: "http://localhost"}, http.StatusMethodNotAllowed, ""},
|
||||
{
|
||||
"good body not checked",
|
||||
opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil,
|
||||
map[string]string{urlutil.QueryRedirectURI: "http://localhost"},
|
||||
http.StatusOK,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"good body not checked",
|
||||
opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil,
|
||||
map[string]string{urlutil.QueryRedirectURI: "http://localhost"},
|
||||
http.StatusOK,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"router miss, bad redirect_uri query",
|
||||
opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil,
|
||||
map[string]string{"bad_redirect_uri": "http://localhost"},
|
||||
http.StatusNotFound,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"bad redirect_uri missing scheme",
|
||||
opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil,
|
||||
map[string]string{urlutil.QueryRedirectURI: "localhost"},
|
||||
http.StatusBadRequest,
|
||||
"{\"Status\":400,\"Error\":\"Bad Request: localhost url does contain a valid scheme\"}\n",
|
||||
},
|
||||
{
|
||||
"bad redirect_uri not whitelisted",
|
||||
opts, http.MethodGet, "https", "corp.example.example", "/.pomerium/api/v1/login", nil,
|
||||
map[string]string{urlutil.QueryRedirectURI: "https://example.com"},
|
||||
http.StatusBadRequest,
|
||||
"{\"Status\":400,\"Error\":\"Bad Request: invalid redirect uri\"}\n",
|
||||
},
|
||||
{
|
||||
"bad http method",
|
||||
opts, http.MethodPost, "https", "corp.example.example", "/.pomerium/api/v1/login", nil,
|
||||
map[string]string{urlutil.QueryRedirectURI: "http://localhost"},
|
||||
http.StatusMethodNotAllowed,
|
||||
"",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue