Skip to content

[Feature] Add option to expire node on disconnect #2494

@dmeremyanin

Description

@dmeremyanin

Use case

We want to enforce user authentication on every connection attempt to ensure 2FA is used each time. We've configured an OIDC provider (Authentik) for this purpose, but currently, Headscale doesn't require re-authentication unless the node is expired.

Setting a shorter expiration time (e.g., 1 hour) isn't ideal, as it forces Tailscale to disconnect frequently, interrupting user access. We need a solution that ensures authentication on each connection attempt without forcing disconnections every few hours.

Description

This feature enforces stricter authentication by expiring the node upon disconnection. When enabled, it ensures that users must re-authenticate via the OIDC provider on the next connection attempt, requiring 2FA each time.

Contribution

  • I can write the design doc for this feature
  • I can contribute this feature

How can it be implemented?

I propose adding a new configuration option, expire_node_on_disconnect, which will be disabled by default to preserve current behavior. When enabled, the node will expire upon disconnection, and users will be prompted to re-authenticate on the next connection attempt.

The expiration can be implemented in the updateNodeOnlineStatus function here:

headscale/hscontrol/poll.go

Lines 404 to 410 in 707438f

if !online {
now := time.Now()
// lastSeen is only relevant if the node is disconnected.
node.LastSeen = &now
change.LastSeen = &now
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions