registryproxy

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxPath ctxKey = 0
)

context keys

Variables

View Source
var (
	ErrUpstreamCouldNotParseHost = errors.New("could not parse upstream host")
)

These are the errors returned by this file of the pkg

Functions

func Authenticate

func Authenticate(opts *ProxyOpts, res http.ResponseWriter, req *http.Request)

Authenticate handles authentication

func GetFullRepositoryFromPath

func GetFullRepositoryFromPath(path string, base string) string

GetFullRepositoryFromPath returns the upstream Docker registry repository

func GetImageFromPath

func GetImageFromPath(path string) string

GetImageFromPath returns the Docker image

func GetPathWithBase

func GetPathWithBase(path, base string) string

GetPathWithBase returns the path to send to the upstream registry

func GetRepositoryFromPath

func GetRepositoryFromPath(path string) string

GetRepositoryFromPath returns the Docker registry repository

func GetRepositoryFromScope

func GetRepositoryFromScope(scope string) string

GetRepositoryFromScope returns the repository from a scope

func GetScope

func GetScope(req *http.Request, upstreamPath string) string

GetScope returns the requested scope

func MakeBasicAuth

func MakeBasicAuth(username string, password string) string

MakeBasicAuth returns a basic auth string from a ProvideResponse

func NewProxy

func NewProxy(req *http.Request, opts *ProxyOpts) (*httputil.ReverseProxy, error)

NewProxy returns a httputil.ReverseProxy for a request. This proxy should be used for subsequent requests of the same session.

func NewRedirectFollower

func NewRedirectFollower(wrappedRoundTripper http.RoundTripper) http.RoundTripper

NewRedirectFollower wraps another http.RoundTripper following redirect response codes

func ProxyHandler

func ProxyHandler(opts *ProxyOpts) func(http.ResponseWriter, *http.Request)

ProxyHandler returns a http.HandlerFunc

func RegistryAuthResolveGRPC

RegistryAuthResolveGRPC resolves the registry authentication from via GRPC

func UnauthenticatedResponse

func UnauthenticatedResponse(res http.ResponseWriter, req *http.Request, upstreamPath string)

UnauthenticatedResponse writes the unauthenticated response

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	DockerRepository string `json:"dockerRepository"`
}

Claims represents the claims for the generated token

func GetAuthentication

func GetAuthentication(req *http.Request) *Claims

GetAuthentication returns the authentication for a request

func (Claims) Valid

func (c Claims) Valid() error

Valid returns whether or not the claims are valid

type ProxyOpts

type ProxyOpts struct {
	Upstream *url.URL

	Registry  name.Registry
	Auth      authn.Authenticator
	Transport http.RoundTripper

	AuthVerifiers map[string]dockerregistryproxyv1.AuthenticationVerifierAPIClient

	TokenHMAC []byte
}

ProxyOpts represents the options available for the ProxyHandler

func GetProxyOpts

func GetProxyOpts(
	upstreamAddr string,
	upstreamAuthClient dockerregistryproxyv1.AuthenticationProviderAPIClient,
	authVerifiers map[string]dockerregistryproxyv1.AuthenticationVerifierAPIClient,
) (*ProxyOpts, error)

GetProxyOpts validates and returns the given proxy handler options

type RedirectFollower

type RedirectFollower struct {
	http.RoundTripper
}

RedirectFollower represents a Transport RoundTripper that follows redirects

func (*RedirectFollower) RoundTrip

func (t *RedirectFollower) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper

Jump to

Keyboard shortcuts

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