Skip to content

Commit cf13e40

Browse files
committed
peer identity update, help in dynamic group updates
1 parent 4b514ca commit cf13e40

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

client/internal/engine.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,11 @@ func (e *Engine) modifyPeers(peersUpdate []*mgmProto.RemotePeerConfig) error {
662662
if err := e.statusRecorder.UpdatePeerFQDN(peerPubKey, p.GetFqdn()); err != nil {
663663
log.Warnf("error updating peer's %s fqdn in the status recorder, got error: %v", peerPubKey, err)
664664
}
665+
666+
// Update peer identity (groups/userId) for K8s Auth Proxy impersonation
667+
if err := e.statusRecorder.UpdatePeerIdentity(peerPubKey, p.GetGroups(), p.GetUserId()); err != nil {
668+
log.Warnf("error updating peer's %s identity in the status recorder, got error: %v", peerPubKey, err)
669+
}
665670
}
666671

667672
// second, close all modified connections and remove them from the state map

client/internal/peer/status.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,24 @@ func (d *Status) UpdatePeerFQDN(peerPubKey, fqdn string) error {
606606
return nil
607607
}
608608

609+
// UpdatePeerIdentity updates peer's groups and userId for K8s Auth Proxy impersonation.
610+
// This is called when the management server sends updated peer config.
611+
func (d *Status) UpdatePeerIdentity(peerPubKey string, groups []string, userId string) error {
612+
d.mux.Lock()
613+
defer d.mux.Unlock()
614+
615+
peerState, ok := d.peers[peerPubKey]
616+
if !ok {
617+
return errors.New("peer doesn't exist")
618+
}
619+
620+
peerState.Groups = groups
621+
peerState.UserId = userId
622+
d.peers[peerPubKey] = peerState
623+
624+
return nil
625+
}
626+
609627
// UpdatePeerSSHHostKey updates peer's SSH host key
610628
func (d *Status) UpdatePeerSSHHostKey(peerPubKey string, sshHostKey []byte) error {
611629
d.mux.Lock()

0 commit comments

Comments
 (0)