Skip to content

Commit

Permalink
🐛 Do not assume principle is user
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHock committed Feb 1, 2023
1 parent 681c2bc commit 1263015
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,15 @@ func newKeyVersion(d []byte, s knox.VersionStatus) knox.KeyVersion {
}

// NewKey creates a new Key with correctly set defaults.
func newKey(id string, acl knox.ACL, d []byte, u knox.Principal) knox.Key {
func newKey(id string, acl knox.ACL, d []byte, principal knox.Principal) knox.Key {
key := knox.Key{}
key.ID = id

creatorAccess := knox.Access{ID: u.GetID(), AccessType: knox.Admin, Type: knox.User}
key.ACL = acl.Add(creatorAccess)
// If principal is a service, we will have already checked `acl` for a human user or group
if auth.IsUser(principal) {
creatorAccess := knox.Access{ID: principal.GetID(), AccessType: knox.Admin, Type: knox.User}
key.ACL = acl.Add(creatorAccess)
}
for _, a := range defaultAccess {
key.ACL = key.ACL.Add(a)
}
Expand Down

0 comments on commit 1263015

Please sign in to comment.