mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-27 00:36:49 +09:00
policy/v2: revoke stale SSH access and recheck authentication
Updates #3517, #3508
(cherry picked from commit 4fd4da75f2)
This commit is contained in:
1 parent
00f670213a
commit
5fb2d4e089
21 files changed
+1202
-121
No files matched your search
@@ -1171,12 +1171,13 @@ func (s *State) SSHPolicy(node types.NodeView) (*tailcfg.SSHPolicy, error) {
|
||||
return s.polMan.SSHPolicy(s.cfg.ServerURL, node)
|
||||
}
|
||||
|
||||
// SSHCheckParams resolves the SSH check period for a source-destination
|
||||
// node pair from the current policy.
|
||||
// SSHCheckParams resolves the SSH check period for src logging in to dst
|
||||
// as localUser from the current policy.
|
||||
func (s *State) SSHCheckParams(
|
||||
srcNodeID, dstNodeID types.NodeID,
|
||||
localUser string,
|
||||
) (time.Duration, bool) {
|
||||
return s.polMan.SSHCheckParams(srcNodeID, dstNodeID)
|
||||
return s.polMan.SSHCheckParams(srcNodeID, dstNodeID, localUser)
|
||||
}
|
||||
|
||||
// Filter returns the current network filter rules and matches.
|
||||
@@ -1524,6 +1525,21 @@ func (s *State) DeleteNodeFromStoreForTest(id types.NodeID) {
|
||||
s.nodeStore.DeleteNode(id)
|
||||
}
|
||||
|
||||
// WrapPolicyManagerForTest replaces the policy manager with wrap(current) so
|
||||
// tests can fail a single method. The [NodeStore] keeps the original manager,
|
||||
// so wrap must delegate to its argument. Call before any map is served.
|
||||
func (s *State) WrapPolicyManagerForTest(wrap func(policy.PolicyManager) policy.PolicyManager) {
|
||||
s.polMan = wrap(s.polMan)
|
||||
}
|
||||
|
||||
// UpdatePolicyManagerNodesForTest syncs the policy manager with the
|
||||
// [NodeStore], for tests that stage nodes with [State.PutNodeInStoreForTest].
|
||||
func (s *State) UpdatePolicyManagerNodesForTest() error {
|
||||
_, err := s.polMan.SetNodes(s.ListNodes())
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// CreateRegisteredNodeForTest creates a test node with allocated IPs. This is a convenience wrapper around the database layer.
|
||||
func (s *State) CreateRegisteredNodeForTest(user *types.User, hostname ...string) *types.Node {
|
||||
return s.db.CreateRegisteredNodeForTest(user, hostname...)
|
||||
|
||||
Reference in new issue
Block a user