|
| 1 | +# Portainer setup with tsidp |
| 2 | + |
| 3 | +This doc will cover the OAuth configuration for Portainer using tsidp. If you want a guide on how to setup tsidp, you can check the [Proxmox](../proxmox/README.md) guide. |
| 4 | + |
| 5 | +## Configure Portainer to use tsidp |
| 6 | + |
| 7 | +This example assumes: |
| 8 | +- Portainer server: https://portainer.yourtailnet.ts.net:9443 |
| 9 | +- tsidp instance: https://idp.yourtailnet.ts.net |
| 10 | + |
| 11 | +> NOTE: This guide will use Portainer Business Edition, but the steps can be applied to the Community Edition as well. |
| 12 | +
|
| 13 | + |
| 14 | +### Add a new claim to the Tailscale Access Control |
| 15 | +1. **Visit** `https://login.tailscale.com/admin/acls/file` |
| 16 | +2. On the Policy JSON, inside the `tsidp` app, add the following `extraClaims` property: |
| 17 | +```json |
| 18 | +"extraClaims": { |
| 19 | + "groups": [ |
| 20 | + "group_1", |
| 21 | + "group_2", |
| 22 | + ... |
| 23 | + ] |
| 24 | +} |
| 25 | +``` |
| 26 | +It is reccomended to map the group names (`group_1`, `group_2`, ...) to groups inside Portainer to ease the setup process |
| 27 | +These groups can be created following the policies you already have configured on Tailscale. If you do not have any policies in place, you can create a single group called `admin` and link all the users to this group. |
| 28 | + |
| 29 | + |
| 30 | +### Register Portainer as a Client in tsidp |
| 31 | + |
| 32 | +1. **Visit** `https://idp.yourtailnet.ts.net` and click "Add New Client" |
| 33 | + |
| 34 | +  |
| 35 | + |
| 36 | +2. **Configure the client**: |
| 37 | + - Add redirect URIs for each way you access Proxmox |
| 38 | + - Save the generated Client ID and Client Secret; you'll use these next |
| 39 | + |
| 40 | +  |
| 41 | + |
| 42 | + |
| 43 | +### Configure the Groups to allow resource access |
| 44 | +1. Navigate to User-related → Teams |
| 45 | +2. Create a new team. You can call it whatever you want, but, to ease the configuration process, we will call it with the same name we configured on the [Add a new claim to the Tailscale Access Control](#add-a-new-claim-to-the-tailscale-access-control) step. |
| 46 | + |
| 47 | +  |
| 48 | + |
| 49 | +3. Go to **Environment-related** -> **Groups** -> on the `Unassigned` group, click on **Manage access** |
| 50 | +4. On the **Create access** section, select the group you just created and the role you want to associate to it. |
| 51 | +5. Click on **+ Create access** |
| 52 | + |
| 53 | +  |
| 54 | + |
| 55 | + |
| 56 | +### Configure OpenID Connect in Portainer |
| 57 | + |
| 58 | +1. **Navigate to** Settings → Authentication → **OAuth** |
| 59 | + |
| 60 | +  |
| 61 | + |
| 62 | +2. **Set the following options:** |
| 63 | + - **Use SSO**: Enabled |
| 64 | + - **Hide internal authentication prompt**: Enabled if you want to force SSO, otherwise, disabled. |
| 65 | + - **Automatic user provisioning**: Enabled |
| 66 | + - **Automatic team membership**: Enabled |
| 67 | + - **Claim name**: `groups` - the same we configured on [Add a new claim to the Tailscale Access Control](#add-a-new-claim-to-the-tailscale-access-control) |
| 68 | + - **Statically assigned teams**: click on the `add team mapping` button |
| 69 | + - **Claim value regex**: `admin` maps to `admin` team |
| 70 | + > This step should be repeated for all the groups created on the [Add a new claim to the Tailscale Access Control](#add-a-new-claim-to-the-tailscale-access-control). |
| 71 | + - **Default team**: No team |
| 72 | + - **Assign admin rights to group(s)**: Enabled |
| 73 | + - **claim value regex**: `admin` |
| 74 | + |
| 75 | +3. **Configure the Custom OAuth provider** with these settings: |
| 76 | + - **Client ID**: (from tsidp) |
| 77 | + - **Client Secret**: (from tsidp) |
| 78 | + - **Authorization URL**: `https://idp.yourtailnet.ts.net/authorize` |
| 79 | + - **Access token URL**: `https://idp.yourtailnet.ts.net/token` |
| 80 | + - **Resource URL**: `https://idp.yourtailnet.ts.net/userinfo` |
| 81 | + - **Redirect URL**: `https://portainer.yourtailnet.ts.net:9443` |
| 82 | + - **Logout URL**: Blank |
| 83 | + - **User identifier**: `username` |
| 84 | + - **Scopes**: `openid email profile` |
| 85 | + - **Auth style**: `Auto Detect` |
| 86 | + |
| 87 | +  |
| 88 | + |
| 89 | + |
| 90 | +### Test the Authentication |
| 91 | + |
| 92 | +1. **Open an incognito browser window** and navigate to `https://portainer.yourtailnet.ts.net:9443` |
| 93 | + |
| 94 | +2. **Log in with OAuth** |
| 95 | + - Authentication should work immediately |
| 96 | + - Portainer will auto-create a user account (due to "Automatic user provisioning: enabled") |
| 97 | + - You should be able to see all environments configured on your Portainer installation. |
| 98 | + |
| 99 | +  |
0 commit comments