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
+38 -101
View File
@@ -17,7 +17,7 @@ import (
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
"mstore/pkg/term"
"mstore/pkg/terms"
)
func (db *Database) WriteAnonymous(ctx context.Context) error {
@@ -27,14 +27,14 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
password := auxtool.RandomString(64)
passhash := auxpwd.MakeSHA256Hash([]byte(password))
accountDescr := &descr.Account{
ID: term.AnonymousID,
Username: term.AnonimousUsername,
ID: terms.AnonymousID,
Username: terms.AnonimousUsername,
Passhash: passhash,
Disabled: false,
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertAccount(ctx, accountDescr)
if err != nil {
@@ -43,12 +43,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
grantDescr := &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightReadFiles,
Right: terms.RightReadFiles,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -57,12 +57,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightReadImages,
Right: terms.RightReadImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -76,107 +76,44 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
func (db *Database) WriteInituser(ctx context.Context) error {
var err error
now := auxtool.TimeNow()
passhash := auxpwd.MakeSHA256Hash([]byte(term.InitUsername))
passhash := auxpwd.MakeSHA256Hash([]byte(terms.InitUsername))
accountDescr := &descr.Account{
ID: term.InitID,
Username: term.InitUsername,
ID: terms.InitID,
Username: terms.InitUsername,
Passhash: passhash,
Disabled: false,
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertAccount(ctx, accountDescr)
if err != nil {
return err
}
// Files
grantDescr := &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightReadFiles,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
fullRights := []string{
terms.RightWriteAccounts,
terms.RightReadAccounts,
terms.RightWriteFiles,
terms.RightReadFiles,
terms.RightWriteImages,
terms.RightReadImages,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
return err
}
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightWriteFiles,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
return err
}
// Accounts
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightReadAccounts,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
return err
}
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightWriteAccounts,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
return err
}
// Images
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightReadImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
return err
}
grantDescr = &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: term.RightWriteImages,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: term.ServerID,
UpdatedBy: term.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
return err
for _, right := range fullRights {
grantDescr := &descr.Grant{
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
Right: right,
Pattern: ".*",
CreatedAt: now,
UpdatedAt: now,
CreatedBy: terms.ServerID,
UpdatedBy: terms.ServerID,
}
err = db.InsertGrant(ctx, grantDescr)
if err != nil {
return err
}
}
return err