Skip to content

Commit

Permalink
Disallow brokers from returning users without groups
Browse files Browse the repository at this point in the history
The brokers used to be able to provide the userinfo without any group
associated to it. This creates difficulties when trying to manage the
user presence in the local groups. Now, the broker must provide at least
one group for the user and the first group must be a remote one (with
UGID).
  • Loading branch information
denisonbarbosa committed Dec 7, 2023
1 parent ca985a4 commit efbce02
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/brokers/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ func validateUserInfoAndGenerateIDs(brokerName string, rawMsg json.RawMessage) (
}
uInfo.UID = generateID(brokerName + uInfo.UUID)

// User must be a part of at least one group.
if len(uInfo.Groups) == 0 {
return users.UserInfo{}, fmt.Errorf("empty groups")
}
// The default group for the user is the default and it must have a UGID.
if uInfo.Groups[0].UGID == "" {
return users.UserInfo{}, fmt.Errorf("default group has empty UGID")
}
// Validate UGIDs and generate GIDs
for _, g := range uInfo.Groups {
if g.Name == "" {
Expand Down

0 comments on commit efbce02

Please sign in to comment.