mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
* chore: rename `AgentConn` to `WorkspaceAgentConn` The codersdk was becoming bloated with consts for the workspace agent that made no sense to a reader. `Tailnet*` is an example of these consts. * chore: remove `Get` prefix from *Client functions * chore: remove `BypassRatelimits` option in `codersdk.Client` It feels wrong to have this as a direct option because it's so infrequently needed by API callers. It's better to directly modify headers in the two places that we actually use it. * Merge `appearance.go` and `buildinfo.go` into `deployment.go` * Merge `experiments.go` and `features.go` into `deployment.go` * Fix `make gen` referencing old type names * Merge `error.go` into `client.go` `codersdk.Response` lived in `error.go`, which is wrong. * chore: refactor workspace agent functions into agentsdk It was odd conflating the codersdk that clients should use with functions that only the agent should use. This separates them into two SDKs that are closely coupled, but separate. * Merge `insights.go` into `deployment.go` * Merge `organizationmember.go` into `organizations.go` * Merge `quota.go` into `workspaces.go` * Rename `sse.go` to `serversentevents.go` * Rename `codersdk.WorkspaceAppHostResponse` to `codersdk.AppHostResponse` * Format `.vscode/settings.json` * Fix outdated naming in `api.ts` * Fix app host response * Fix unsupported type * Fix imported type
32 lines
727 B
Go
32 lines
727 B
Go
package httpapi
|
|
|
|
import (
|
|
"net/textproto"
|
|
"strings"
|
|
|
|
"github.com/coder/coder/codersdk"
|
|
)
|
|
|
|
// StripCoderCookies removes the session token from the cookie header provided.
|
|
func StripCoderCookies(header string) string {
|
|
header = textproto.TrimString(header)
|
|
cookies := []string{}
|
|
|
|
var part string
|
|
for len(header) > 0 { // continue since we have rest
|
|
part, header, _ = strings.Cut(header, ";")
|
|
part = textproto.TrimString(part)
|
|
if part == "" {
|
|
continue
|
|
}
|
|
name, _, _ := strings.Cut(part, "=")
|
|
if name == codersdk.SessionTokenCookie ||
|
|
name == codersdk.OAuth2StateCookie ||
|
|
name == codersdk.OAuth2RedirectCookie {
|
|
continue
|
|
}
|
|
cookies = append(cookies, part)
|
|
}
|
|
return strings.Join(cookies, "; ")
|
|
}
|