client/web: add self node cache

Adds a cached self node to the web client Server struct, which will
be used from the web client api to verify that request came from the
node's own machine (i.e. came from the web client frontend). We'll
be using when we switch the web client api over to acting as a proxy
to the localapi, to protect against DNS rebinding attacks.

Updates tailscale/corp#13775

Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
This commit is contained in:
Sonia Appasamy
2023-08-24 16:24:57 -04:00
committed by Sonia Appasamy
parent 3b7ebeba2e
commit f3077c6ab5
3 changed files with 80 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
package main
import (
"context"
"flag"
"log"
"net/http"
@@ -20,6 +21,7 @@ var (
func main() {
flag.Parse()
ctx := context.Background()
s := new(tsnet.Server)
defer s.Close()
@@ -30,7 +32,7 @@ func main() {
}
// Serve the Tailscale web client.
ws, cleanup := web.NewServer(web.ServerOpts{
ws, cleanup := web.NewServer(ctx, web.ServerOpts{
DevMode: *devMode,
LocalClient: lc,
})