tsidp

repository·main·Indexed 20 days ago

https://github.com/tailscale/tsidp

An identity provider (IdP) and verifier designed for Tailscale networks. It enables secure authentication via OpenID Connect (OIDC) for services such as Proxmox and supports the MCP Gateway Pattern using Dynamic Client Registration (RFC 7591) and OAuth 2.0 Token Exchange (RFC 8693). The project includes a verifier tool for testing Security Token Server (STS) implementations and OIDC flows.

Tokens
5.1K
Snippets
20
Records
29
Agent score
70%

What's inside tsidp

  1. How the MCP Gateway Pattern works with tsidp

    main

    The MCP Gateway Pattern uses tsidp to secure communication between an MCP client, a gateway, and a server using Dynamic Client Registration (RFC 7591) and OAuth 2.0 Token Exchange (RFC 8693).

    The Workflow:

    1. Client Registration: The MCP client registers as an OAuth client with tsidp.
    2. User Authorization: The client requests the user to authorize access to the MCP gateway.
    3. Gateway Registration: The MCP gateway also registers as an OAuth client with tsidp.
    4. Token Exchange: Instead of authorizing the user directly, the gateway takes the token presented by the client (where the gateway was the original audience) and exchanges it for a new token where the MCP server is the audience.
    5. Server Validation: The MCP server registers with tsidp to perform token introspection, ensuring the token is valid and specifically lists the MCP server as the audience.
    6. Connection: Once validated, the MCP server initiates the connection back to the gateway and the client.
  2. Register Proxmox as a Client in tsidp

    main

    Before configuring Proxmox, you must register it as an OIDC client within the tsidp web interface:

    1. Navigate to your tsidp instance URL (e.g., https://idp.yourtailnet.ts.net).
    2. Click Add New Client.
    3. Configure the client by adding the Redirect URIs used to access your Proxmox server.
    4. Save and record the generated Client ID and Client Secret; these are required for the Proxmox OpenID Connect configuration.
  3. Create an LXC for tsidp

    main

    To host tsidp in Docker, create a new LXC in Proxmox with the following specific configuration:

    • General: Enable "Unprivileged container" and enable "Nesting" (required for Docker).
    • Template: Use alpine-3.21-default_20241217_amd64.tar.xz (or similar).
    • Disks: 4 GiB.
    • CPU: 1 Core.
    • Memory: 512 MiB RAM + 512 MiB Swap.
    • Note: Do not enable keyctl=1 as tsidp does not require Docker secrets.
  4. Configure Auto-start for tsidp

    main

    To ensure the identity provider survives reboots, configure both the Docker container and the LXC to start automatically:

    1. Docker: Set the container to restart unless stopped:

      docker update --restart unless-stopped tsidp
    2. Proxmox LXC: In the Proxmox UI, select the container, go to Options $\rightarrow$ Start at boot, and set it to Yes.

    docker update --restart unless-stopped tsidp
  5. Assign User Permissions to tsidp Users in Proxmox

    main

    Because Autocreate Users is enabled, tsidp users will be created in Proxmox automatically upon their first login, but they will have no permissions by default. To grant access:

    1. Create a Group: Go to Datacenter $\rightarrow$ Permissions $\rightarrow$ Groups and create a group (e.g., tsadmins).
    2. Grant Permissions: Go to Datacenter $\rightarrow$ Permissions. Add a Group Permission:
      • Path: /
      • Group: tsadmins
      • Role: Administrator
    3. Assign Users: Go to Datacenter $\rightarrow$ Permissions $\rightarrow$ Users, edit the auto-created user, and add them to the tsadmins group.
  6. Configure application grants for STS testing

    main

    To test the Security Token Server (STS) in tsidp, you must ensure an application grant is configured. For testing and development purposes, you can use a highly permissive grant that allows all sources, destinations, IPs, users, and resources for the tailscale.com/cap/tsidp capability.

    "grants": [
      {
        "src": ["*"],
        "dst": ["*"],
        "ip":  ["*"],
    
        "app": {
          "tailscale.com/cap/tsidp": [
            {
              "users":     ["*"],
              "resources": ["*"]
            }
          ]
        }
      }
    ]
  7. Run tsidp using Docker

    main

    To run the tsidp server for the MCP gateway demo, use the following Docker command. This setup enables STS (Security Token Service) and dynamic client registration.

    $ docker run -it --rm --name tsidp \
      -v tsidp-mcp-gateway-demo:/data \
      -e TS_STATE_DIR=/data \
      -e TS_HOSTNAME=tsidp-mcp-gateway-demo \
      -e TSIDP_ENABLE_STS=1 \
      -e TAILSCALE_USE_WIP_CODE=1 \
      -e TSIDP_LOG=debug ghcr.io/tailscale/tsidp:latest
  8. Test the MCP server using the MCP Inspector

    main

    To verify the server, use the MCP inspector. Due to known bugs in newer versions, it is recommended to use version 0.16.3 as of late 2025.

    Authorization Flow

    1. Set the transport type to Streamable HTTP.
    2. Set the URL to http://localhost:9933.
    3. Click Open Auth Settings.
    4. Click Quick OAuth Flow and verify all checks pass.

    Tool Execution

    1. Click Connect.
    2. Click List tools to see available capabilities.
    3. Execute a tool call to verify end-to-end functionality.
    npx @modelcontextprotocol/inspector@0.16.3
  9. Install Docker and tsidp in an Alpine LXC

    main

    After creating and starting the LXC, access the console as root and run the following commands to set up the environment:

    1. Install dependencies:

      apk update
      apk add docker git
    2. Start Docker service:

      rc-service docker start
      rc-update add docker boot
    3. Clone the repository:

      mkdir -p /usr/local/src && cd /usr/local/src
      git clone https://github.com/tailscale/tsidp.git
    4. Build and run: Follow the project's main README instructions to launch tsidp via Docker.

    apk update
    apk add docker git
    rc-service docker start
    rc-update add docker boot
    mkdir -p /usr/local/src && cd /usr/local/src
    git clone https://github.com/tailscale/tsidp.git
  10. Run tsidp via Docker

    main

    To use the MCP server example, you must first have tsidp running. If you are using Docker, you can start the service with the following command. Ensure you replace YOUR_TAILSCALE_AUTHKEY with a valid Tailscale authentication key.

    Note that the container uses a volume tsidp-data to persist data at /var/lib/tsidp and sets the hostname to idp.

    docker run -d \
      --name tsidp \
      -p 443:443 \
      -e TS_AUTHKEY=YOUR_TAILSCALE_AUTHKEY \
      -e TSNET_FORCE_LOGIN=1 \
      -e TAILSCALE_USE_WIP_CODE=1 \
      -v tsidp-data:/var/lib/tsidp \
      tsidp --hostname=idp --dir=/var/lib/tsidp
  11. Configure Tailscale ACLs for tsidp resource indicators

    main

    MCP requires the use of resource indicators. You must add an ACL application grant to your tailnet to allow users or devices to specify resources in their requests.

    For testing purposes, you can use the following permissive rule which allows any user/device to request any resource. For production, replace the "*" in resources with your specific resource URI (e.g., http://localhost:9933).

    {
      "src": ["*"],
      "dst": ["*"],
      "app": {
        "tailscale.com/cap/tsidp": [
          {
            "users":     ["*"],
            "resources": ["*"],
          },
        ],
      },
    }