working commit

This commit is contained in:
2026-02-15 12:25:09 +02:00
parent af44293195
commit 15a3379e5c
8 changed files with 22 additions and 23 deletions
+9 -6
View File
@@ -109,20 +109,23 @@ func (conf *Config) ReadOptions() error {
// TODO: make local scope of flags
//flag.Int64Var(&conf.Service.Port, "port", conf.Service.Port, "listen port")
//flag.BoolVar(&conf.AsDaemon, "daemon", conf.AsDaemon, "run as daemon")
flagSet := flag.NewFlagSet(exename, flag.ExitOnError)
flagSet.Int64Var(&conf.Service.Port, "port", conf.Service.Port, "listen port")
flagSet.BoolVar(&conf.AsDaemon, "daemon", conf.AsDaemon, "run as daemon")
help := func() {
fmt.Println("")
fmt.Printf("Usage: %s [option]\n", exename)
fmt.Println("")
fmt.Println("Options:")
flag.PrintDefaults()
flagSet.PrintDefaults()
fmt.Println("")
}
flag.Usage = help
flag.Parse()
flagSet.Usage = help
args := flag.Args()
if len(args) > 1 {
flagSet.Parse(args)
}
return err
}
+1 -4
View File
@@ -32,12 +32,9 @@ type Grant struct {
}
const (
// Accounts
// Accounts, grants
RightReadAccounts = "readAccounts" // GetAccount, ListAccounts
RightWriteAccounts = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
// Frants
RightReadGrants = "readGrants" // Like account operation
RightWriteGrants = "writeGrants"
// Files
RightWriteFiles = "writeFiles" // FileInfo, GetFile, ListFiles
RightReadFiles = "readFiles" // PutFile, DeleteFile
+5 -5
View File
@@ -29,7 +29,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteGrants, "")
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
@@ -62,7 +62,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadGrants, "")
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadAccounts, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
@@ -95,7 +95,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadGrants, "")
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadAccounts, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
@@ -128,7 +128,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteGrants, "")
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
@@ -161,7 +161,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) {
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteGrants, "")
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
+3 -3
View File
@@ -148,11 +148,11 @@ func (db *Database) WriteInituser(ctx context.Context) error {
if err != nil {
return err
}
// Grants
// Images
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightReadGrants,
Right: descr.RightReadImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
@@ -166,7 +166,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: descr.RightWriteGrants,
Right: descr.RightWriteImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,