mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: Strip session_token cookie from app proxy requests (#3528)
Fixes coder/security#1.
This commit is contained in:
35
coderd/httpapi/cookie_test.go
Normal file
35
coderd/httpapi/cookie_test.go
Normal file
@ -0,0 +1,35 @@
|
||||
package httpapi_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/coderd/httpapi"
|
||||
)
|
||||
|
||||
func TestStripCoderCookies(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tc := range []struct {
|
||||
Input string
|
||||
Output string
|
||||
}{{
|
||||
"testing=hello; wow=test",
|
||||
"testing=hello; wow=test",
|
||||
}, {
|
||||
"session_token=moo; wow=test",
|
||||
"wow=test",
|
||||
}, {
|
||||
"another_token=wow; session_token=ok",
|
||||
"another_token=wow",
|
||||
}, {
|
||||
"session_token=ok; oauth_state=wow; oauth_redirect=/",
|
||||
"",
|
||||
}} {
|
||||
tc := tc
|
||||
t.Run(tc.Input, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
require.Equal(t, tc.Output, httpapi.StripCoderCookies(tc.Input))
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user