Skip to content

Commit

Permalink
Merge pull request #285 from jaredbischof/master
Browse files Browse the repository at this point in the history
Bug fixes for AWE with auth.
  • Loading branch information
jaredbischof committed Aug 26, 2014
2 parents 5b978f4 + 3dadf34 commit ec3174d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.3
0.9.4
2 changes: 1 addition & 1 deletion lib/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func init() {
// Admin
if admin_users, err := c.String("Admin", "users"); err == nil {
for _, name := range strings.Split(admin_users, ",") {
Admin_Users[name] = true
Admin_Users[strings.TrimSpace(name)] = true
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/controller/jobController.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (cr *JobController) ReadMany(cx *goweb.Context) {

// Add authorization checking to query if the user is not an admin
if u.Admin == false {
q["$or"] = []bson.M{bson.M{"acl.read": "public"}, bson.M{"acl.read": u.Uuid}, bson.M{"acl.owner": u.Uuid}}
q["$or"] = []bson.M{bson.M{"acl.read": "public"}, bson.M{"acl.read": u.Uuid}, bson.M{"acl.owner": u.Uuid}, bson.M{"acl": bson.M{"$exists": "false"}}}
}

limit := conf.DEFAULT_PAGE_SIZE
Expand Down
21 changes: 10 additions & 11 deletions lib/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ func Initialize() (err error) {
// This config parameter contains a string that should be a comma-separated list of users that are Admins.
for k, _ := range conf.Admin_Users {
if k != "" {
if err = c.Update(bson.M{"username": k}, bson.M{"$set": bson.M{"admin": true}}); err != nil {
if err.Error() == "not found" {
u := User{Username: k}
if err = u.SetMongoInfo(); err != nil {
return err
}
if err = c.Update(bson.M{"username": k}, bson.M{"$set": bson.M{"admin": true}}); err != nil {
return err
}
} else {
if info, err := c.UpdateAll(bson.M{"username": k}, bson.M{"$set": bson.M{"admin": true}}); err != nil {
return err
} else if info.Updated == 0 {
u, err := New(k, "", true)
if err != nil {
return err
}
if err := u.Save(); err != nil {
return err
}
}
Expand Down Expand Up @@ -127,5 +125,6 @@ func (u *User) Save() (err error) {
session := db.Connection.Session.Copy()
defer session.Close()
c := session.DB(conf.MONGODB_DATABASE).C("Users")
return c.Insert(&u)
_, err = c.Upsert(bson.M{"uuid": u.Uuid}, &u)
return
}

0 comments on commit ec3174d

Please sign in to comment.