Skip to content

Commit

Permalink
[v14] Fix Access List Members cache and eventing. (#32649)
Browse files Browse the repository at this point in the history
* Fix Access List Members cache and eventing.

Two things were happening that were shadowing the Access List members cache
and eventing.

1. In the cache collections, the wrong reader was being assigned to the
   lookup map. The correct reader was being used elsewhere, however, so the
   caching tests appear to have still been working.
2. The watcher in lib/services/local/events.go apparently collapses prefixes
   if they overlap. Prefix `access_list_members` is encompassed by
   `access_list`, so the access list members prefix was eliminated from the
   watcher. As a result, access list member events were being processed by
   the access list parser, which resulted in non-critical warnings.

Local testing and dogfooding has yielded that this has had no apparent impact,
at least in situations without cache propagation. However, I've got a feeling
that this could affect situations with multiple auth servers.

While I'm here, I've eliminated the pointer-to-pointer logic in the access
list unmarshaling, which was excised elsewhere and should be excised here as
well.

* Use ExactKey, fix accessListMemberParser as well.
  • Loading branch information
mdwn committed Sep 27, 2023
1 parent 707072e commit 02148e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/cache/collections.go
Expand Up @@ -615,7 +615,7 @@ func setupCollections(c *Cache, watches []types.WatchKind) (*cacheCollections, e
return nil, trace.BadParameter("missing parameter AccessLists")
}
collections.accessListMembers = &genericCollection[*accesslist.AccessListMember, services.AccessListMembersGetter, accessListMembersExecutor]{cache: c, watch: watch}
collections.byKind[resourceKind] = collections.accessLists
collections.byKind[resourceKind] = collections.accessListMembers
default:
return nil, trace.BadParameter("resource %q is not supported", watch.Kind)
}
Expand Down
8 changes: 4 additions & 4 deletions lib/services/access_list.go
Expand Up @@ -86,7 +86,7 @@ func UnmarshalAccessList(data []byte, opts ...MarshalOption) (*accesslist.Access
if err != nil {
return nil, trace.Wrap(err)
}
var accessList *accesslist.AccessList
var accessList accesslist.AccessList
if err := utils.FastUnmarshal(data, &accessList); err != nil {
return nil, trace.BadParameter(err.Error())
}
Expand All @@ -99,7 +99,7 @@ func UnmarshalAccessList(data []byte, opts ...MarshalOption) (*accesslist.Access
if !cfg.Expires.IsZero() {
accessList.SetExpiry(cfg.Expires)
}
return accessList, nil
return &accessList, nil
}

// AccessListMembersGetter defines an interface for reading access list members.
Expand Down Expand Up @@ -152,7 +152,7 @@ func UnmarshalAccessListMember(data []byte, opts ...MarshalOption) (*accesslist.
if err != nil {
return nil, trace.Wrap(err)
}
var member *accesslist.AccessListMember
var member accesslist.AccessListMember
if err := utils.FastUnmarshal(data, &member); err != nil {
return nil, trace.BadParameter(err.Error())
}
Expand All @@ -165,7 +165,7 @@ func UnmarshalAccessListMember(data []byte, opts ...MarshalOption) (*accesslist.
if !cfg.Expires.IsZero() {
member.SetExpiry(cfg.Expires)
}
return member, nil
return &member, nil
}

// IsAccessListOwner will return true if the user is an owner for the current list.
Expand Down
4 changes: 2 additions & 2 deletions lib/services/local/events.go
Expand Up @@ -1603,7 +1603,7 @@ func (p *headlessAuthenticationParser) parse(event backend.Event) (types.Resourc

func newAccessListParser() *accessListParser {
return &accessListParser{
baseParser: newBaseParser(backend.Key(accessListPrefix)),
baseParser: newBaseParser(backend.ExactKey(accessListPrefix)),
}
}

Expand Down Expand Up @@ -1651,7 +1651,7 @@ func (p *userLoginStateParser) parse(event backend.Event) (types.Resource, error

func newAccessListMemberParser() *accessListMemberParser {
return &accessListMemberParser{
baseParser: newBaseParser(backend.Key(accessListMemberPrefix)),
baseParser: newBaseParser(backend.ExactKey(accessListMemberPrefix)),
}
}

Expand Down

0 comments on commit 02148e8

Please sign in to comment.