mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: limit OAuth redirects to local paths (#14585)
- This prevents a malicious user from crafting a redirect URL to a nefarious site under their control.
This commit is contained in:
@ -1143,7 +1143,7 @@ func MustWorkspace(t testing.TB, client *codersdk.Client, workspaceID uuid.UUID)
|
||||
|
||||
// RequestExternalAuthCallback makes a request with the proper OAuth2 state cookie
|
||||
// to the external auth callback endpoint.
|
||||
func RequestExternalAuthCallback(t testing.TB, providerID string, client *codersdk.Client) *http.Response {
|
||||
func RequestExternalAuthCallback(t testing.TB, providerID string, client *codersdk.Client, opts ...func(*http.Request)) *http.Response {
|
||||
client.HTTPClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
@ -1160,6 +1160,9 @@ func RequestExternalAuthCallback(t testing.TB, providerID string, client *coders
|
||||
Name: codersdk.SessionTokenCookie,
|
||||
Value: client.SessionToken(),
|
||||
})
|
||||
for _, opt := range opts {
|
||||
opt(req)
|
||||
}
|
||||
res, err := client.HTTPClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
Reference in New Issue
Block a user