api

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package ldap provides a simple ldap client to authenticate, retrieve basic information and groups for a user.

Index

Constants

View Source
const (
	// actions.
	CREATE = "create"
	READ   = "read"
	UPDATE = "update"
	DELETE = "delete"
)
View Source
const (
	RoutePrefix          = "/v2"
	DistAPIVersion       = "Docker-Distribution-API-Version"
	DistContentDigestKey = "Docker-Content-Digest"
	BlobUploadUUID       = "Blob-Upload-UUID"
	DefaultMediaType     = "application/json"
	BinaryMediaType      = "application/octet-stream"
)

Variables

View Source
var (

	// NameRegexp is the format for the name component of references. The
	// regexp has capturing groups for the domain and name part omitting
	// the separating forward slash from either.
	NameRegexp = expression(
		nameComponentRegexp,
		optional(repeated(literal(`/`), nameComponentRegexp)))
)

nolint: gochecknoglobals

Functions

func AuthHandler added in v1.0.1

func AuthHandler(c *Controller) mux.MiddlewareFunc

func AuthzHandler added in v1.3.0

func AuthzHandler(c *Controller) mux.MiddlewareFunc

func DefaultHeaders added in v1.2.0

func DefaultHeaders() mux.MiddlewareFunc

func SessionAuditLogger added in v1.3.2

func SessionAuditLogger(audit *log.Logger) mux.MiddlewareFunc

func SessionLogger added in v1.3.2

func SessionLogger(c *Controller) mux.MiddlewareFunc

SessionLogger logs session details.

func WriteData added in v0.2.7

func WriteData(w http.ResponseWriter, status int, mediaType string, data []byte)

func WriteDataFromReader added in v0.2.7

func WriteDataFromReader(w http.ResponseWriter, status int, length int64, mediaType string,
	reader io.Reader, logger log.Logger)

func WriteJSON added in v0.2.7

func WriteJSON(w http.ResponseWriter, status int, data interface{})

Types

type AccessControlContext added in v1.3.0

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

AccessControlContext context passed down to http.Handlers.

type AccessController added in v1.3.0

type AccessController struct {
	Config *config.AccessControlConfig
	Log    log.Logger
}

AccessController authorizes users to act on resources.

func NewAccessController added in v1.3.0

func NewAccessController(config *config.Config) *AccessController

type Controller

type Controller struct {
	Config          *config.Config
	Router          *mux.Router
	StoreController storage.StoreController
	Log             log.Logger
	Audit           *log.Logger
	Server          *http.Server
	Metrics         monitoring.MetricServer
}

func NewController

func NewController(config *config.Config) *Controller

func (*Controller) Run

func (c *Controller) Run() error

nolint: gocyclo

type Error

type Error struct {
	Code        string      `json:"code"`
	Message     string      `json:"message"`
	Description string      `json:"description"`
	Detail      interface{} `json:"detail,omitempty"`
}

func NewError

func NewError(code ErrorCode, detail ...interface{}) Error

type ErrorCode

type ErrorCode int
const (
	BLOB_UNKNOWN ErrorCode = iota
	BLOB_UPLOAD_INVALID
	BLOB_UPLOAD_UNKNOWN
	DIGEST_INVALID
	MANIFEST_BLOB_UNKNOWN
	MANIFEST_INVALID
	MANIFEST_UNKNOWN
	MANIFEST_UNVERIFIED
	NAME_INVALID
	NAME_UNKNOWN
	SIZE_INVALID
	TAG_INVALID
	UNAUTHORIZED
	DENIED
	UNSUPPORTED
)

nolint: golint, stylecheck

func (ErrorCode) String added in v1.0.1

func (e ErrorCode) String() string

type ErrorList

type ErrorList struct {
	Errors []*Error `json:"errors"`
}

func NewErrorList added in v1.0.1

func NewErrorList(errors ...Error) ErrorList

type ImageManifest

type ImageManifest struct {
	ispec.Manifest
}

NOTE: https://github.com/swaggo/swag/issues/387.

type ImageTags

type ImageTags struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

type LDAPClient added in v0.3.0

type LDAPClient struct {
	InsecureSkipVerify bool
	UseSSL             bool
	SkipTLS            bool
	SubtreeSearch      bool
	Port               int
	Attributes         []string
	Base               string
	BindDN             string
	BindPassword       string
	GroupFilter        string // e.g. "(memberUid=%s)"
	Host               string
	ServerName         string
	UserFilter         string // e.g. "(uid=%s)"
	Conn               *ldap.Conn
	ClientCertificates []tls.Certificate // Adding client certificates
	ClientCAs          *x509.CertPool
	Log                log.Logger
	// contains filtered or unexported fields
}

