added /v2 auth info

This commit is contained in:
2026-03-17 10:23:01 +02:00
parent 791e04cdf1
commit 97904e0529
2 changed files with 36 additions and 35 deletions
+10 -9
View File
@@ -10,7 +10,7 @@
package handler package handler
import ( import (
//"net/http" "net/http"
"mstore/app/imageoper" "mstore/app/imageoper"
"mstore/app/router" "mstore/app/router"
@@ -21,14 +21,15 @@ func (hand *Handler) GetVersion(rctx *router.Context) {
params := &imageoper.GetVersionParams{} params := &imageoper.GetVersionParams{}
//hand.DumpHeaders("GetVersion", rctx) //hand.DumpHeaders("GetVersion", rctx)
/*
authorization := rctx.GetHeader("Authorization") authorization := rctx.GetHeader("Authorization")
if authorization == "" { if authorization == "" {
rctx.SetHeader("WWW-Authenticate", `Basic realm="mstore"`) rctx.SetHeader("WWW-Authenticate", `Basic realm="mstore"`)
rctx.SetStatus(http.StatusUnauthorized) //rctx.SetStatus(http.StatusUnauthorized)
return rctx.SetStatus(http.StatusOK)
} return
*/ }
ctx := rctx.GetContext() ctx := rctx.GetContext()
_, code, err := hand.imop.GetVersion(ctx, params) _, code, err := hand.imop.GetVersion(ctx, params)
if err != nil { if err != nil {
+26 -26
View File
@@ -63,32 +63,32 @@ func (oper *Operator) ManifestExists(ctx context.Context, params *ManifestExists
res.Exists = exist res.Exists = exist
} else { } else {
/* /*
// Create index of manifests // Create index of manifests
exists, manDescrs, err := oper.mdb.GetManifestsByReference(ctx, params.Name, params.Reference) exists, manDescrs, err := oper.mdb.GetManifestsByReference(ctx, params.Name, params.Reference)
if err != nil { if err != nil {
return res, http.StatusInternalServerError, err return res, http.StatusInternalServerError, err
} }
if !exists { if !exists {
return res, http.StatusNotFound, err return res, http.StatusNotFound, err
} }
if len(manDescrs) == 1 { if len(manDescrs) == 1 {
manDescr := manDescrs[0] manDescr := manDescrs[0]
res.DockerContentDigest = manDescr.Digest res.DockerContentDigest = manDescr.Digest
size := int64(len(manDescr.Payload)) size := int64(len(manDescr.Payload))
res.ContentLength = strconv.FormatInt(size, 10) res.ContentLength = strconv.FormatInt(size, 10)
res.ContentType = manDescr.ContentType res.ContentType = manDescr.ContentType
} else { } else {
_, indexdata, err := indexFromManigestDescrs(manDescrs) _, indexdata, err := indexFromManigestDescrs(manDescrs)
if err != nil { if err != nil {
return res, http.StatusInternalServerError, err return res, http.StatusInternalServerError, err
} }
digobj := ocidigest.FromBytes(indexdata) digobj := ocidigest.FromBytes(indexdata)
res.DockerContentDigest = digobj.String() res.DockerContentDigest = digobj.String()
size := int64(len(indexdata)) size := int64(len(indexdata))
res.ContentLength = strconv.FormatInt(size, 10) res.ContentLength = strconv.FormatInt(size, 10)
res.ContentType = oiiMediaType res.ContentType = oiiMediaType
res.Exists = true res.Exists = true
} }
*/ */
exists, manDescr, err := oper.mdb.GetManifestByReference(ctx, params.Name, params.Reference) exists, manDescr, err := oper.mdb.GetManifestByReference(ctx, params.Name, params.Reference)
if err != nil { if err != nil {