utils

package
v0.0.0-...-c116fac Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyHeader

func CopyHeader(dst, src http.Header)

Copy headers from proxied src to dst, removing those defined by HTTP as "hop-by-hop" and not to be forwarded (see https://www.rfc-editor.org/rfc/rfc9110#field.connection)

func GetJwks

func GetJwks(ctx context.Context, location string) (jwk.Set, error)

func HeaderParser

func HeaderParser(values string) (retMap map[string]string)

Simple parser to that takes a "values" string from a header and turns it into a map of key/value pairs

func LaunchPeriodicWriteCABundle

func LaunchPeriodicWriteCABundle(ctx context.Context, filename string, sleepTime time.Duration) (count int, err error)

Periodically write out the system CAs, updating them if the system updates. Returns an error if the first attempt at writing fails. Otherwise, it will launch a goroutine and update the entire CA bundle every specified duration.

If we're on a platform (Mac, Windows) that does not provide a CA bundle, we return a count of 0 and do not launch the go routine.

func MakeRequest

func MakeRequest(ctx context.Context, url string, method string, data map[string]interface{}, headers map[string]string) ([]byte, error)

MakeRequest makes an http request with our custom http client. It acts similarly to the http.NewRequest but it only takes json as the request data.

func SnakeCaseToCamelCase

func SnakeCaseToCamelCase(input string) string

snakeCaseToCamelCase converts a snake case string to camel case.

func SnakeCaseToHumanReadable

func SnakeCaseToHumanReadable(input string) string

snakeCaseToSnakeCase converts a snake_case string to Snake Case (CamelCase with spaces).

func WriteCABundle

func WriteCABundle(filename string) (int, error)

Write out all the trusted CAs as a CA bundle on disk. This is useful for components that do not use go's trusted CA store

Types

type CredentialGeneration

type CredentialGeneration struct {
	BasePath      string `json:"base_path"`
	Issuer        string `json:"issuer"`
	MaxScopeDepth int    `json:"max_scope_depth"`
	Strategy      string `json:"strategy"`
	VaultIssuer   string `json:"vault_issuer"`
	VaultServer   string `json:"vault_server"`
}

type Namespace

type Namespace struct {
	Caches               []Server             `json:"caches"`
	Origins              []Server             `json:"origins"`
	CredentialGeneration CredentialGeneration `json:"credential_generation"`
	DirlistHost          string               `json:"dirlisthost"`
	Path                 string               `json:"path"`
	ReadHTTPS            bool                 `json:"readhttps"`
	Scitokens            []Scitokens          `json:"scitokens"`
	UseTokenOnRead       bool                 `json:"usetokenonread"`
	WritebackHost        string               `json:"writebackhost"`
}

type Scitokens

type Scitokens struct {
	BasePath   []string `json:"base_path"`
	Issuer     string   `json:"issuer"`
	Restricted []string `json:"restricted_path"`
}

type Server

type Server struct {
	AuthEndpoint string `json:"auth_endpoint"`
	Endpoint     string `json:"endpoint"`
	Resource     string `json:"resource"`
}

type TopologyNamespacesJSON

type TopologyNamespacesJSON struct {
	Caches     []Server    `json:"caches"`
	Namespaces []Namespace `json:"namespaces"`
}

func GetTopologyJSON

func GetTopologyJSON() (*TopologyNamespacesJSON, error)

GetTopologyJSON returns the namespaces and caches from OSDF topology

Jump to

Keyboard shortcuts

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