mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
re: #10528 Refactors PG Coordinator to work with the Tailnet v2 API, including wrappers for the existing v1 API. The debug endpoint functions, but doesn't return sensible data, that will be in another stacked PR.
31 lines
745 B
Go
31 lines
745 B
Go
package tailnet
|
|
|
|
import "github.com/google/uuid"
|
|
|
|
type TunnelAuth interface {
|
|
Authorize(dst uuid.UUID) bool
|
|
}
|
|
|
|
// SingleTailnetTunnelAuth allows all tunnels, since Coderd and wsproxy are allowed to initiate a tunnel to any agent
|
|
type SingleTailnetTunnelAuth struct{}
|
|
|
|
func (SingleTailnetTunnelAuth) Authorize(uuid.UUID) bool {
|
|
return true
|
|
}
|
|
|
|
// ClientTunnelAuth allows connecting to a single, given agent
|
|
type ClientTunnelAuth struct {
|
|
AgentID uuid.UUID
|
|
}
|
|
|
|
func (c ClientTunnelAuth) Authorize(dst uuid.UUID) bool {
|
|
return c.AgentID == dst
|
|
}
|
|
|
|
// AgentTunnelAuth disallows all tunnels, since agents are not allowed to initiate their own tunnels
|
|
type AgentTunnelAuth struct{}
|
|
|
|
func (AgentTunnelAuth) Authorize(uuid.UUID) bool {
|
|
return false
|
|
}
|