func (*LDAPClient) Authenticate added in v0.3.0

func (lc *LDAPClient) Authenticate(username, password string) (bool, map[string]string, error)

Authenticate authenticates the user against the ldap backend.

func (*LDAPClient) Close added in v0.3.8

func (lc *LDAPClient) Close()

Close closes the ldap backend connection.

func (*LDAPClient) Connect added in v0.3.0

func (lc *LDAPClient) Connect() error

Connect connects to the ldap backend.

type ReferenceList added in v1.3.4

type ReferenceList struct {
	References []notation.Descriptor `json:"references"`
}

type RepositoryList

type RepositoryList struct {
	Repositories []string `json:"repositories"`
}

type RouteHandler

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

func NewRouteHandler

func NewRouteHandler(c *Controller) *RouteHandler

func (*RouteHandler) CheckBlob

func (rh *RouteHandler) CheckBlob(w http.ResponseWriter, r *http.Request)

CheckBlob godoc @Summary Check image blob/layer @Description Check an image's blob/layer given a digest @Accept json @Produce json @Param name path string true "repository name" @Param digest path string true "blob/layer digest" @Success 200 {object} api.ImageManifest @Header 200 {object} api.DistContentDigestKey @Router /v2/{name}/blobs/{digest} [head].

func (*RouteHandler) CheckManifest

func (rh *RouteHandler) CheckManifest(w http.ResponseWriter, r *http.Request)

CheckManifest godoc @Summary Check image manifest @Description Check an image's manifest given a reference or a digest @Router /v2/{name}/manifests/{reference} [head] @Accept json @Produce json @Param name path string true "repository name" @Param reference path string true "image reference or digest" @Success 200 {string} string "ok" @Header 200 {object} api.DistContentDigestKey @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error".

func (*RouteHandler) CheckVersionSupport

func (rh *RouteHandler) CheckVersionSupport(w http.ResponseWriter, r *http.Request)

CheckVersionSupport godoc @Summary Check API support @Description Check if this API version is supported @Router /v2/ [get] @Accept json @Produce json @Success 200 {string} string "ok".

func (*RouteHandler) CreateBlobUpload

func (rh *RouteHandler) CreateBlobUpload(w http.ResponseWriter, r *http.Request)

CreateBlobUpload godoc @Summary Create image blob/layer upload @Description Create a new image blob/layer upload @Accept json @Produce json @Param name path string true "repository name" @Success 202 {string} string "accepted" @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}" @Header 202 {string} Range "bytes=0-0" @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error" @Router /v2/{name}/blobs/uploads [post].

func (*RouteHandler) DeleteBlob

func (rh *RouteHandler) DeleteBlob(w http.ResponseWriter, r *http.Request)

DeleteBlob godoc @Summary Delete image blob/layer @Description Delete an image's blob/layer given a digest @Accept json @Produce json @Param name path string true "repository name" @Param digest path string true "blob/layer digest" @Success 202 {string} string "accepted" @Router /v2/{name}/blobs/{digest} [delete].

func (*RouteHandler) DeleteBlobUpload

func (rh *RouteHandler) DeleteBlobUpload(w http.ResponseWriter, r *http.Request)

DeleteBlobUpload godoc @Summary Delete image blob/layer @Description Delete an image's blob/layer given a digest @Accept json @Produce json @Param name path string true "repository name" @Param session_id path string true "upload session_id" @Success 200 {string} string "ok" @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error" @Router /v2/{name}/blobs/uploads/{session_id} [delete].

func (*RouteHandler) DeleteManifest

func (rh *RouteHandler) DeleteManifest(w http.ResponseWriter, r *http.Request)

DeleteManifest godoc @Summary Delete image manifest @Description Delete an image's manifest given a reference or a digest @Accept json @Produce json @Param name path string true "repository name" @Param reference path string true "image reference or digest" @Success 200 {string} string "ok" @Router /v2/{name}/manifests/{reference} [delete].

func (*RouteHandler) GetBlob

func (rh *RouteHandler) GetBlob(w http.ResponseWriter, r *http.Request)

GetBlob godoc @Summary Get image blob/layer @Description Get an image's blob/layer given a digest @Accept json @Produce application/vnd.oci.image.layer.v1.tar+gzip @Param name path string true "repository name" @Param digest path string true "blob/layer digest" @Header 200 {object} api.DistContentDigestKey @Success 200 {object} api.ImageManifest @Router /v2/{name}/blobs/{digest} [get].

func (*RouteHandler) GetBlobUpload

func (rh *RouteHandler) GetBlobUpload(w http.ResponseWriter, r *http.Request)

