remenv

package
v1.19.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderAPIKey        = "X-API-Key"            // #nosec G101: header name, not a credential
	HeaderAgentToken    = "X-Arcane-Agent-Token" // #nosec G101: header name, not a credential
	HeaderAuthorization = "Authorization"
)

Variables

This section is empty.

Functions

func ApplyAgentTokenHeaderMap

func ApplyAgentTokenHeaderMap(headers map[string]string, accessToken *string)

ApplyAgentTokenHeaderMap mirrors ApplyAgentTokenHeaders for map-based header carriers. Same rationale: do not write Authorization here.

func ApplyAgentTokenHeaders

func ApplyAgentTokenHeaders(headers http.Header, accessToken *string)

ApplyAgentTokenHeaders sets the agent token in both X- header forms on the given http.Header. It deliberately does NOT set the Authorization header: these helpers are used by the manager when proxying user requests through to remote environments, and the Authorization header in that case carries the calling user's bearer or session token. Direct agent->manager call sites (poll, websocket dial, grpc dial, mTLS enroll) set `Authorization: Bearer <token>` themselves so the token survives reverse proxies that strip non-standard X- headers.

func ExtractBearerToken

func ExtractBearerToken(headerValue string) string

ExtractBearerToken returns the token portion of an "Authorization: Bearer <token>" header value. It is case-insensitive on the scheme and trims surrounding whitespace. Returns an empty string if the header is empty or does not use the Bearer scheme.

func RedactedTokenFingerprint

func RedactedTokenFingerprint(token string) string

RedactedTokenFingerprint returns a short, redacted identifier for a token suitable for debug logs. It is intentionally not reversible and never reveals the full secret.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client, tunnel TunnelTransport) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req Request) (*Response, error)

func (*Client) DoJSON

func (c *Client) DoJSON(ctx context.Context, req Request, out any) error

type DecodeError

type DecodeError struct {
	Err error
}

func (*DecodeError) Error

func (e *DecodeError) Error() string

func (*DecodeError) Unwrap

func (e *DecodeError) Unwrap() error

type Request

type Request struct {
	EnvironmentID string
	IsEdge        bool
	Method        string
	URL           string
	Path          string
	Headers       map[string]string
	Body          []byte
}

type Response

type Response struct {
	StatusCode int
	Body       []byte
	Headers    map[string]string
}

func (*Response) DecodeJSON

func (r *Response) DecodeJSON(out any) error

func (*Response) RequireSuccess

func (r *Response) RequireSuccess() error

type StatusError

type StatusError struct {
	StatusCode int
	Body       []byte
}

func (*StatusError) Error

func (e *StatusError) Error() string

type TransportError

type TransportError struct {
	Err error
}

func (*TransportError) Error

func (e *TransportError) Error() string

func (*TransportError) Unwrap

func (e *TransportError) Unwrap() error

type TunnelTransport

type TunnelTransport interface {
	EnsureAvailable(ctx context.Context, envID string) error
	Do(ctx context.Context, envID, method, path string, headers map[string]string, body []byte) (*Response, error)
}

type TunnelTransportFuncs

type TunnelTransportFuncs struct {
	EnsureAvailableFunc func(ctx context.Context, envID string) error
	DoFunc              func(ctx context.Context, envID, method, path string, headers map[string]string, body []byte) (*Response, error)
}

func (TunnelTransportFuncs) Do

func (t TunnelTransportFuncs) Do(ctx context.Context, envID, method, path string, headers map[string]string, body []byte) (*Response, error)

func (TunnelTransportFuncs) EnsureAvailable

func (t TunnelTransportFuncs) EnsureAvailable(ctx context.Context, envID string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL