working commit
This commit is contained in:
@@ -42,8 +42,8 @@ type Config struct {
|
|||||||
Logpath string `json:"logpath" yaml:"logpath"`
|
Logpath string `json:"logpath" yaml:"logpath"`
|
||||||
Runpath string `json:"runpath" yaml:"runpath"`
|
Runpath string `json:"runpath" yaml:"runpath"`
|
||||||
Version string `json:"version" yaml:"version"`
|
Version string `json:"version" yaml:"version"`
|
||||||
Certpath string `json:"certpath,omitempty" yaml:"certath"`
|
Certpath string `json:"certpath,omitempty" yaml:"certpath,omitempty"`
|
||||||
Keypath string `json:"keypath,omitempty" yaml:"keypath"`
|
Keypath string `json:"keypath,omitempty" yaml:"keypath,omitempty"`
|
||||||
X509Cert string `json:"-" yaml:"-"`
|
X509Cert string `json:"-" yaml:"-"`
|
||||||
X509Key string `json:"-" yaml:"-"`
|
X509Key string `json:"-" yaml:"-"`
|
||||||
Datadir string `json:"datadir" yaml:datadir`
|
Datadir string `json:"datadir" yaml:datadir`
|
||||||
@@ -89,7 +89,7 @@ func (conf *Config) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (conf *Config) ReadConfigfile() error {
|
func (conf *Config) ReadConfigfile() error {
|
||||||
conffile := fmt.Sprintf("%sd.yaml", srvname)
|
conffile := fmt.Sprintf("%s.yaml", srvname)
|
||||||
confpath := filepath.Join(confdir, conffile)
|
confpath := filepath.Join(confdir, conffile)
|
||||||
|
|
||||||
confdata, err := ioutil.ReadFile(confpath)
|
confdata, err := ioutil.ReadFile(confpath)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"mstore/pkg/auxhttp"
|
"mstore/pkg/auxhttp"
|
||||||
"mstore/pkg/auxpwd"
|
"mstore/pkg/auxpwd"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -44,12 +44,12 @@ func (hand *Handler) AuthMiddleware(next router.Handler) router.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Authentification
|
// Authentification
|
||||||
func (hand *Handler) CheckAccess(rctx *router.Context) (bool, uuid.UUID, error) {
|
func (hand *Handler) CheckAccess(rctx *router.Context) (bool, uint64, error) {
|
||||||
var err error
|
var err error
|
||||||
var success bool
|
var success bool
|
||||||
var username string
|
var username string
|
||||||
var password string
|
var password string
|
||||||
var accountID uuid.UUID
|
var accountID uint64
|
||||||
|
|
||||||
accountID = term.AnonymousID
|
accountID = term.AnonymousID
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ anonymous:
|
|||||||
return success, accountID, err
|
return success, accountID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hand *Handler) ValidatePassword(ctx context.Context, username, password string) (bool, uuid.UUID, error) {
|
func (hand *Handler) ValidatePassword(ctx context.Context, username, password string) (bool, uint64, error) {
|
||||||
var err error
|
var err error
|
||||||
var accountID uuid.UUID
|
var accountID uint64
|
||||||
valid := false
|
valid := false
|
||||||
|
|
||||||
accountExists, accountDescr, err := hand.mdb.GetAccountByUsername(ctx, username)
|
accountExists, accountDescr, err := hand.mdb.GetAccountByUsername(ctx, username)
|
||||||
@@ -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 term.Right, subject string) (bool, error) {
|
func (hand *Handler) CheckRight(ctx context.Context, accountID uint64, 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)
|
||||||
|
|||||||
+10
-10
@@ -15,7 +15,7 @@ import (
|
|||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/app/router"
|
"mstore/app/router"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// POST /v3/account/create 200 200
|
// POST /v3/account/create 200 200
|
||||||
@@ -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), term.RightWriteAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -42,7 +42,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.CreateAccount(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.CreateAccount(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("Operation error: %v", err)
|
hand.logg.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), term.RightWriteAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -75,7 +75,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.GetAccount(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.GetAccount(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("Operation error: %v", err)
|
hand.logg.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), term.RightWriteAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightWriteAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -141,7 +141,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.UpdateAccount(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.UpdateAccount(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("UpdateAccount error: %v", err)
|
hand.logg.Errorf("UpdateAccount 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), term.RightWriteAccounts, params.Username)
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -174,7 +174,7 @@ func (hand *Handler) DeleteAccount(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.DeleteAccount(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.DeleteAccount(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("DeleteAccount error: %v", err)
|
hand.logg.Errorf("DeleteAccount error: %v", err)
|
||||||
hand.SendError(rctx, err)
|
hand.SendError(rctx, err)
|
||||||
|
|||||||
+7
-7
@@ -17,7 +17,7 @@ import (
|
|||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/app/router"
|
"mstore/app/router"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HEAD /v2/<name>/blobs/<digest> 200 404
|
// HEAD /v2/<name>/blobs/<digest> 200 404
|
||||||
@@ -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), term.RightReadImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightWriteImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightWriteImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightWriteImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightReadImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightWriteImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightWriteImages, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
|||||||
+15
-15
@@ -16,7 +16,7 @@ import (
|
|||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/app/router"
|
"mstore/app/router"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
const zeroContentLength = "0"
|
const zeroContentLength = "0"
|
||||||
@@ -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), term.RightReadFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightReadFiles, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -40,7 +40,7 @@ func (hand *Handler) FileInfo(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
ctx := rctx.GetContext()
|
ctx := rctx.GetContext()
|
||||||
code, res, err := hand.oper.FileInfo(ctx, uuid.UUID(operatorID), params)
|
code, res, err := hand.oper.FileInfo(ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("FileInfo error: %v", err)
|
hand.logg.Errorf("FileInfo error: %v", err)
|
||||||
rctx.SetStatus(code)
|
rctx.SetStatus(code)
|
||||||
@@ -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), term.RightWriteFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightWriteFiles, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -85,7 +85,7 @@ func (hand *Handler) PutFile(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
ctx := rctx.GetContext()
|
ctx := rctx.GetContext()
|
||||||
code, _, err := hand.oper.PutFile(ctx, uuid.UUID(operatorID), params)
|
code, _, err := hand.oper.PutFile(ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("PutFile error: %v", err)
|
hand.logg.Errorf("PutFile error: %v", err)
|
||||||
rctx.SetStatus(code)
|
rctx.SetStatus(code)
|
||||||
@@ -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), term.RightReadFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightReadFiles, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -113,7 +113,7 @@ func (hand *Handler) GetFile(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
ctx := rctx.GetContext()
|
ctx := rctx.GetContext()
|
||||||
code, res, err := hand.oper.GetFile(ctx, uuid.UUID(operatorID), params)
|
code, res, err := hand.oper.GetFile(ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("PutFile error: %v", err)
|
hand.logg.Errorf("PutFile error: %v", err)
|
||||||
rctx.SetStatus(code)
|
rctx.SetStatus(code)
|
||||||
@@ -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), term.RightWriteFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightWriteFiles, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -161,7 +161,7 @@ func (hand *Handler) DeleteFile(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
ctx := rctx.GetContext()
|
ctx := rctx.GetContext()
|
||||||
code, _, err := hand.oper.DeleteFile(ctx, uuid.UUID(operatorID), params)
|
code, _, err := hand.oper.DeleteFile(ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("DeleteFIle error: %v", err)
|
hand.logg.Errorf("DeleteFIle error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -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), term.RightReadFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightReadFiles, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -198,7 +198,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
ctx := rctx.GetContext()
|
ctx := rctx.GetContext()
|
||||||
code, res, err := hand.oper.ListFiles(ctx, uuid.UUID(operatorID), params)
|
code, res, err := hand.oper.ListFiles(ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("ListFiles error: %v", err)
|
hand.logg.Errorf("ListFiles error: %v", err)
|
||||||
rctx.SetStatus(code)
|
rctx.SetStatus(code)
|
||||||
@@ -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), term.RightReadFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightReadFiles, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -235,7 +235,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
ctx := rctx.GetContext()
|
ctx := rctx.GetContext()
|
||||||
code, res, err := hand.oper.ListCollections(ctx, uuid.UUID(operatorID), params)
|
code, res, err := hand.oper.ListCollections(ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("ListCollections error: %v", err)
|
hand.logg.Errorf("ListCollections error: %v", err)
|
||||||
rctx.SetStatus(code)
|
rctx.SetStatus(code)
|
||||||
@@ -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), term.RightReadFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightReadFiles, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -273,7 +273,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) {
|
|||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
ctx := rctx.GetContext()
|
ctx := rctx.GetContext()
|
||||||
code, res, err := hand.oper.DeleteColletion(ctx, uuid.UUID(operatorID), params)
|
code, res, err := hand.oper.DeleteColletion(ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("DeleteColletion error: %v", err)
|
hand.logg.Errorf("DeleteColletion error: %v", err)
|
||||||
rctx.SetStatus(code)
|
rctx.SetStatus(code)
|
||||||
|
|||||||
+11
-11
@@ -15,7 +15,7 @@ import (
|
|||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/app/router"
|
"mstore/app/router"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// POST /v3/grant/create 200 200
|
// POST /v3/grant/create 200 200
|
||||||
@@ -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), term.RightWriteAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -42,7 +42,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.CreateGrant(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.CreateGrant(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("CreateGrant error: %v", err)
|
hand.logg.Errorf("CreateGrant 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), term.RightReadAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -75,7 +75,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.GetGrant(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.GetGrant(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("CreateGrant error: %v", err)
|
hand.logg.Errorf("CreateGrant 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), term.RightReadAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -108,7 +108,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.ListGrants(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.ListGrants(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("ListGrants error: %v", err)
|
hand.logg.Errorf("ListGrants 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), term.RightWriteAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -141,7 +141,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.UpdateGrant(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.UpdateGrant(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("UpdateGrant error: %v", err)
|
hand.logg.Errorf("UpdateGrant 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), term.RightWriteAccounts, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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)
|
||||||
@@ -174,7 +174,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Execution of the operation
|
// Execution of the operation
|
||||||
res, err := hand.oper.DeleteGrant(rctx.Ctx, uuid.UUID(operatorID), params)
|
res, err := hand.oper.DeleteGrant(rctx.Ctx, uint64(operatorID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hand.logg.Errorf("DeleteGrant error: %v", err)
|
hand.logg.Errorf("DeleteGrant error: %v", err)
|
||||||
hand.SendError(rctx, err)
|
hand.SendError(rctx, err)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/app/router"
|
"mstore/app/router"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (hand *Handler) ManifestExists(rctx *router.Context) {
|
func (hand *Handler) ManifestExists(rctx *router.Context) {
|
||||||
@@ -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), term.RightReadImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightWriteImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightReadImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightWriteImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightReadImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(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), term.RightReadImages, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, uint64(operatorID), term.RightReadImages, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rctx.SetStatus(http.StatusInternalServerError)
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (db *Database) InsertAccount(ctx context.Context, account *descr.Account) error {
|
func (db *Database) InsertAccount(ctx context.Context, account *descr.Account) error {
|
||||||
@@ -20,7 +19,7 @@ func (db *Database) InsertAccount(ctx context.Context, account *descr.Account) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) UpdateAccountByID(ctx context.Context, accountID uuid.UUID, account *descr.Account) error {
|
func (db *Database) UpdateAccountByID(ctx context.Context, accountID uint64, account *descr.Account) error {
|
||||||
var err error
|
var err error
|
||||||
request := `UPDATE accounts SET username = $1, passhash = $2, disabled = $3, updated_at = $4, updated_by = $5 WHERE id = $6`
|
request := `UPDATE accounts SET username = $1, passhash = $2, disabled = $3, updated_at = $4, updated_by = $5 WHERE id = $6`
|
||||||
_, err = db.db.Exec(request, account.Username, account.Passhash, account.Disabled, account.UpdatedAt, account.UpdatedBy, accountID)
|
_, err = db.db.Exec(request, account.Username, account.Passhash, account.Disabled, account.UpdatedAt, account.UpdatedBy, accountID)
|
||||||
@@ -52,7 +51,7 @@ func (db *Database) ListAccounts(ctx context.Context) ([]descr.Account, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) GetAccountByID(ctx context.Context, accountID uuid.UUID) (bool, *descr.Account, error) {
|
func (db *Database) GetAccountByID(ctx context.Context, accountID uint64) (bool, *descr.Account, error) {
|
||||||
var err error
|
var err error
|
||||||
var res *descr.Account
|
var res *descr.Account
|
||||||
var exists bool = false
|
var exists bool = false
|
||||||
@@ -91,7 +90,7 @@ func (db *Database) GetAccountByUsername(ctx context.Context, username string) (
|
|||||||
return exists, res, err
|
return exists, res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) DeleteAccountByID(ctx context.Context, accountID uuid.UUID) error {
|
func (db *Database) DeleteAccountByID(ctx context.Context, accountID uint64) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
request := `DELETE FROM accounts WHERE id = $1`
|
request := `DELETE FROM accounts WHERE id = $1`
|
||||||
|
|||||||
+1
-2
@@ -13,7 +13,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (db *Database) InsertFile(ctx context.Context, file *descr.File) error {
|
func (db *Database) InsertFile(ctx context.Context, file *descr.File) error {
|
||||||
@@ -28,7 +27,7 @@ func (db *Database) InsertFile(ctx context.Context, file *descr.File) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) UpdateFileByID(ctx context.Context, fileID uuid.UUID, file *descr.File) error {
|
func (db *Database) UpdateFileByID(ctx context.Context, fileID uint64, file *descr.File) error {
|
||||||
var err error
|
var err error
|
||||||
request := `UPDATE files SET id = $1, collection = $2, name = $3, type = $4, checksum = $5,
|
request := `UPDATE files SET id = $1, collection = $2, name = $3, type = $4, checksum = $5,
|
||||||
size = $6, updated_at = $7, created_by = $8, updated_by = $9
|
size = $6, updated_at = $7, created_by = $8, updated_by = $9
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
"mstore/pkg/auxtool"
|
"mstore/pkg/auxtool"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|||||||
+9
-10
@@ -14,7 +14,6 @@ import (
|
|||||||
|
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
||||||
@@ -29,7 +28,7 @@ func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) UpdateGrantByID(ctx context.Context, grantID uuid.UUID, grant *descr.Grant) error {
|
func (db *Database) UpdateGrantByID(ctx context.Context, grantID uint64, grant *descr.Grant) error {
|
||||||
var err error
|
var err error
|
||||||
request := `UPDATE grants SET pattern = $1, updated_at = $2, updated_by = $3 WHERE id = $4`
|
request := `UPDATE grants SET pattern = $1, updated_at = $2, updated_by = $3 WHERE id = $4`
|
||||||
_, err = db.db.Exec(request, grant.Pattern, grant.UpdatedAt, grant.UpdatedBy, grantID)
|
_, err = db.db.Exec(request, grant.Pattern, grant.UpdatedAt, grant.UpdatedBy, grantID)
|
||||||
@@ -39,7 +38,7 @@ func (db *Database) UpdateGrantByID(ctx context.Context, grantID uuid.UUID, gran
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID uuid.UUID) ([]descr.Grant, error) {
|
func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID uint64) ([]descr.Grant, error) {
|
||||||
var err error
|
var err error
|
||||||
request := `SELECT * FROM grants WHERE account_id = $1`
|
request := `SELECT * FROM grants WHERE account_id = $1`
|
||||||
res := make([]descr.Grant, 0)
|
res := make([]descr.Grant, 0)
|
||||||
@@ -61,7 +60,7 @@ func (db *Database) ListGrants(ctx context.Context) ([]descr.Grant, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) GetGrantByID(ctx context.Context, id uuid.UUID) (bool, *descr.Grant, error) {
|
func (db *Database) GetGrantByID(ctx context.Context, id uint64) (bool, *descr.Grant, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &descr.Grant{}
|
res := &descr.Grant{}
|
||||||
request := `SELECT * FROM grants WHERE id = $1 LIMIT 1`
|
request := `SELECT * FROM grants WHERE id = $1 LIMIT 1`
|
||||||
@@ -78,7 +77,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 term.Right) (bool, *descr.Grant, error) {
|
func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uint64, 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 +94,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 term.Right) (bool, []descr.Grant, error) {
|
func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uint64, 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 +108,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 term.Right, pattern string) (bool, *descr.Grant, error) {
|
func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID uint64, 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`
|
||||||
@@ -126,7 +125,7 @@ func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, account
|
|||||||
return true, res, err
|
return true, res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, accountID uuid.UUID, right, pattern string) error {
|
func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, accountID uint64, right, pattern string) error {
|
||||||
var err error
|
var err error
|
||||||
request := `DELETE FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3`
|
request := `DELETE FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3`
|
||||||
_, err = db.db.Exec(request, accountID, right, pattern)
|
_, err = db.db.Exec(request, accountID, right, pattern)
|
||||||
@@ -136,7 +135,7 @@ func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, acco
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) DeleteGrantByID(ctx context.Context, grantID uuid.UUID) error {
|
func (db *Database) DeleteGrantByID(ctx context.Context, grantID uint64) error {
|
||||||
var err error
|
var err error
|
||||||
request := `DELETE FROM grants WHERE id = $1`
|
request := `DELETE FROM grants WHERE id = $1`
|
||||||
_, err = db.db.Exec(request, grantID)
|
_, err = db.db.Exec(request, grantID)
|
||||||
@@ -146,7 +145,7 @@ func (db *Database) DeleteGrantByID(ctx context.Context, grantID uuid.UUID) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID uuid.UUID) error {
|
func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID uint64) error {
|
||||||
var err error
|
var err error
|
||||||
request := `DELETE FROM grants WHERE account_id = $1`
|
request := `DELETE FROM grants WHERE account_id = $1`
|
||||||
_, err = db.db.Exec(request, grantID)
|
_, err = db.db.Exec(request, grantID)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
"mstore/pkg/auxtool"
|
"mstore/pkg/auxtool"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|||||||
+9
-9
@@ -17,7 +17,7 @@ import (
|
|||||||
"mstore/pkg/auxtool"
|
"mstore/pkg/auxtool"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (db *Database) WriteAnonymous(ctx context.Context) error {
|
func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||||
@@ -41,7 +41,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
grantDescr := &descr.Grant{
|
grantDescr := &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightReadFiles,
|
Right: term.RightReadFiles,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
@@ -55,7 +55,7 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
grantDescr = &descr.Grant{
|
grantDescr = &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightReadImages,
|
Right: term.RightReadImages,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
@@ -93,7 +93,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
// Files
|
// Files
|
||||||
grantDescr := &descr.Grant{
|
grantDescr := &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightReadFiles,
|
Right: term.RightReadFiles,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
@@ -107,7 +107,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
grantDescr = &descr.Grant{
|
grantDescr = &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightWriteFiles,
|
Right: term.RightWriteFiles,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
@@ -122,7 +122,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
// Accounts
|
// Accounts
|
||||||
grantDescr = &descr.Grant{
|
grantDescr = &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightReadAccounts,
|
Right: term.RightReadAccounts,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
@@ -136,7 +136,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
grantDescr = &descr.Grant{
|
grantDescr = &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightWriteAccounts,
|
Right: term.RightWriteAccounts,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
@@ -151,7 +151,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
// Images
|
// Images
|
||||||
grantDescr = &descr.Grant{
|
grantDescr = &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightReadImages,
|
Right: term.RightReadImages,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
@@ -165,7 +165,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
grantDescr = &descr.Grant{
|
grantDescr = &descr.Grant{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
AccountID: accountDescr.ID,
|
AccountID: accountDescr.ID,
|
||||||
Right: term.RightWriteImages,
|
Right: term.RightWriteImages,
|
||||||
Pattern: ".*",
|
Pattern: ".*",
|
||||||
|
|||||||
+14
-14
@@ -7,7 +7,7 @@ import (
|
|||||||
"mstore/pkg/auxpwd"
|
"mstore/pkg/auxpwd"
|
||||||
"mstore/pkg/auxtool"
|
"mstore/pkg/auxtool"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateAccountParams struct {
|
type CreateAccountParams struct {
|
||||||
@@ -15,10 +15,10 @@ type CreateAccountParams struct {
|
|||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
type CreateAccountResult struct {
|
type CreateAccountResult struct {
|
||||||
AccountID uuid.UUID `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) CreateAccount(ctx context.Context, operatorID uuid.UUID, params *CreateAccountParams) (*CreateAccountResult, error) {
|
func (oper *Operator) CreateAccount(ctx context.Context, operatorID uint64, params *CreateAccountParams) (*CreateAccountResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &CreateAccountResult{}
|
res := &CreateAccountResult{}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID uuid.UUID, p
|
|||||||
now := auxtool.TimeNow()
|
now := auxtool.TimeNow()
|
||||||
passhash := auxpwd.MakeSHA256Hash([]byte(params.Password))
|
passhash := auxpwd.MakeSHA256Hash([]byte(params.Password))
|
||||||
accountDescr := &descr.Account{
|
accountDescr := &descr.Account{
|
||||||
ID: uuid.NewUUID(),
|
ID: auxid.NewID(),
|
||||||
Username: params.Username,
|
Username: params.Username,
|
||||||
Passhash: passhash,
|
Passhash: passhash,
|
||||||
Disabled: false,
|
Disabled: false,
|
||||||
@@ -63,17 +63,17 @@ func (oper *Operator) CreateAccount(ctx context.Context, operatorID uuid.UUID, p
|
|||||||
// GetAccount
|
// GetAccount
|
||||||
type GetAccountParams struct {
|
type GetAccountParams struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
AccountID uuid.UUID `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
}
|
}
|
||||||
type GetAccountResult struct {
|
type GetAccountResult struct {
|
||||||
Account *descr.AccountShort `json:"account"`
|
Account *descr.AccountShort `json:"account"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) GetAccount(ctx context.Context, operatorID uuid.UUID, params *GetAccountParams) (*GetAccountResult, error) {
|
func (oper *Operator) GetAccount(ctx context.Context, operatorID uint64, params *GetAccountParams) (*GetAccountResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &GetAccountResult{}
|
res := &GetAccountResult{}
|
||||||
|
|
||||||
if params.Username == "" && params.AccountID == "" {
|
if params.Username == "" && params.AccountID == 0 {
|
||||||
err := fmt.Errorf("Empty username and accountId parameter")
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ func (oper *Operator) GetAccount(ctx context.Context, operatorID uuid.UUID, para
|
|||||||
var accountDescr *descr.Account
|
var accountDescr *descr.Account
|
||||||
var accountExists bool
|
var accountExists bool
|
||||||
switch {
|
switch {
|
||||||
case params.AccountID != "":
|
case params.AccountID != 0:
|
||||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -129,24 +129,24 @@ func (oper *Operator) GetAccount(ctx context.Context, operatorID uuid.UUID, para
|
|||||||
|
|
||||||
type UpdateAccountParams struct {
|
type UpdateAccountParams struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
AccountID uuid.UUID `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
NewUsername string `json:"newUsername"`
|
NewUsername string `json:"newUsername"`
|
||||||
NewPassword string `json:"newPassword"`
|
NewPassword string `json:"newPassword"`
|
||||||
Disabled bool `json:"disabled"`
|
Disabled bool `json:"disabled"`
|
||||||
}
|
}
|
||||||
type UpdateAccountResult struct{}
|
type UpdateAccountResult struct{}
|
||||||
|
|
||||||
func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uuid.UUID, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uint64, params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &UpdateAccountResult{}
|
res := &UpdateAccountResult{}
|
||||||
if params.Username == "" && params.AccountID == "" {
|
if params.Username == "" && params.AccountID == 0 {
|
||||||
err := fmt.Errorf("Empty username and accountId parameter")
|
err := fmt.Errorf("Empty username and accountId parameter")
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
var accountDescr *descr.Account
|
var accountDescr *descr.Account
|
||||||
var accountExists bool
|
var accountExists bool
|
||||||
switch {
|
switch {
|
||||||
case params.AccountID != "":
|
case params.AccountID != 0:
|
||||||
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -196,11 +196,11 @@ func (oper *Operator) UpdateAccount(ctx context.Context, operatorID uuid.UUID, p
|
|||||||
|
|
||||||
type DeleteAccountParams struct {
|
type DeleteAccountParams struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
AccountID uuid.UUID `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
}
|
}
|
||||||
type DeleteAccountResult struct{}
|
type DeleteAccountResult struct{}
|
||||||
|
|
||||||
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID uuid.UUID, params *DeleteAccountParams) (*DeleteAccountResult, error) {
|
func (oper *Operator) DeleteAccount(ctx context.Context, operatorID uint64, params *DeleteAccountParams) (*DeleteAccountResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &DeleteAccountResult{}
|
res := &DeleteAccountResult{}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlobExistsParams struct {
|
type BlobExistsParams struct {
|
||||||
@@ -73,7 +73,7 @@ type PostUploadParams struct {
|
|||||||
From string
|
From string
|
||||||
}
|
}
|
||||||
type PostUploadResult struct {
|
type PostUploadResult struct {
|
||||||
DockerUploadUUID uuid.UUID
|
DockerUploadUUID uint64
|
||||||
Location string
|
Location string
|
||||||
ContentLength string
|
ContentLength string
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -24,7 +24,7 @@ import (
|
|||||||
"mstore/pkg/auxtool"
|
"mstore/pkg/auxtool"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FileInfo
|
// FileInfo
|
||||||
@@ -41,9 +41,9 @@ type FileInfoResult struct {
|
|||||||
ContentDigest string
|
ContentDigest string
|
||||||
|
|
||||||
ContentCreatedAt string
|
ContentCreatedAt string
|
||||||
ContentCreatedBy uuid.UUID
|
ContentCreatedBy uint64
|
||||||
ContentUpdatedAt string
|
ContentUpdatedAt string
|
||||||
ContentUpdatedBy uuid.UUID
|
ContentUpdatedBy uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanFilepath(filename string) (string, error) {
|
func cleanFilepath(filename string) (string, error) {
|
||||||
@@ -51,7 +51,7 @@ func cleanFilepath(filename string) (string, error) {
|
|||||||
return filepath.Clean(filename), nil
|
return filepath.Clean(filename), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) FileInfo(ctx context.Context, operatorID uuid.UUID, param *FileInfoParams) (int, *FileInfoResult, error) {
|
func (oper *Operator) FileInfo(ctx context.Context, operatorID uint64, param *FileInfoParams) (int, *FileInfoResult, error) {
|
||||||
var err error
|
var err error
|
||||||
code := http.StatusOK
|
code := http.StatusOK
|
||||||
res := &FileInfoResult{}
|
res := &FileInfoResult{}
|
||||||
@@ -101,7 +101,7 @@ type PutFileResult struct{}
|
|||||||
const defaultContentType = "application/octet-stream"
|
const defaultContentType = "application/octet-stream"
|
||||||
|
|
||||||
// TODO: checking catalog and file names conflict
|
// TODO: checking catalog and file names conflict
|
||||||
func (oper *Operator) PutFile(ctx context.Context, operatorID uuid.UUID, param *PutFileParams) (int, *PutFileResult, error) {
|
func (oper *Operator) PutFile(ctx context.Context, operatorID uint64, param *PutFileParams) (int, *PutFileResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &PutFileResult{}
|
res := &PutFileResult{}
|
||||||
|
|
||||||
@@ -193,12 +193,12 @@ type GetFileResult struct {
|
|||||||
Source io.ReadCloser
|
Source io.ReadCloser
|
||||||
|
|
||||||
ContentCreatedAt string
|
ContentCreatedAt string
|
||||||
ContentCreatedBy uuid.UUID
|
ContentCreatedBy uint64
|
||||||
ContentUpdatedAt string
|
ContentUpdatedAt string
|
||||||
ContentUpdatedBy uuid.UUID
|
ContentUpdatedBy uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) GetFile(ctx context.Context, operatorID uuid.UUID, param *GetFileParams) (int, *GetFileResult, error) {
|
func (oper *Operator) GetFile(ctx context.Context, operatorID uint64, param *GetFileParams) (int, *GetFileResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &GetFileResult{}
|
res := &GetFileResult{}
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ type DeleteFileParams struct {
|
|||||||
}
|
}
|
||||||
type DeleteFileResult struct{}
|
type DeleteFileResult struct{}
|
||||||
|
|
||||||
func (oper *Operator) DeleteFile(ctx context.Context, operatorID uuid.UUID, param *DeleteFileParams) (int, *DeleteFileResult, error) {
|
func (oper *Operator) DeleteFile(ctx context.Context, operatorID uint64, param *DeleteFileParams) (int, *DeleteFileResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &DeleteFileResult{}
|
res := &DeleteFileResult{}
|
||||||
code := http.StatusOK
|
code := http.StatusOK
|
||||||
@@ -294,7 +294,7 @@ type ListFilesResult struct {
|
|||||||
Files []descr.File `json:"files,omitempty"`
|
Files []descr.File `json:"files,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) ListFiles(ctx context.Context, operatorID uuid.UUID, params *ListFilesParams) (int, *ListFilesResult, error) {
|
func (oper *Operator) ListFiles(ctx context.Context, operatorID uint64, params *ListFilesParams) (int, *ListFilesResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &ListFilesResult{
|
res := &ListFilesResult{
|
||||||
Files: make([]descr.File, 0),
|
Files: make([]descr.File, 0),
|
||||||
@@ -406,7 +406,7 @@ type ListCollectionsResult struct {
|
|||||||
Collections []string `json:"collection,omitempty"`
|
Collections []string `json:"collection,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) ListCollections(ctx context.Context, operatorID uuid.UUID, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
|
func (oper *Operator) ListCollections(ctx context.Context, operatorID uint64, param *ListCollectionsParams) (int, *ListCollectionsResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &ListCollectionsResult{
|
res := &ListCollectionsResult{
|
||||||
Collections: make([]string, 0),
|
Collections: make([]string, 0),
|
||||||
@@ -539,7 +539,7 @@ type DeleteColletionResult struct {
|
|||||||
Files []descr.File `json:"files,omitempty"`
|
Files []descr.File `json:"files,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uuid.UUID, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
|
func (oper *Operator) DeleteColletion(ctx context.Context, operatorID uint64, param *DeleteColletionParams) (int, *DeleteColletionResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &DeleteColletionResult{
|
res := &DeleteColletionResult{
|
||||||
Files: make([]descr.File, 0),
|
Files: make([]descr.File, 0),
|
||||||
|
|||||||
+12
-12
@@ -8,21 +8,21 @@ import (
|
|||||||
"mstore/pkg/auxtool"
|
"mstore/pkg/auxtool"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateGrant
|
// CreateGrant
|
||||||
type CreateGrantParams struct {
|
type CreateGrantParams struct {
|
||||||
AccountID uuid.UUID `json:"accountID"`
|
AccountID uint64 `json:"accountID"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Right term.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 uint64 `json:"grantId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) CreateGrant(ctx context.Context, operatorID uuid.UUID, params *CreateGrantParams) (*CreateGrantResult, error) {
|
func (oper *Operator) CreateGrant(ctx context.Context, operatorID uint64, params *CreateGrantParams) (*CreateGrantResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &CreateGrantResult{}
|
res := &CreateGrantResult{}
|
||||||
|
|
||||||
@@ -100,12 +100,12 @@ func (oper *Operator) CreateGrant(ctx context.Context, operatorID uuid.UUID, par
|
|||||||
|
|
||||||
// UpdateGrant
|
// UpdateGrant
|
||||||
type UpdateGrantParams struct {
|
type UpdateGrantParams struct {
|
||||||
GrantID uuid.UUID
|
GrantID uint64
|
||||||
NewPattern string
|
NewPattern string
|
||||||
}
|
}
|
||||||
type UpdateGrantResult struct{}
|
type UpdateGrantResult struct{}
|
||||||
|
|
||||||
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uuid.UUID, params *UpdateGrantParams) (*UpdateGrantResult, error) {
|
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uint64, params *UpdateGrantParams) (*UpdateGrantResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &UpdateGrantResult{}
|
res := &UpdateGrantResult{}
|
||||||
|
|
||||||
@@ -143,11 +143,11 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operatorID uuid.UUID, par
|
|||||||
|
|
||||||
// DeleteGrant
|
// DeleteGrant
|
||||||
type DeleteGrantParams struct {
|
type DeleteGrantParams struct {
|
||||||
GrantID uuid.UUID `json:"grantId"`
|
GrantID uint64 `json:"grantId"`
|
||||||
}
|
}
|
||||||
type DeleteGrantResult struct{}
|
type DeleteGrantResult struct{}
|
||||||
|
|
||||||
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uuid.UUID, params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uint64, params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &DeleteGrantResult{}
|
res := &DeleteGrantResult{}
|
||||||
|
|
||||||
@@ -177,13 +177,13 @@ func (oper *Operator) DeleteGrant(ctx context.Context, operatorID uuid.UUID, par
|
|||||||
// ListGrants
|
// ListGrants
|
||||||
type ListGrantsParams struct {
|
type ListGrantsParams struct {
|
||||||
Username string
|
Username string
|
||||||
AccountID uuid.UUID
|
AccountID uint64
|
||||||
}
|
}
|
||||||
type ListGrantsResult struct {
|
type ListGrantsResult struct {
|
||||||
Grants []descr.Grant `json:"grants"`
|
Grants []descr.Grant `json:"grants"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) ListGrants(ctx context.Context, operatorID uuid.UUID, params *ListGrantsParams) (*ListGrantsResult, error) {
|
func (oper *Operator) ListGrants(ctx context.Context, operatorID uint64, params *ListGrantsParams) (*ListGrantsResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &ListGrantsResult{
|
res := &ListGrantsResult{
|
||||||
Grants: make([]descr.Grant, 0),
|
Grants: make([]descr.Grant, 0),
|
||||||
@@ -224,13 +224,13 @@ func (oper *Operator) ListGrants(ctx context.Context, operatorID uuid.UUID, para
|
|||||||
|
|
||||||
// Get Grants
|
// Get Grants
|
||||||
type GetGrantParams struct {
|
type GetGrantParams struct {
|
||||||
GrantID uuid.UUID `json:"grantId"`
|
GrantID uint64 `json:"grantId"`
|
||||||
}
|
}
|
||||||
type GetGrantResult struct {
|
type GetGrantResult struct {
|
||||||
Grant *descr.Grant `json:"grant"`
|
Grant *descr.Grant `json:"grant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oper *Operator) GetGrant(ctx context.Context, operatorID uuid.UUID, params *GetGrantParams) (*GetGrantResult, error) {
|
func (oper *Operator) GetGrant(ctx context.Context, operatorID uint64, params *GetGrantParams) (*GetGrantResult, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &GetGrantResult{}
|
res := &GetGrantResult{}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ package operator
|
|||||||
import (
|
import (
|
||||||
"mstore/pkg/auxtool"
|
"mstore/pkg/auxtool"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
|
|
||||||
ocidigest "github.com/opencontainers/go-digest"
|
ocidigest "github.com/opencontainers/go-digest"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func (srv *Server) Configure() error {
|
|||||||
}
|
}
|
||||||
err = srv.conf.ReadConfigfile()
|
err = srv.conf.ReadConfigfile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//srv.logg.Warningf("Error loading config file: %v", err)
|
srv.logg.Warningf("Error loading config file: %v", err)
|
||||||
//return err
|
//return err
|
||||||
}
|
}
|
||||||
err = srv.conf.ReadX509Cert()
|
err = srv.conf.ReadX509Cert()
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"mstore/app/logger"
|
"mstore/app/logger"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -80,8 +81,8 @@ func (store *Storage) WriteTempFile(source io.Reader) (string, int64, string, er
|
|||||||
var size int64
|
var size int64
|
||||||
var csum string
|
var csum string
|
||||||
|
|
||||||
tmpname := string(uuid.NewUUID())
|
|
||||||
tmpname = fmt.Sprintf("file-%s.tmp", tmpname)
|
tmpname := fmt.Sprintf("file-%d-%d.tmp", auxid.NewID(), auxid.NewID())
|
||||||
tmppath := store.makeTmppath(tmpname)
|
tmppath := store.makeTmppath(tmpname)
|
||||||
|
|
||||||
tmpdirpath := store.makeTmpsubdir()
|
tmpdirpath := store.makeTmpsubdir()
|
||||||
|
|||||||
+10
-10
@@ -21,7 +21,7 @@ import (
|
|||||||
"mstore/pkg/client"
|
"mstore/pkg/client"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -126,8 +126,8 @@ type CreateAccountParams struct {
|
|||||||
NewPassword string
|
NewPassword string
|
||||||
}
|
}
|
||||||
type CreateAccountResult struct {
|
type CreateAccountResult struct {
|
||||||
AccountID uuid.UUID `yaml:"accountId"`
|
AccountID uint64 `yaml:"accountId"`
|
||||||
Grants map[uuid.UUID]term.Right `yaml:"grantsIds,omitempty"`
|
Grants map[uint64]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]term.Right, 0),
|
Grants: make(map[uint64]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 {
|
||||||
@@ -203,7 +203,7 @@ func (util *AccountUtil) updateAccount(common *CommonAccountParams, params *Upda
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
err = client.NewClient().UpdateAccountByID(ctx, hostname, uuid.UUID(id), params.NewUsername, params.NewPassword)
|
err = client.NewClient().UpdateAccountByID(ctx, hostname, uint64(id), params.NewUsername, params.NewPassword)
|
||||||
} else {
|
} else {
|
||||||
err = client.NewClient().UpdateAccountByName(ctx, hostname, params.AccountID, params.NewUsername, params.NewPassword)
|
err = client.NewClient().UpdateAccountByName(ctx, hostname, params.AccountID, params.NewUsername, params.NewPassword)
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ func (util *AccountUtil) getAccount(common *CommonAccountParams, params *GetAcco
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
opRes, err = client.NewClient().GetAccountByID(ctx, hostname, uuid.UUID(id))
|
opRes, err = client.NewClient().GetAccountByID(ctx, hostname, uint64(id))
|
||||||
} else {
|
} else {
|
||||||
opRes, err = client.NewClient().GetAccountByName(ctx, hostname, params.AccountID)
|
opRes, err = client.NewClient().GetAccountByName(ctx, hostname, params.AccountID)
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ func (util *AccountUtil) deleteAccount(common *CommonAccountParams, params *Dele
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
err = client.NewClient().DeleteAccountByID(ctx, hostname, uuid.UUID(id))
|
err = client.NewClient().DeleteAccountByID(ctx, hostname, uint64(id))
|
||||||
} else {
|
} else {
|
||||||
err = client.NewClient().DeleteAccountByName(ctx, hostname, params.AccountID)
|
err = client.NewClient().DeleteAccountByName(ctx, hostname, params.AccountID)
|
||||||
}
|
}
|
||||||
@@ -300,8 +300,8 @@ 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 uint64 `yaml:"accountId,omitempty"`
|
||||||
Rights map[uuid.UUID]term.Right `yaml:"rights,omitempty"`
|
Rights map[uint64]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]term.Right, 0),
|
Rights: make(map[uint64]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
|
||||||
|
|||||||
+10
-10
@@ -21,7 +21,7 @@ import (
|
|||||||
"mstore/pkg/client"
|
"mstore/pkg/client"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
||||||
@@ -117,7 +117,7 @@ type CreateGrantParams struct {
|
|||||||
Pattern string
|
Pattern string
|
||||||
}
|
}
|
||||||
type CreateGrantResult struct {
|
type CreateGrantResult struct {
|
||||||
GrantID uuid.UUID `yaml:"grantId"`
|
GrantID uint64 `yaml:"grantId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (util *GrantUtil) CreateGrant(cmd *cobra.Command, args []string) {
|
func (util *GrantUtil) CreateGrant(cmd *cobra.Command, args []string) {
|
||||||
@@ -140,9 +140,9 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
|
|||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
var operRes uuid.UUID
|
var operRes uint64
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uuid.UUID(id), term.Right(params.Right), params.Pattern)
|
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, uint64(id), term.Right(params.Right), params.Pattern)
|
||||||
} else {
|
} else {
|
||||||
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, term.Right(params.Right), params.Pattern)
|
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, term.Right(params.Right), params.Pattern)
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ func (util *GrantUtil) updateGrant(common *CommonGrantParams, params *UpdateGran
|
|||||||
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)
|
||||||
id := strings.ToLower(params.GrantID)
|
id := strings.ToLower(params.GrantID)
|
||||||
err = client.NewClient().UpdateGrant(ctx, hostname, uuid.UUID(id), params.Pattern)
|
err = client.NewClient().UpdateGrant(ctx, hostname, uint64(id), params.Pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ func (util *GrantUtil) getGrant(common *CommonGrantParams, params *GetGrantParam
|
|||||||
opRes := &descr.Grant{}
|
opRes := &descr.Grant{}
|
||||||
|
|
||||||
id := strings.ToLower(params.GrantID)
|
id := strings.ToLower(params.GrantID)
|
||||||
opRes, err = client.NewClient().GetGrant(ctx, hostname, uuid.UUID(id))
|
opRes, err = client.NewClient().GetGrant(ctx, hostname, uint64(id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ func (util *GrantUtil) deleteGrant(common *CommonGrantParams, params *DeleteGran
|
|||||||
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)
|
||||||
id := strings.ToLower(params.GrantID)
|
id := strings.ToLower(params.GrantID)
|
||||||
err = client.NewClient().DeleteGrant(ctx, hostname, uuid.UUID(id))
|
err = client.NewClient().DeleteGrant(ctx, hostname, uint64(id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ 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]term.Right `yaml:"rights,omitempty"`
|
Rights map[uint64]term.Right `yaml:"rights,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) {
|
func (util *GrantUtil) ListGrants(cmd *cobra.Command, args []string) {
|
||||||
@@ -282,7 +282,7 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, uuid.UUID(id))
|
grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, uint64(id))
|
||||||
} else {
|
} else {
|
||||||
grants, err = client.NewClient().ListGrantsByUsername(ctx, hostname, params.AccountID)
|
grants, err = client.NewClient().ListGrantsByUsername(ctx, hostname, params.AccountID)
|
||||||
}
|
}
|
||||||
@@ -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]term.Right, 0)
|
res.Rights = make(map[uint64]term.Right, 0)
|
||||||
for _, item := range grants {
|
for _, item := range grants {
|
||||||
res.Rights[item.ID] = item.Right
|
res.Rights[item.ID] = item.Right
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ import (
|
|||||||
"mstore/app/handler"
|
"mstore/app/handler"
|
||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (uuid.UUID, error) {
|
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (uint64, error) {
|
||||||
var err error
|
var err error
|
||||||
var res uuid.UUID
|
var res uint64
|
||||||
|
|
||||||
apiuri, err := setApiPath(hosturi, "/v3/api/account/create")
|
apiuri, err := setApiPath(hosturi, "/v3/api/account/create")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -54,7 +54,7 @@ func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, passwor
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id uuid.UUID) (*descr.AccountShort, error) {
|
func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id uint64) (*descr.AccountShort, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &descr.AccountShort{}
|
res := &descr.AccountShort{}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ func (cli *Client) GetAccountByName(ctx context.Context, hosturi, username strin
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id uuid.UUID, newUsername, newPassword string) error {
|
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id uint64, newUsername, newPassword string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
apipath, err := setApiPath(hosturi, "/v3/api/account/update")
|
apipath, err := setApiPath(hosturi, "/v3/api/account/update")
|
||||||
@@ -215,7 +215,7 @@ func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username st
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id uuid.UUID) error {
|
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id uint64) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
||||||
|
|||||||
+9
-9
@@ -18,12 +18,12 @@ import (
|
|||||||
"mstore/app/operator"
|
"mstore/app/operator"
|
||||||
"mstore/pkg/descr"
|
"mstore/pkg/descr"
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID, right term.Right, pattern string) (uuid.UUID, error) {
|
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID uint64, right term.Right, pattern string) (uint64, error) {
|
||||||
var err error
|
var err error
|
||||||
var res uuid.UUID
|
var res uint64
|
||||||
|
|
||||||
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -56,9 +56,9 @@ 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 term.Right, pattern string) (uuid.UUID, error) {
|
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username string, right term.Right, pattern string) (uint64, error) {
|
||||||
var err error
|
var err error
|
||||||
var res uuid.UUID
|
var res uint64
|
||||||
|
|
||||||
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -91,7 +91,7 @@ func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uuid.UUID) (*descr.Grant, error) {
|
func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uint64) (*descr.Grant, error) {
|
||||||
var err error
|
var err error
|
||||||
res := &descr.Grant{}
|
res := &descr.Grant{}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uuid.UUID) (
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID uuid.UUID, newPattern string) error {
|
func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID uint64, newPattern string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
apipath, err := setApiPath(hosturi, "/v3/api/grant/update")
|
apipath, err := setApiPath(hosturi, "/v3/api/grant/update")
|
||||||
@@ -155,7 +155,7 @@ func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID uuid
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID uuid.UUID) error {
|
func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID uint64) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
apipath, err := setApiPath(hosturi, "/v3/api/grant/delete")
|
apipath, err := setApiPath(hosturi, "/v3/api/grant/delete")
|
||||||
@@ -186,7 +186,7 @@ func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID uuid
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID uuid.UUID) ([]descr.Grant, error) {
|
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID uint64) ([]descr.Grant, error) {
|
||||||
var err error
|
var err error
|
||||||
res := make([]descr.Grant, 0)
|
res := make([]descr.Grant, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -9,28 +9,25 @@
|
|||||||
*/
|
*/
|
||||||
package descr
|
package descr
|
||||||
|
|
||||||
import (
|
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
ID uuid.UUID `json:"id" db:"id"`
|
ID uint64 `json:"id" db:"id"`
|
||||||
Username string `json:"username" db:"username"`
|
Username string `json:"username" db:"username"`
|
||||||
Passhash string `json:"passhash" db:"passhash"`
|
Passhash string `json:"passhash" db:"passhash"`
|
||||||
Disabled bool `json:"disabled" db:"disabled"`
|
Disabled bool `json:"disabled" db:"disabled"`
|
||||||
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 uint64 `json:"createdBy" db:"created_by"`
|
||||||
UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"`
|
UpdatedBy uint64 `json:"updatedBy" db:"updated_by"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountShort struct {
|
type AccountShort struct {
|
||||||
ID uuid.UUID `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Disabled bool `json:"disabled"`
|
Disabled bool `json:"disabled"`
|
||||||
CreatedAt string `json:"createdAt"`
|
CreatedAt string `json:"createdAt"`
|
||||||
UpdatedAt string `json:"updatedAt"`
|
UpdatedAt string `json:"updatedAt"`
|
||||||
CreatedBy uuid.UUID `json:"createdBy"`
|
CreatedBy uint64 `json:"createdBy"`
|
||||||
UpdatedBy uuid.UUID `json:"updatedBy"`
|
UpdatedBy uint64 `json:"updatedBy"`
|
||||||
Grants []Grant `json:"grants"`
|
Grants []Grant `json:"grants"`
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-7
@@ -9,12 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package descr
|
package descr
|
||||||
|
|
||||||
import (
|
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Blob struct {
|
type Blob struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uint64 `db:"id" json:"id"`
|
||||||
Name string `db:"name" json:"name"`
|
Name string `db:"name" json:"name"`
|
||||||
Reference string `db:"reference" json:"reference"`
|
Reference string `db:"reference" json:"reference"`
|
||||||
MediaType string `db:"mediaType" json:"mediaType"`
|
MediaType string `db:"mediaType" json:"mediaType"`
|
||||||
@@ -22,6 +18,6 @@ type Blob struct {
|
|||||||
Size int64 `db:"size" json:"size"`
|
Size int64 `db:"size" json:"size"`
|
||||||
CreatedAt string `db:"created_at" json:"createdAt"`
|
CreatedAt string `db:"created_at" json:"createdAt"`
|
||||||
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
||||||
CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty"`
|
CreatedBy uint64 `db:"created_by" json:"createdBy,omitempty"`
|
||||||
UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
|
UpdatedBy uint64 `db:"updated_by" json:"updatedBy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-7
@@ -9,12 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package descr
|
package descr
|
||||||
|
|
||||||
import (
|
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
ID uuid.UUID `db:"id" json:"id,omitempty" yaml:"id,omitempty"`
|
ID uint64 `db:"id" json:"id,omitempty" yaml:"id,omitempty"`
|
||||||
Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"`
|
Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"`
|
||||||
Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"`
|
Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"`
|
||||||
Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"`
|
Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"`
|
||||||
@@ -22,6 +18,6 @@ type File struct {
|
|||||||
Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"`
|
Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"`
|
||||||
CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
|
CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
|
||||||
UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
|
UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
|
||||||
CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
|
CreatedBy uint64 `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
|
||||||
UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
|
UpdatedBy uint64 `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -12,16 +12,15 @@ package descr
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"mstore/pkg/term"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Grant struct {
|
type Grant struct {
|
||||||
ID uuid.UUID `json:"id" db:"id"`
|
ID uint64 `json:"id" db:"id"`
|
||||||
AccountID uuid.UUID `json:"accountID" db:"account_id"`
|
AccountID uint64 `json:"accountID" db:"account_id"`
|
||||||
Right term.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 uint64 `json:"createdBy" db:"created_by"`
|
||||||
UpdatedBy uuid.UUID `json:"updatedBy" db:"updated_by"`
|
UpdatedBy uint64 `json:"updatedBy" db:"updated_by"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package descr
|
package descr
|
||||||
|
|
||||||
import (
|
|
||||||
"mstore/pkg/uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Manifest struct {
|
type Manifest struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uint64 `db:"id" json:"id"`
|
||||||
Name string `db:"name" json:"name"`
|
Name string `db:"name" json:"name"`
|
||||||
Reference string `db:"reference" json:"reference"`
|
Reference string `db:"reference" json:"reference"`
|
||||||
ContentType string `db:"contentType" json:"contentType"`
|
ContentType string `db:"contentType" json:"contentType"`
|
||||||
@@ -22,8 +18,8 @@ type Manifest struct {
|
|||||||
Digest string `db:"digest" json:"digest"`
|
Digest string `db:"digest" json:"digest"`
|
||||||
CreatedAt string `db:"created_at" json:"createdAt"`
|
CreatedAt string `db:"created_at" json:"createdAt"`
|
||||||
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
UpdatedAt string `db:"updated_at" json:"updatedAt"`
|
||||||
CreatedBy uuid.UUID `db:"created_by" json:"createdBy,omitempty"`
|
CreatedBy uint64 `db:"created_by" json:"createdBy,omitempty"`
|
||||||
UpdatedBy uuid.UUID `db:"updated_by" json:"updatedBy,omitempty"`
|
UpdatedBy uint64 `db:"updated_by" json:"updatedBy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tags struct {
|
type Tags struct {
|
||||||
|
|||||||
+4
-4
@@ -11,7 +11,7 @@
|
|||||||
package term
|
package term
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mstore/pkg/uuid"
|
//"mstore/pkg/auxid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PathUsage string
|
type PathUsage string
|
||||||
@@ -24,11 +24,11 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AnonimousUsername string = "anonymous"
|
AnonimousUsername string = "anonymous"
|
||||||
AnonymousID uuid.UUID = "10000000-0000-0000-0000-000000000001"
|
AnonymousID uint64 = 1
|
||||||
ServerUsername string = "server"
|
ServerUsername string = "server"
|
||||||
ServerID uuid.UUID = "10000000-0000-0000-0000-000000000002"
|
ServerID uint64 = 2
|
||||||
InitUsername string = "mstore"
|
InitUsername string = "mstore"
|
||||||
InitID uuid.UUID = "10000000-0000-0000-0000-000000000005"
|
InitID uint64 = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
type Right string
|
type Right string
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import (
|
|||||||
|
|
||||||
"mstore/app/server"
|
"mstore/app/server"
|
||||||
"mstore/pkg/client"
|
"mstore/pkg/client"
|
||||||
"mstore/pkg/terms"
|
"mstore/pkg/term"
|
||||||
"mstore/pkg/uuid"
|
"mstore/pkg/auxid"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
username := "testuser"
|
username := "testuser"
|
||||||
password := "testpass"
|
password := "testpass"
|
||||||
|
|
||||||
var accountID uuid.UUID
|
var accountID uint64
|
||||||
{
|
{
|
||||||
// CreateAccount
|
// CreateAccount
|
||||||
fmt.Printf("=== CreateAccount ===\n")
|
fmt.Printf("=== CreateAccount ===\n")
|
||||||
@@ -92,7 +92,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
accountID, err = cli.CreateAccount(ctx, srvaddr, username, password)
|
accountID, err = cli.CreateAccount(ctx, srvaddr, username, password)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
var grantID uuid.UUID
|
var grantID uint64
|
||||||
{
|
{
|
||||||
// CreateGrant
|
// CreateGrant
|
||||||
fmt.Printf("=== CreateGrant ===\n")
|
fmt.Printf("=== CreateGrant ===\n")
|
||||||
@@ -100,7 +100,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
grantID, err = cli.CreateGrantByAccountID(ctx, srvaddr, accountID, terms.RightReadAccounts, ".*")
|
grantID, err = cli.CreateGrantByAccountID(ctx, srvaddr, accountID, term.RightReadAccounts, ".*")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, len(grantID), 36)
|
require.Equal(t, len(grantID), 36)
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ func TestAccountLife(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
grantID, err = cli.CreateGrantByAccountID(ctx, srvaddr, accountID, terms.RightWriteAccounts, ".*")
|
grantID, err = cli.CreateGrantByAccountID(ctx, srvaddr, accountID, term.RightWriteAccounts, ".*")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, len(grantID), 36)
|
require.Equal(t, len(grantID), 36)
|
||||||
fmt.Printf("grantID: %s\n", grantID)
|
fmt.Printf("grantID: %s\n", grantID)
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"mstore/app/server"
|
"mstore/app/server"
|
||||||
"mstore/pkg/client"
|
"mstore/pkg/client"
|
||||||
"mstore/pkg/terms"
|
"mstore/pkg/term"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -133,7 +133,7 @@ func TestFileLife(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
files, err := cli.ListFiles(ctx, srvaddr+"/", terms.AsFinePath)
|
files, err := cli.ListFiles(ctx, srvaddr+"/", term.AsFinePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotZero(t, len(files))
|
require.NotZero(t, len(files))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user