GetBlobUpload godoc @Summary Get image blob/layer upload @Description Get an image's blob/layer upload given a session_id @Accept json @Produce json @Param name path string true "repository name" @Param session_id path string true "upload session_id" @Success 204 {string} string "no content" @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}" @Header 202 {string} Range "bytes=0-128" @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error" @Router /v2/{name}/blobs/uploads/{session_id} [get].

func (*RouteHandler) GetManifest

func (rh *RouteHandler) GetManifest(w http.ResponseWriter, r *http.Request)

GetManifest godoc @Summary Get image manifest @Description Get an image's manifest given a reference or a digest @Accept json @Produce application/vnd.oci.image.manifest.v1+json @Param name path string true "repository name" @Param reference path string true "image reference or digest" @Success 200 {object} api.ImageManifest @Header 200 {object} api.DistContentDigestKey @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error" @Router /v2/{name}/manifests/{reference} [get].

func (*RouteHandler) GetMetrics added in v1.3.2

func (rh *RouteHandler) GetMetrics(w http.ResponseWriter, r *http.Request)

func (*RouteHandler) GetReferrers added in v1.3.4

func (rh *RouteHandler) GetReferrers(w http.ResponseWriter, r *http.Request)

GetReferrers godoc @Summary Get references for an image @Description Get references for an image given a digest and artifact type @Accept json @Produce json @Param name path string true "repository name" @Param digest path string true "image digest" @Param artifactType query string true "artifact type" @Success 200 {string} string "ok" @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error" @Router /oras/artifacts/v1/{name:%s}/manifests/{digest}/referrers [get].

func (*RouteHandler) ListRepositories

func (rh *RouteHandler) ListRepositories(w http.ResponseWriter, r *http.Request)

ListRepositories godoc @Summary List image repositories @Description List all image repositories @Accept json @Produce json @Success 200 {object} api.RepositoryList @Failure 500 {string} string "internal server error" @Router /v2/_catalog [get].

func (*RouteHandler) ListTags

func (rh *RouteHandler) ListTags(w http.ResponseWriter, r *http.Request)

ListTags godoc @Summary List image tags @Description List all image tags in a repository @Router /v2/{name}/tags/list [get] @Accept json @Produce json @Param name path string true "test" @Param n query integer true "limit entries for pagination" @Param last query string true "last tag value for pagination" @Success 200 {object} api.ImageTags @Failure 404 {string} string "not found" @Failure 400 {string} string "bad request".

func (*RouteHandler) PatchBlobUpload

func (rh *RouteHandler) PatchBlobUpload(w http.ResponseWriter, r *http.Request)

PatchBlobUpload godoc @Summary Resume image blob/layer upload @Description Resume an image's blob/layer upload given an session_id @Accept json @Produce json @Param name path string true "repository name" @Param session_id path string true "upload session_id" @Success 202 {string} string "accepted" @Header 202 {string} Location "/v2/{name}/blobs/uploads/{session_id}" @Header 202 {string} Range "bytes=0-128" @Header 200 {object} api.BlobUploadUUID @Failure 400 {string} string "bad request" @Failure 404 {string} string "not found" @Failure 416 {string} string "range not satisfiable" @Failure 500 {string} string "internal server error" @Router /v2/{name}/blobs/uploads/{session_id} [patch].

func (*RouteHandler) SetupRoutes

func (rh *RouteHandler) SetupRoutes()

func (*RouteHandler) UpdateBlobUpload

func (rh *RouteHandler) UpdateBlobUpload(w http.ResponseWriter, r *http.Request)

UpdateBlobUpload godoc @Summary Update image blob/layer upload @Description Update and finish an image's blob/layer upload given a digest @Accept json @Produce json @Param name path string true "repository name" @Param session_id path string true "upload session_id" @Param digest query string true "blob/layer digest" @Success 201 {string} string "created" @Header 202 {string} Location "/v2/{name}/blobs/uploads/{digest}" @Header 200 {object} api.DistContentDigestKey @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error" @Router /v2/{name}/blobs/uploads/{session_id} [put].

func (*RouteHandler) UpdateManifest

func (rh *RouteHandler) UpdateManifest(w http.ResponseWriter, r *http.Request)

UpdateManifest godoc @Summary Update image manifest @Description Update an image's manifest given a reference or a digest @Accept json @Produce json @Param name path string true "repository name" @Param reference path string true "image reference or digest" @Header 201 {object} api.DistContentDigestKey @Success 201 {string} string "created" @Failure 400 {string} string "bad request" @Failure 404 {string} string "not found" @Failure 500 {string} string "internal server error" @Router /v2/{name}/manifests/{reference} [put].

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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