working commit
This commit is contained in:
+22
-13
@@ -34,18 +34,20 @@ type Storage struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Service Service `json:"service" yaml:"service"`
|
||||
Database Database `json:"database" yaml:"database"`
|
||||
Storage Storage `json:"storage" yaml:"storage"`
|
||||
AsDaemon bool `json:"asDaemon" yaml:"asDaemon"`
|
||||
Logpath string `json:"logpath" yaml:"logpath"`
|
||||
Runpath string `json:"runpath" yaml:"runpath"`
|
||||
Version string `json:"version" yaml:"version"`
|
||||
Certpath string `json:"certpath,omitempty" yaml:"certpath,omitempty"`
|
||||
Keypath string `json:"keypath,omitempty" yaml:"keypath,omitempty"`
|
||||
X509Cert string `json:"-" yaml:"-"`
|
||||
X509Key string `json:"-" yaml:"-"`
|
||||
Datadir string `json:"datadir" yaml:datadir`
|
||||
Service Service `json:"service" yaml:"service"`
|
||||
Database Database `json:"database" yaml:"database"`
|
||||
Storage Storage `json:"storage" yaml:"storage"`
|
||||
AsDaemon bool `json:"asDaemon" yaml:"asDaemon"`
|
||||
Logpath string `json:"logpath" yaml:"logpath"`
|
||||
Runpath string `json:"runpath" yaml:"runpath"`
|
||||
Version string `json:"version" yaml:"version"`
|
||||
Certpath string `json:"certpath,omitempty" yaml:"certpath,omitempty"`
|
||||
Keypath string `json:"keypath,omitempty" yaml:"keypath,omitempty"`
|
||||
X509Cert string `json:"-" yaml:"-"`
|
||||
X509Key string `json:"-" yaml:"-"`
|
||||
Datadir string `json:"datadir" yaml:datadir`
|
||||
Hostname string `json:"hostname" yaml:hostname`
|
||||
Hostnames []string `json:"hostnames" yaml:hostnames`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
@@ -79,6 +81,7 @@ func NewConfig() *Config {
|
||||
Datadir: datadir,
|
||||
//Certpath: certpath,
|
||||
//Keypath: keypath,
|
||||
Hostnames: make([]string, 0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +141,13 @@ func (conf *Config) ReadX509Cert() error {
|
||||
}
|
||||
*/
|
||||
if conf.X509Cert == "" || conf.X509Key == "" {
|
||||
certBytes, keyBytes, err := auxx509.CreateSelfSignedCert("localhost")
|
||||
if conf.Hostname == "" {
|
||||
conf.Hostname, err = os.Hostname()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
certBytes, keyBytes, err := auxx509.CreateSelfSignedCert(conf.Hostname, conf.Hostnames...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -106,7 +106,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("Check right %s: right=%s subj=%s", accountID, reqRight, subject)
|
||||
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
|
||||
@@ -117,7 +117,7 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID, reqRight, subjec
|
||||
switch reqRight {
|
||||
case terms.RightReadFiles, terms.RightWriteFiles, terms.RightReadImages, terms.RightWriteImages:
|
||||
for _, grant := range grants {
|
||||
hand.logg.Debugf("Grant pattern=[%s], subject=[%s]", grant.Pattern, subject)
|
||||
//hand.logg.Debugf("Grant accountID=[%s] pattern=[%s], subject=[%s]", accountID, grant.Pattern, subject)
|
||||
|
||||
re, err := regexp.Compile(grant.Pattern)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user