working commit
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/auxhttp"
|
||||
"mstore/pkg/auxpwd"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -51,7 +51,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, uuid.UUID, error)
|
||||
var password string
|
||||
var accountID uuid.UUID
|
||||
|
||||
accountID = terms.AnonymousID
|
||||
accountID = term.AnonymousID
|
||||
|
||||
authHeader := rctx.GetHeader("Authorization")
|
||||
if authHeader != "" {
|
||||
@@ -76,7 +76,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, uuid.UUID, error)
|
||||
}
|
||||
anonymous:
|
||||
success = true
|
||||
accountID = terms.AnonymousID
|
||||
accountID = term.AnonymousID
|
||||
return success, accountID, err
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func (hand *Handler) ValidatePassword(ctx context.Context, username, password st
|
||||
|
||||
// Authorization
|
||||
|
||||
func (hand *Handler) CheckRight(ctx context.Context, accountID uuid.UUID, reqRight terms.Right, subject string) (bool, error) {
|
||||
func (hand *Handler) CheckRight(ctx context.Context, accountID uuid.UUID, reqRight term.Right, subject string) (bool, error) {
|
||||
var err error
|
||||
var res bool
|
||||
//hand.logg.Debugf("Cop check your right %s: %s %s", accountID, reqRight, subject)
|
||||
@@ -121,7 +121,7 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID uuid.UUID, reqRig
|
||||
return res, err
|
||||
}
|
||||
switch reqRight {
|
||||
case terms.RightReadFiles, terms.RightWriteFiles:
|
||||
case term.RightReadFiles, term.RightWriteFiles:
|
||||
for _, grant := range grants {
|
||||
re, err := regexp.Compile(grant.Pattern)
|
||||
if err != nil {
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -63,7 +63,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -96,7 +96,7 @@ func (hand *Handler) ListAccounts(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -129,7 +129,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -162,7 +162,7 @@ func (hand *Handler) DeleteAccount(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, params.Username)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, params.Username)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
|
||||
+7
-7
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ func (hand *Handler) BlobExists(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -73,7 +73,7 @@ func (hand *Handler) PostUpload(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -118,7 +118,7 @@ func (hand *Handler) PatchUpload(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -162,7 +162,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -192,7 +192,7 @@ func (hand *Handler) GetBlob(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -238,7 +238,7 @@ func (hand *Handler) DeleteBlob(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
+8
-8
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ func (hand *Handler) FileInfo(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -74,7 +74,7 @@ func (hand *Handler) PutFile(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -102,7 +102,7 @@ func (hand *Handler) GetFile(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -150,7 +150,7 @@ func (hand *Handler) DeleteFile(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -187,7 +187,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
|
||||
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -224,7 +224,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -262,7 +262,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) {
|
||||
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadFiles, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadFiles, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -63,7 +63,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -96,7 +96,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -129,7 +129,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -162,7 +162,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteAccounts, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/term"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ func (hand *Handler) ManifestExists(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -72,7 +72,7 @@ func (hand *Handler) PutManifest(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -105,7 +105,7 @@ func (hand *Handler) GetManifest(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -145,7 +145,7 @@ func (hand *Handler) DeleteManifest(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightWriteImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightWriteImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -174,7 +174,7 @@ func (hand *Handler) GetReferer(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -200,7 +200,7 @@ func (hand *Handler) GetTags(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), terms.RightReadImages, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, uuid.UUID(operatorID), term.RightReadImages, "")
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user