working commit

This commit is contained in:
2026-02-21 13:16:30 +02:00
parent cd37a4508c
commit d650d58a6d
1149 changed files with 116 additions and 722633 deletions
+9 -15
View File
@@ -17,7 +17,7 @@ import (
"mstore/app/router"
"mstore/pkg/auxhttp"
"mstore/pkg/auxpwd"
"mstore/pkg/term"
"mstore/pkg/terms"
)
const (
@@ -50,7 +50,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, string, error) {
var password string
var accountID string
accountID = term.AnonymousID
accountID = terms.AnonymousID
authHeader := rctx.GetHeader("Authorization")
if authHeader != "" {
@@ -75,7 +75,7 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, string, error) {
}
anonymous:
success = true
accountID = term.AnonymousID
accountID = terms.AnonymousID
return success, accountID, err
}
@@ -104,14 +104,7 @@ func (hand *Handler) ValidatePassword(ctx context.Context, username, password st
func (hand *Handler) CheckRight(ctx context.Context, accountID, reqRight, subject string) (bool, error) {
var err error
var res bool
//hand.logg.Debugf("Cop check your right %s: %s %s", accountID, reqRight, subject)
// =[]=
// .------. ---
// .---[-] [#] \--, ---
// >| [ ] [ ] | ---...
// '--0-------0----'
// Bad news for you, baby.... #
//
hand.logg.Debugf("Check right %s: right=%s subj=%s", accountID, reqRight, subject)
exists, grants, err := hand.mdb.ListGrantsByAccoundIDRight(ctx, accountID, reqRight)
if err != nil {
return res, err
@@ -120,11 +113,13 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID, reqRight, subjec
return res, err
}
switch reqRight {
case term.RightReadFiles, term.RightWriteFiles:
case terms.RightReadFiles, terms.RightWriteFiles, terms.RightReadImages, terms.RightWriteImages:
for _, grant := range grants {
hand.logg.Debugf("Grant pattern=[%s], subject=[%s]", grant.Pattern, subject)
re, err := regexp.Compile(grant.Pattern)
if err != nil {
hand.logg.Warningf("Wrong pattern %s for grant %s: %v", grant.Pattern, grant.ID, err)
hand.logg.Warningf("Wrong regexp %s for grant %s: %v", grant.Pattern, grant.ID, err)
err = nil
continue
}
@@ -134,8 +129,7 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID, reqRight, subjec
}
}
default:
// NOP
res = true
}
res = true
return res, err
}