working commit

This commit is contained in:
2026-02-20 15:33:15 +02:00
parent 09f2125a4e
commit f973293315
18 changed files with 169 additions and 147 deletions
+5 -5
View File
@@ -17,7 +17,7 @@ import (
"mstore/app/router" "mstore/app/router"
"mstore/pkg/auxhttp" "mstore/pkg/auxhttp"
"mstore/pkg/auxpwd" "mstore/pkg/auxpwd"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -51,7 +51,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, uuid.UUID, error)
var password string var password string
var accountID uuid.UUID var accountID uuid.UUID
accountID = terms.AnonymousID accountID = term.AnonymousID
authHeader := rctx.GetHeader("Authorization") authHeader := rctx.GetHeader("Authorization")
if authHeader != "" { if authHeader != "" {
@@ -76,7 +76,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, uuid.UUID, error)
} }
anonymous: anonymous:
success = true success = true
accountID = terms.AnonymousID accountID = term.AnonymousID
return success, accountID, err return success, accountID, err
} }
@@ -102,7 +102,7 @@ func (hand *Handler) ValidatePassword(ctx context.Context, username, password st
// Authorization // 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 err error
var res bool var res bool
//hand.logg.Debugf("Cop check your right %s: %s %s", accountID, reqRight, subject) //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 return res, err
} }
switch reqRight { switch reqRight {
case terms.RightReadFiles, terms.RightWriteFiles: case term.RightReadFiles, term.RightWriteFiles:
for _, grant := range grants { for _, grant := range grants {
re, err := regexp.Compile(grant.Pattern) re, err := regexp.Compile(grant.Pattern)
if err != nil { if err != nil {
+6 -6
View File
@@ -14,7 +14,7 @@ import (
"mstore/app/operator" "mstore/app/operator"
"mstore/app/router" "mstore/app/router"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -30,7 +30,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -63,7 +63,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -96,7 +96,7 @@ func (hand *Handler) ListAccounts(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -129,7 +129,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -162,7 +162,7 @@ func (hand *Handler) DeleteAccount(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
+7 -7
View File
@@ -16,7 +16,7 @@ import (
"mstore/app/operator" "mstore/app/operator"
"mstore/app/router" "mstore/app/router"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -33,7 +33,7 @@ func (hand *Handler) BlobExists(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -73,7 +73,7 @@ func (hand *Handler) PostUpload(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -118,7 +118,7 @@ func (hand *Handler) PatchUpload(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -162,7 +162,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -192,7 +192,7 @@ func (hand *Handler) GetBlob(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -238,7 +238,7 @@ func (hand *Handler) DeleteBlob(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
+8 -8
View File
@@ -15,7 +15,7 @@ import (
"mstore/app/operator" "mstore/app/operator"
"mstore/app/router" "mstore/app/router"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -29,7 +29,7 @@ func (hand *Handler) FileInfo(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -74,7 +74,7 @@ func (hand *Handler) PutFile(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -102,7 +102,7 @@ func (hand *Handler) GetFile(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -150,7 +150,7 @@ func (hand *Handler) DeleteFile(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -187,7 +187,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -224,7 +224,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -262,7 +262,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) {
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
+6 -6
View File
@@ -14,7 +14,7 @@ import (
"mstore/app/operator" "mstore/app/operator"
"mstore/app/router" "mstore/app/router"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -30,7 +30,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -63,7 +63,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -96,7 +96,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -129,7 +129,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
@@ -162,7 +162,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
err := fmt.Errorf("Operation error: %v", err) err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err) hand.SendError(rctx, err)
+7 -7
View File
@@ -14,7 +14,7 @@ import (
"mstore/app/operator" "mstore/app/operator"
"mstore/app/router" "mstore/app/router"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -30,7 +30,7 @@ func (hand *Handler) ManifestExists(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -72,7 +72,7 @@ func (hand *Handler) PutManifest(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -105,7 +105,7 @@ func (hand *Handler) GetManifest(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -145,7 +145,7 @@ func (hand *Handler) DeleteManifest(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -174,7 +174,7 @@ func (hand *Handler) GetReferer(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
@@ -200,7 +200,7 @@ func (hand *Handler) GetTags(rctx *router.Context) {
} }
// Rigth checking // Rigth checking
operatorID, _ := rctx.GetString(userTag) 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 { if err != nil {
rctx.SetStatus(http.StatusInternalServerError) rctx.SetStatus(http.StatusInternalServerError)
return return
+4 -4
View File
@@ -13,7 +13,7 @@ import (
"context" "context"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -78,7 +78,7 @@ func (db *Database) GetGrantByID(ctx context.Context, id uuid.UUID) (bool, *desc
return true, res, err return true, res, err
} }
func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, *descr.Grant, error) { func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right term.Right) (bool, *descr.Grant, error) {
var err error var err error
res := &descr.Grant{} res := &descr.Grant{}
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 LIMIT 1` request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 LIMIT 1`
@@ -95,7 +95,7 @@ func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid
return true, res, err return true, res, err
} }
func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, []descr.Grant, error) { func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right term.Right) (bool, []descr.Grant, error) {
var err error var err error
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2` request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2`
res := make([]descr.Grant, 0) res := make([]descr.Grant, 0)
@@ -109,7 +109,7 @@ func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uu
return true, res, err return true, res, err
} }
func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID uuid.UUID, right terms.Right, pattern string) (bool, *descr.Grant, error) { func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID uuid.UUID, right term.Right, pattern string) (bool, *descr.Grant, error) {
var err error var err error
res := &descr.Grant{} res := &descr.Grant{}
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3 LIMIT 1` request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3 LIMIT 1`
+34 -34
View File
@@ -16,7 +16,7 @@ import (
"mstore/pkg/auxpwd" "mstore/pkg/auxpwd"
"mstore/pkg/auxtool" "mstore/pkg/auxtool"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -27,14 +27,14 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
password := auxtool.RandomString(64) password := auxtool.RandomString(64)
passhash := auxpwd.MakeSHA256Hash([]byte(password)) passhash := auxpwd.MakeSHA256Hash([]byte(password))
accountDescr := &descr.Account{ accountDescr := &descr.Account{
ID: terms.AnonymousID, ID: term.AnonymousID,
Username: terms.AnonimousUsername, Username: term.AnonimousUsername,
Passhash: passhash, Passhash: passhash,
Disabled: false, Disabled: false,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertAccount(ctx, accountDescr) err = db.InsertAccount(ctx, accountDescr)
if err != nil { if err != nil {
@@ -43,12 +43,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
grantDescr := &descr.Grant{ grantDescr := &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightReadFiles, Right: term.RightReadFiles,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
@@ -57,12 +57,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
grantDescr = &descr.Grant{ grantDescr = &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightReadImages, Right: term.RightReadImages,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
@@ -76,16 +76,16 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
func (db *Database) WriteInituser(ctx context.Context) error { func (db *Database) WriteInituser(ctx context.Context) error {
var err error var err error
now := auxtool.TimeNow() now := auxtool.TimeNow()
passhash := auxpwd.MakeSHA256Hash([]byte(terms.InitUsername)) passhash := auxpwd.MakeSHA256Hash([]byte(term.InitUsername))
accountDescr := &descr.Account{ accountDescr := &descr.Account{
ID: terms.InitID, ID: term.InitID,
Username: terms.InitUsername, Username: term.InitUsername,
Passhash: passhash, Passhash: passhash,
Disabled: false, Disabled: false,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertAccount(ctx, accountDescr) err = db.InsertAccount(ctx, accountDescr)
if err != nil { if err != nil {
@@ -95,12 +95,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr := &descr.Grant{ grantDescr := &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightReadFiles, Right: term.RightReadFiles,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
@@ -109,12 +109,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{ grantDescr = &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightWriteFiles, Right: term.RightWriteFiles,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
@@ -124,12 +124,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{ grantDescr = &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightReadAccounts, Right: term.RightReadAccounts,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
@@ -138,12 +138,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{ grantDescr = &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightWriteAccounts, Right: term.RightWriteAccounts,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
@@ -153,12 +153,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{ grantDescr = &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightReadImages, Right: term.RightReadImages,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
@@ -167,12 +167,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{ grantDescr = &descr.Grant{
ID: uuid.NewUUID(), ID: uuid.NewUUID(),
AccountID: accountDescr.ID, AccountID: accountDescr.ID,
Right: terms.RightWriteImages, Right: term.RightWriteImages,
Pattern: ".*", Pattern: ".*",
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
CreatedBy: terms.ServerID, CreatedBy: term.ServerID,
UpdatedBy: terms.ServerID, UpdatedBy: term.ServerID,
} }
err = db.InsertGrant(ctx, grantDescr) err = db.InsertGrant(ctx, grantDescr)
if err != nil { if err != nil {
+11 -11
View File
@@ -23,7 +23,7 @@ import (
"mstore/pkg/auxtool" "mstore/pkg/auxtool"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -288,7 +288,7 @@ func (oper *Operator) DeleteFile(ctx context.Context, operatorID uuid.UUID, para
// ListFiles // ListFiles
type ListFilesParams struct { type ListFilesParams struct {
Filepath string Filepath string
PathAs terms.PathUsage `param:"pathAs"` PathAs term.PathUsage `param:"pathAs"`
} }
type ListFilesResult struct { type ListFilesResult struct {
Files []descr.File `json:"files,omitempty"` Files []descr.File `json:"files,omitempty"`
@@ -300,14 +300,14 @@ func (oper *Operator) ListFiles(ctx context.Context, operatorID uuid.UUID, param
Files: make([]descr.File, 0), Files: make([]descr.File, 0),
} }
switch params.PathAs { switch params.PathAs {
case terms.AsRegexp: case term.AsRegexp:
files, err := oper.listFilesWithRegex(ctx, params.Filepath) files, err := oper.listFilesWithRegex(ctx, params.Filepath)
if err != nil { if err != nil {
code := http.StatusInternalServerError code := http.StatusInternalServerError
return code, res, err return code, res, err
} }
res.Files = files res.Files = files
case terms.AsPrefix: case term.AsPrefix:
params.Filepath, err = cleanFilepath(params.Filepath) params.Filepath, err = cleanFilepath(params.Filepath)
if err != nil { if err != nil {
code := http.StatusInternalServerError code := http.StatusInternalServerError
@@ -400,7 +400,7 @@ func (oper *Operator) listFilesWithRegex(ctx context.Context, regex string) ([]d
// ListCollections // ListCollections
type ListCollectionsParams struct { type ListCollectionsParams struct {
Path string Path string
PathAS terms.PathUsage `param:"pathAs"` PathAS term.PathUsage `param:"pathAs"`
} }
type ListCollectionsResult struct { type ListCollectionsResult struct {
Collections []string `json:"collection,omitempty"` Collections []string `json:"collection,omitempty"`
@@ -414,13 +414,13 @@ func (oper *Operator) ListCollections(ctx context.Context, operatorID uuid.UUID,
collectionList := make([]string, 0) collectionList := make([]string, 0)
switch param.PathAS { switch param.PathAS {
case terms.AsRegexp: case term.AsRegexp:
collectionList, err = oper.listCollectionsWithRegexp(ctx, param.Path) collectionList, err = oper.listCollectionsWithRegexp(ctx, param.Path)
if err != nil { if err != nil {
code := http.StatusInternalServerError code := http.StatusInternalServerError
return code, res, err return code, res, err
} }
case terms.AsPrefix: case term.AsPrefix:
param.Path, err = cleanFilepath(param.Path) param.Path, err = cleanFilepath(param.Path)
if err != nil { if err != nil {
code := http.StatusInternalServerError code := http.StatusInternalServerError
@@ -532,8 +532,8 @@ func (oper *Operator) listAllCollections(ctx context.Context) ([]string, error)
// DeleteColletion // DeleteColletion
type DeleteColletionParams struct { type DeleteColletionParams struct {
Path string Path string
PathAs terms.PathUsage `param:"pathAs"` PathAs term.PathUsage `param:"pathAs"`
DryRun bool `param:"dryRun"` DryRun bool `param:"dryRun"`
} }
type DeleteColletionResult struct { type DeleteColletionResult struct {
Files []descr.File `json:"files,omitempty"` Files []descr.File `json:"files,omitempty"`
@@ -545,7 +545,7 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uuid.UUID,
Files: make([]descr.File, 0), Files: make([]descr.File, 0),
} }
switch param.PathAs { switch param.PathAs {
case terms.AsRegexp: case term.AsRegexp:
collections, err := oper.listCollectionsWithRegexp(ctx, param.Path) collections, err := oper.listCollectionsWithRegexp(ctx, param.Path)
if err != nil { if err != nil {
code := http.StatusInternalServerError code := http.StatusInternalServerError
@@ -562,7 +562,7 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uuid.UUID,
} }
res.Files = allfiles res.Files = allfiles
case terms.AsPrefix: case term.AsPrefix:
param.Path, err = cleanFilepath(param.Path) param.Path, err = cleanFilepath(param.Path)
if err != nil { if err != nil {
code := http.StatusInternalServerError code := http.StatusInternalServerError
+5 -5
View File
@@ -7,16 +7,16 @@ import (
"mstore/pkg/auxtool" "mstore/pkg/auxtool"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
// CreateGrant // CreateGrant
type CreateGrantParams struct { type CreateGrantParams struct {
AccountID uuid.UUID `json:"accountID"` AccountID uuid.UUID `json:"accountID"`
Username string `json:"username"` Username string `json:"username"`
Right terms.Right `json:"operation"` Right term.Right `json:"operation"`
Pattern string `json:"pattern"` Pattern string `json:"pattern"`
} }
type CreateGrantResult struct { type CreateGrantResult struct {
GrantID uuid.UUID `json:"grantId"` GrantID uuid.UUID `json:"grantId"`
+15 -15
View File
@@ -20,7 +20,7 @@ import (
"mstore/pkg/client" "mstore/pkg/client"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -126,8 +126,8 @@ type CreateAccountParams struct {
NewPassword string NewPassword string
} }
type CreateAccountResult struct { type CreateAccountResult struct {
AccountID uuid.UUID `yaml:"accountId"` AccountID uuid.UUID `yaml:"accountId"`
Grants map[uuid.UUID]terms.Right `yaml:"grantsIds,omitempty"` Grants map[uuid.UUID]term.Right `yaml:"grantsIds,omitempty"`
} }
func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) { func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) {
@@ -141,7 +141,7 @@ func (util *AccountUtil) CreateAccount(cmd *cobra.Command, args []string) {
func (util *AccountUtil) createAccount(common *CommonAccountParams, params *CreateAccountParams) (*CreateAccountResult, error) { func (util *AccountUtil) createAccount(common *CommonAccountParams, params *CreateAccountParams) (*CreateAccountResult, error) {
var err error var err error
res := &CreateAccountResult{ res := &CreateAccountResult{
Grants: make(map[uuid.UUID]terms.Right, 0), Grants: make(map[uuid.UUID]term.Right, 0),
} }
hostname, err := packUserinfo(common.Hostname, common.Username, common.Password) hostname, err := packUserinfo(common.Hostname, common.Username, common.Password)
if err != nil { if err != nil {
@@ -154,13 +154,13 @@ func (util *AccountUtil) createAccount(common *CommonAccountParams, params *Crea
return res, err return res, err
} }
fullRights := []terms.Right{ fullRights := []term.Right{
terms.RightWriteAccounts, term.RightWriteAccounts,
terms.RightReadAccounts, term.RightReadAccounts,
terms.RightWriteFiles, term.RightWriteFiles,
terms.RightReadFiles, term.RightReadFiles,
terms.RightWriteImages, term.RightWriteImages,
terms.RightReadImages, term.RightReadImages,
} }
for _, right := range fullRights { for _, right := range fullRights {
id, err := client.NewClient().CreateGrantByAccountID(ctx, hostname, accountID, right, ".*") id, err := client.NewClient().CreateGrantByAccountID(ctx, hostname, accountID, right, ".*")
@@ -299,9 +299,9 @@ type ListAccountsParams struct {
} }
type Userinfo struct { type Userinfo struct {
Username string `yaml:"username,omitempty"` Username string `yaml:"username,omitempty"`
AccountID uuid.UUID `yaml:"accountId,omitempty"` AccountID uuid.UUID `yaml:"accountId,omitempty"`
Rights map[uuid.UUID]terms.Right `yaml:"rights,omitempty"` Rights map[uuid.UUID]term.Right `yaml:"rights,omitempty"`
} }
type ListAccountsResult struct { type ListAccountsResult struct {
@@ -350,7 +350,7 @@ func (util *AccountUtil) listAccounts(common *CommonAccountParams, params *ListA
userinfo := Userinfo{ userinfo := Userinfo{
Username: account.Username, Username: account.Username,
AccountID: account.ID, AccountID: account.ID,
Rights: make(map[uuid.UUID]terms.Right, 0), Rights: make(map[uuid.UUID]term.Right, 0),
} }
for _, grant := range account.Grants { for _, grant := range account.Grants {
userinfo.Rights[grant.ID] = grant.Right userinfo.Rights[grant.ID] = grant.Right
+16 -16
View File
@@ -27,7 +27,7 @@ import (
"mstore/pkg/client" "mstore/pkg/client"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
) )
func (util *FileUtil) CreateFileCmds() *cobra.Command { func (util *FileUtil) CreateFileCmds() *cobra.Command {
@@ -338,14 +338,14 @@ func (util *FileUtil) listFiles(common *CommonFileParams, params *ListFilesParam
if params.AsRegexp { if params.AsRegexp {
params.AsPrefix = false params.AsPrefix = false
} }
var pathAs terms.PathUsage var pathAs term.PathUsage
switch { switch {
case params.AsRegexp: case params.AsRegexp:
pathAs = terms.AsRegexp pathAs = term.AsRegexp
case params.AsPrefix: case params.AsPrefix:
pathAs = terms.AsPrefix pathAs = term.AsPrefix
default: default:
pathAs = terms.AsFinePath pathAs = term.AsFinePath
} }
timeout := time.Duration(common.Timeout) * time.Second timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
@@ -464,14 +464,14 @@ func (util *FileUtil) exportFiles(common *CommonFileParams, params *ExportFilesP
if params.AsRegexp { if params.AsRegexp {
params.AsPrefix = false params.AsPrefix = false
} }
var pathAs terms.PathUsage var pathAs term.PathUsage
switch { switch {
case params.AsRegexp: case params.AsRegexp:
pathAs = terms.AsRegexp pathAs = term.AsRegexp
case params.AsPrefix: case params.AsPrefix:
pathAs = terms.AsPrefix pathAs = term.AsPrefix
default: default:
pathAs = terms.AsFinePath pathAs = term.AsFinePath
} }
timeout := time.Duration(common.Timeout) * time.Second timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
@@ -553,14 +553,14 @@ func (util *FileUtil) listCollections(common *CommonFileParams, params *ListColl
if params.AsRegexp { if params.AsRegexp {
params.AsPrefix = false params.AsPrefix = false
} }
var pathAs terms.PathUsage var pathAs term.PathUsage
switch { switch {
case params.AsRegexp: case params.AsRegexp:
pathAs = terms.AsRegexp pathAs = term.AsRegexp
case params.AsPrefix: case params.AsPrefix:
pathAs = terms.AsPrefix pathAs = term.AsPrefix
default: default:
pathAs = terms.AsFinePath pathAs = term.AsFinePath
} }
timeout := time.Duration(common.Timeout) * time.Second timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
@@ -603,12 +603,12 @@ func (util *FileUtil) deleteCollection(common *CommonFileParams, params *DeleteC
} }
timeout := time.Duration(common.Timeout) * time.Second timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
var pathAs terms.PathUsage var pathAs term.PathUsage
switch { switch {
case params.AsPrefix: case params.AsPrefix:
pathAs = terms.AsPrefix pathAs = term.AsPrefix
default: default:
pathAs = terms.AsFinePath pathAs = term.AsFinePath
} }
files, err := client.NewClient().DeleteCollection(ctx, params.Path, pathAs, params.DryRun) files, err := client.NewClient().DeleteCollection(ctx, params.Path, pathAs, params.DryRun)
if err != nil { if err != nil {
+6 -6
View File
@@ -20,7 +20,7 @@ import (
"mstore/pkg/client" "mstore/pkg/client"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
@@ -142,9 +142,9 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
id := strings.ToLower(params.AccountID) id := strings.ToLower(params.AccountID)
var operRes uuid.UUID var operRes uuid.UUID
if re.MatchString(id) { if re.MatchString(id) {
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uuid.UUID(id), terms.Right(params.Right), params.Pattern) operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uuid.UUID(id), term.Right(params.Right), params.Pattern)
} else { } else {
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, terms.Right(params.Right), params.Pattern) operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, term.Right(params.Right), params.Pattern)
} }
if err != nil { if err != nil {
return res, err return res, err
@@ -259,8 +259,8 @@ type ListGrantsParams struct {
} }
type ListGrantsResult struct { type ListGrantsResult struct {
Grants []descr.Grant `yaml:"grants,omitempty"` Grants []descr.Grant `yaml:"grants,omitempty"`
Rights map[uuid.UUID]terms.Right `yaml:"rights,omitempty"` Rights map[uuid.UUID]term.Right `yaml:"rights,omitempty"`
} }
func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) { func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) {
@@ -292,7 +292,7 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
if params.Detail { if params.Detail {
res.Grants = grants res.Grants = grants
} else { } else {
res.Rights = make(map[uuid.UUID]terms.Right, 0) res.Rights = make(map[uuid.UUID]term.Right, 0)
for _, item := range grants { for _, item := range grants {
res.Rights[item.ID] = item.Right res.Rights[item.ID] = item.Right
} }
+4 -4
View File
@@ -23,7 +23,7 @@ import (
"mstore/pkg/auxhttp" "mstore/pkg/auxhttp"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
) )
func (cli *Client) FileInfo(ctx context.Context, fileuri string) (bool, *descr.File, error) { func (cli *Client) FileInfo(ctx context.Context, fileuri string) (bool, *descr.File, error) {
@@ -209,7 +209,7 @@ func (cli *Client) DeleteFile(ctx context.Context, fileuri string) error {
return err return err
} }
func (cli *Client) ListFiles(ctx context.Context, catalogURI string, usePathAs terms.PathUsage) ([]descr.File, error) { func (cli *Client) ListFiles(ctx context.Context, catalogURI string, usePathAs term.PathUsage) ([]descr.File, error) {
var err error var err error
res := make([]descr.File, 0) res := make([]descr.File, 0)
@@ -277,7 +277,7 @@ func (cli *Client) ListFiles(ctx context.Context, catalogURI string, usePathAs t
return res, err return res, err
} }
func (cli *Client) ListCollections(ctx context.Context, catalogURI string, usePathAs terms.PathUsage) ([]string, error) { func (cli *Client) ListCollections(ctx context.Context, catalogURI string, usePathAs term.PathUsage) ([]string, error) {
var err error var err error
res := make([]string, 0) res := make([]string, 0)
@@ -346,7 +346,7 @@ func (cli *Client) ListCollections(ctx context.Context, catalogURI string, usePa
return res, err return res, err
} }
func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string, usePathAs terms.PathUsage, dryRun bool) ([]descr.File, error) { func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string, usePathAs term.PathUsage, dryRun bool) ([]descr.File, error) {
var err error var err error
res := make([]descr.File, 0) res := make([]descr.File, 0)
+3 -3
View File
@@ -17,11 +17,11 @@ import (
"mstore/app/handler" "mstore/app/handler"
"mstore/app/operator" "mstore/app/operator"
"mstore/pkg/descr" "mstore/pkg/descr"
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID, right terms.Right, pattern string) (uuid.UUID, error) { func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID, right term.Right, pattern string) (uuid.UUID, error) {
var err error var err error
var res uuid.UUID var res uuid.UUID
@@ -56,7 +56,7 @@ func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, a
return res, err return res, err
} }
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username string, right terms.Right, pattern string) (uuid.UUID, error) { func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username string, right term.Right, pattern string) (uuid.UUID, error) {
var err error var err error
var res uuid.UUID var res uuid.UUID
+9 -9
View File
@@ -11,17 +11,17 @@
package descr package descr
import ( import (
"mstore/pkg/terms" "mstore/pkg/term"
"mstore/pkg/uuid" "mstore/pkg/uuid"
) )
type Grant struct { type Grant struct {
ID uuid.UUID `json:"id" db:"id"` ID uuid.UUID `json:"id" db:"id"`
AccountID uuid.UUID `json:"accountID" db:"account_id"` AccountID uuid.UUID `json:"accountID" db:"account_id"`
Right terms.Right `json:"right" db:"right"` Right term.Right `json:"right" db:"right"`
Pattern string `json:"pattern" db:"pattern"` Pattern string `json:"pattern" db:"pattern"`
CreatedAt string `json:"createdAt" db:"created_at"` CreatedAt string `json:"createdAt" db:"created_at"`
UpdatedAt string `json:"updatedAt" db:"updated_at"` UpdatedAt string `json:"updatedAt" db:"updated_at"`
CreatedBy uuid.UUID `json:"createdBy" db:"created_by"` CreatedBy uuid.UUID `json:"createdBy" db:"created_by"`
UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"` UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"`
} }
+1 -1
View File
@@ -8,7 +8,7 @@
* modifications are strictly prohibited. * modifications are strictly prohibited.
*/ */
package terms package term
import ( import (
"mstore/pkg/uuid" "mstore/pkg/uuid"
+22
View File
@@ -0,0 +1,22 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*
* This work is published and licensed under a Creative Commons
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
*
* Distribution of this work is permitted, but commercial use and
* modifications are strictly prohibited.
*/
package uuid
import (
"github.com/google/uuid"
)
type UUID string
const ZeroUUID UUID = "00000000-0000-0000-0000-000000000000"
func NewUUID() UUID {
return UUID(uuid.New().String())
}