Resolve user to stable unique ID in policy (#2205)

This commit is contained in:
Kristoffer Dalby 2024-11-24 00:13:27 +01:00 committed by GitHub
parent 3a2589f1a9
commit fffd23602b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 506 additions and 144 deletions

View file

@ -648,8 +648,13 @@ func EnableAutoApprovedRoutes(
if approvedAlias == node.User.Username() {
approvedRoutes = append(approvedRoutes, advertisedRoute)
} else {
users, err := ListUsers(tx)
if err != nil {
return fmt.Errorf("looking up users to expand route alias: %w", err)
}
// TODO(kradalby): figure out how to get this to depend on less stuff
approvedIps, err := aclPolicy.ExpandAlias(types.Nodes{node}, approvedAlias)
approvedIps, err := aclPolicy.ExpandAlias(types.Nodes{node}, users, approvedAlias)
if err != nil {
return fmt.Errorf("expanding alias %q for autoApprovers: %w", approvedAlias, err)
}