Documentation ¶
Index ¶
- Constants
- Variables
- func ClearSessionHeaders(w http.ResponseWriter) error
- func Dial(ctx context.Context, network, addr string) (net.Conn, error)
- func DialFromEnviron(dnsAddr string) func(ctx context.Context, network, addr string) (net.Conn, error)
- func DialWithLocalResolver(ctx context.Context, dnsAddr, network, addr string) (net.Conn, error)
- func DialWithServiceResolver(ctx context.Context, network, host, port string) (conn net.Conn, err error)
- func GRPCHandlerFunc(grpcHandler, httpHandler http.Handler) http.Handler
- func GetClient(insecure bool, options ...ClientOption) *http.Client
- func GetClusterKubeClient(dnsAddr string, options ...KubeConfigOption) (*kubernetes.Clientset, *rest.Config, error)
- func GetGRPCPlanetClient(ctx context.Context) (client.Client, error)
- func GetPlanetClient(options ...ClientOption) (*http.Client, error)
- func GetRemoteClient(remoteSite rt.RemoteSite, remoteURL *url.URL) *http.Client
- func GetUnprivilegedKubeClient(dnsAddr string, options ...KubeConfigOption) (*kubernetes.Clientset, *rest.Config, error)
- func InGravity(dnsAddress string) error
- func InKubernetes() bool
- func Message(msg string) interface{}
- func NewClient(options ...ClientOption) *http.Client
- func OK() interface{}
- func SetGrafanaHeaders(h http.Header, clusterName string, path string, expired bool)
- func SetupWebsocketClient(ctx context.Context, c *roundtrip.Client, endpoint string, localDialer Dialer) (io.ReadCloser, error)
- func VerifySameOrigin(r *http.Request) error
- func WebsocketClientForURL(URL string, headers http.Header) (*websocket.Conn, error)
- func WriteError(w http.ResponseWriter, err error, hdr http.Header)
- type Addr
- type AuthCreds
- type Authenticator
- type ClientOption
- func WithCA(cert []byte) ClientOption
- func WithClientCert(cert tls.Certificate) ClientOption
- func WithDialTimeout(t time.Duration) ClientOption
- func WithIdleConnTimeout(timeout time.Duration) ClientOption
- func WithInsecure() ClientOption
- func WithLocalResolver(dnsAddr string) ClientOption
- func WithTLSClientConfig(tlsConfig *tls.Config) ClientOption
- func WithTimeout(t time.Duration) ClientOption
- type Dialer
- type KubeConfigOption
- type WebSocketReader
Constants ¶
const ( // AuthBasic is username / password basic auth AuthBasic = "Basic" // AuthBearer is bearer tokens auth AuthBearer = "Bearer" // AccessTokenQueryParam URI query parameter AccessTokenQueryParam = "access_token" )
Variables ¶
var Methods = []string{ http.MethodOptions, http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch, http.MethodHead, }
Methods contains all HTTP methods
Functions ¶
func ClearSessionHeaders ¶
func ClearSessionHeaders(w http.ResponseWriter) error
ClearSessionHeaders removes all server side cookies
func DialFromEnviron ¶
func DialFromEnviron(dnsAddr string) func(ctx context.Context, network, addr string) (net.Conn, error)
DialFromEnviron determines if the specified address should be resolved using local resolver prior to dialing
func DialWithLocalResolver ¶
DialWithLocalResolver resolves the specified address using the local resolver before dialing. Returns a new connection on success.
func DialWithServiceResolver ¶
func DialWithServiceResolver(ctx context.Context, network, host, port string) (conn net.Conn, err error)
DialWithServiceResolver resolves the host as a kubernetes service using its cluster IP
func GRPCHandlerFunc ¶
GRPCHandlerFunc returns an http.Handler that delegates to grpcHandler on incoming gRPC connections or httpHandler otherwise
func GetClient ¶
func GetClient(insecure bool, options ...ClientOption) *http.Client
GetClient returns secure or insecure client based on settings
func GetClusterKubeClient ¶
func GetClusterKubeClient(dnsAddr string, options ...KubeConfigOption) (*kubernetes.Clientset, *rest.Config, error)
GetClusterKubeClient returns a Kubernetes client that uses scheduler certificate for authentication
func GetGRPCPlanetClient ¶
GetGRPCPlanetClient a grpc client connection to the local planet agent.
func GetPlanetClient ¶
func GetPlanetClient(options ...ClientOption) (*http.Client, error)
func GetRemoteClient ¶
GetRemoteClient returns http.Client for the remote site
func GetUnprivilegedKubeClient ¶
func GetUnprivilegedKubeClient(dnsAddr string, options ...KubeConfigOption) (*kubernetes.Clientset, *rest.Config, error)
GetUnprivilegedKubeClient returns a Kubernetes client that uses kubelet certificate for authentication
func InKubernetes ¶
func InKubernetes() bool
InKubernetes returns true if the current context is inside a Kubernetes cluster.
func NewClient ¶
func NewClient(options ...ClientOption) *http.Client
NewClient creates a new HTTP client with the specified list of configuration options
func SetGrafanaHeaders ¶
SetGrafanaHeaders adds a cookie that holds information about current cluster
func SetupWebsocketClient ¶
func SetupWebsocketClient(ctx context.Context, c *roundtrip.Client, endpoint string, localDialer Dialer) (io.ReadCloser, error)
SetupWebsocketClient sets up roundtrip client to dial web socket method
func VerifySameOrigin ¶
VerifySameOrigin checks the HTTP request header values against CSRF attacks There are two steps to check: 1. Determining where the origin the request is coming from (source origin) 2. Determining where the origin the request is going to (target origin) https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet#Verifying_Same_Origin_with_Standard_Headers
func WebsocketClientForURL ¶
WebsocketClientForURL creates a new websocket client for the specified url using provided headers
func WriteError ¶
func WriteError(w http.ResponseWriter, err error, hdr http.Header)
WriteError serializes the given error into the provided response writer. The amount of serialized information depends on the HTTP headers.
Types ¶
type AuthCreds ¶
type AuthCreds struct { // Type is auth HTTP auth type (either Bearer or Basic) Type string // Username is HTTP username Username string // Password holds password in case of Basic auth, http token otherwize Password string }
AuthCreds hold authentication credentials for the given HTTP request
func ParseAuthHeaders ¶
ParseAuthHeaders parses authentication headers from HTTP request it currently detects Bearer and Basic auth types
type Authenticator ¶
type Authenticator func(w http.ResponseWriter, r *http.Request, checkBearerToken bool) (*teleweb.SessionContext, error)
type ClientOption ¶
type ClientOption func(*httpClient)
ClientOption sets custom HTTP client option
func WithCA ¶
func WithCA(cert []byte) ClientOption
WithCA to use a custom certificate authority for server validation
func WithClientCert ¶
func WithClientCert(cert tls.Certificate) ClientOption
WithClientCert sets a certificate for mTLS client authentication
func WithDialTimeout ¶
func WithDialTimeout(t time.Duration) ClientOption
WithDialTimeout sets dial timeout
func WithIdleConnTimeout ¶
func WithIdleConnTimeout(timeout time.Duration) ClientOption
WithIdleConnTimeout overrides the transport connection idle timeout
func WithLocalResolver ¶
func WithLocalResolver(dnsAddr string) ClientOption
WithLocalResolver sets up client to use local DNS resolver
func WithTLSClientConfig ¶
func WithTLSClientConfig(tlsConfig *tls.Config) ClientOption
WithTLSClientConfig sets TLS client configuration.
type Dialer ¶
func LocalResolverDialer ¶
LocalResolverDialer returns Dialer that uses the specified DNS server
type KubeConfigOption ¶
KubeConfigOption represents a functional argument type that allows to modify Kubernetes client configuration before creating it.
func WithHost ¶
func WithHost(host string) KubeConfigOption
WithHost sets host in the Kubernetes client config.
type WebSocketReader ¶
type WebSocketReader struct {
Reader io.ReadCloser
}
WebSocketReader is a web socket handler, ignores all input and streams everything it read from reader to the web socket connection
func (*WebSocketReader) Close ¶
func (w *WebSocketReader) Close() error
func (*WebSocketReader) Handler ¶
func (w *WebSocketReader) Handler() http.Handler