working commit
This commit is contained in:
@@ -14,10 +14,10 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/auxhttp"
|
||||
"mstore/pkg/auxpwd"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -53,7 +53,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, string, error) {
|
||||
var password string
|
||||
var accountID string
|
||||
|
||||
accountID = descr.AnonymousID
|
||||
accountID = terms.AnonymousID
|
||||
|
||||
authHeader := rctx.GetHeader("Authorization")
|
||||
if authHeader != "" {
|
||||
@@ -80,7 +80,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, string, error) {
|
||||
}
|
||||
anonymous:
|
||||
success = true
|
||||
accountID = descr.AnonymousID
|
||||
accountID = terms.AnonymousID
|
||||
return success, accountID, err
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID, reqRight, subjec
|
||||
return res, err
|
||||
}
|
||||
switch reqRight {
|
||||
case descr.RightReadFiles, descr.RightWriteFiles:
|
||||
case terms.RightReadFiles, terms.RightWriteFiles:
|
||||
for _, grant := range grants {
|
||||
re, err := regexp.Compile(grant.Pattern)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,9 +12,9 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
|
||||
// POST /v3/account/create 200 200
|
||||
@@ -29,7 +29,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -62,7 +62,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -95,7 +95,7 @@ func (hand *Handler) ListAccounts(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -128,7 +128,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -161,7 +161,7 @@ func (hand *Handler) DeleteAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, params.Username)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, params.Username)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
|
||||
+7
-7
@@ -14,9 +14,9 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
|
||||
// HEAD /v2/<name>/blobs/<digest> 200 404
|
||||
@@ -32,7 +32,7 @@ func (hand *Handler) BlobExists(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -72,7 +72,7 @@ func (hand *Handler) PostUpload(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -117,7 +117,7 @@ func (hand *Handler) PatchUpload(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -161,7 +161,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -191,7 +191,7 @@ func (hand *Handler) GetBlob(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -237,7 +237,7 @@ func (hand *Handler) DeleteBlob(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
+8
-8
@@ -13,9 +13,9 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
|
||||
const zeroContentLength = "0"
|
||||
@@ -28,7 +28,7 @@ func (hand *Handler) FileInfo(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -73,7 +73,7 @@ func (hand *Handler) PutFile(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -101,7 +101,7 @@ func (hand *Handler) GetFile(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -149,7 +149,7 @@ func (hand *Handler) DeleteFile(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -179,7 +179,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -210,7 +210,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -248,7 +248,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) {
|
||||
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
@@ -12,9 +12,9 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
|
||||
// POST /v3/grant/create 200 200
|
||||
@@ -29,7 +29,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -62,7 +62,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -95,7 +95,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -128,7 +128,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -161,7 +161,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
|
||||
@@ -12,9 +12,9 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
|
||||
func (hand *Handler) ManifestExists(rctx *router.Context) {
|
||||
@@ -29,7 +29,7 @@ func (hand *Handler) ManifestExists(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -71,7 +71,7 @@ func (hand *Handler) PutManifest(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -104,7 +104,7 @@ func (hand *Handler) GetManifest(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -144,7 +144,7 @@ func (hand *Handler) DeleteManifest(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -173,7 +173,7 @@ func (hand *Handler) GetReferer(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -199,7 +199,7 @@ func (hand *Handler) GetTags(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user