|
| 1 | +# Configuring authentication with OIDC |
| 2 | + |
| 3 | +While ionscale can operate without an OIDC (OpenID Connect) provider using only static keys, configuring an OIDC provider is highly recommended for enhanced security, user management, and a smoother administrative experience. |
| 4 | + |
| 5 | +## Why configure an OIDC provider? |
| 6 | + |
| 7 | +Without an OIDC provider, ionscale operates in a key-only mode: |
| 8 | + |
| 9 | +- System administrators can only use the system admin key for administrative tasks |
| 10 | +- Tailscale devices can only connect using [tags](https://tailscale.com/kb/1068/tags) and [pre-authentication keys](https://tailscale.com/kb/1085/auth-keys) |
| 11 | +- No user accounts or user-specific permissions are available |
| 12 | + |
| 13 | +With an OIDC provider configured: |
| 14 | + |
| 15 | +- Users can authenticate using their existing identity provider credentials |
| 16 | +- Administrators can assign specific permissions to users |
| 17 | +- System administration can be delegated to specific users |
| 18 | +- Fine-grained access control based on user identity becomes possible |
| 19 | +- More seamless user experience with browser-based authentication |
| 20 | + |
| 21 | +## Supported OIDC providers |
| 22 | + |
| 23 | +ionscale supports any standard OIDC provider, including: |
| 24 | + |
| 25 | +- Google Workspace |
| 26 | +- Auth0 |
| 27 | +- Okta |
| 28 | +- Azure AD / Microsoft Entra ID |
| 29 | +- Keycloak |
| 30 | +- GitLab |
| 31 | +- GitHub (OAuth 2.0 with OIDC extensions) |
| 32 | +- And many others |
| 33 | + |
| 34 | +## Basic OIDC configuration |
| 35 | + |
| 36 | +To configure an OIDC provider, update your ionscale configuration file (`config.yaml`) with the following settings: |
| 37 | + |
| 38 | +```yaml |
| 39 | +auth: |
| 40 | + provider: |
| 41 | + # OIDC issuer URL where ionscale can find the OpenID Provider Configuration Document |
| 42 | + issuer: "https://your-oidc-provider.com" |
| 43 | + # OIDC client ID and secret |
| 44 | + client_id: "your-client-id" |
| 45 | + client_secret: "your-client-secret" |
| 46 | + # Optional: additional OIDC scopes used in the OIDC flow |
| 47 | + additional_scopes: "groups" |
| 48 | +``` |
| 49 | +
|
| 50 | +### Required configuration fields |
| 51 | +
|
| 52 | +- `issuer`: The URL to your OIDC provider's issuer. This URL is used to discover your provider's endpoints. |
| 53 | +- `client_id`: The client ID from your OIDC provider application registration. |
| 54 | +- `client_secret`: The client secret from your OIDC provider application registration. |
| 55 | + |
| 56 | +### Optional configuration |
| 57 | + |
| 58 | +- `additional_scopes`: A space-separated list of additional OAuth scopes to request during authentication. |
| 59 | + By default, ionscale requests the `openid`, `email`, and `profile` scopes. |
| 60 | + |
| 61 | +## Configuring your OIDC provider |
| 62 | + |
| 63 | +When registering ionscale with your OIDC provider, you'll need to configure the following: |
| 64 | + |
| 65 | +**Redirect URI**: Set to `https://your-ionscale-domain.com/auth/callback` |
| 66 | + |
| 67 | +## System administrator access |
| 68 | + |
| 69 | +With OIDC configured, you'll want to specify which users have system administrator privileges. |
| 70 | +This is done in the `auth.system_admins` section of your configuration: |
| 71 | + |
| 72 | +```yaml |
| 73 | +auth: |
| 74 | + # Configuration from previous section... |
| 75 | +
|
| 76 | + system_admins: |
| 77 | + # By email address |
| 78 | + emails: |
| 79 | + - "admin@example.com" |
| 80 | + - "secadmin@example.com" |
| 81 | + |
| 82 | + # By subject identifier (sub claim from OIDC) |
| 83 | + subs: |
| 84 | + - "user|123456" |
| 85 | + |
| 86 | + # By attribute expression (using BEXPR syntax) |
| 87 | + filters: |
| 88 | + - "token.groups contains \"admin\"" |
| 89 | + - "domain == \"admin.example.com\"" |
| 90 | +``` |
| 91 | + |
| 92 | +You can use one or more of these methods to designate system administrators: |
| 93 | + |
| 94 | +1. **By Email**: List specific email addresses that should have admin privileges. |
| 95 | +2. **By Subject ID**: List specific user IDs (the `sub` claim from your OIDC provider). |
| 96 | +3. **By Expression**: Use BEXPR filters to determine admin status based on token claims. |
| 97 | + |
| 98 | +## OIDC authentication flow |
| 99 | + |
| 100 | +When a user attempts to authenticate with ionscale: |
| 101 | + |
| 102 | +1. The user is redirected to the OIDC provider's login page. |
| 103 | +2. After successful authentication, the user is redirected back to ionscale. |
| 104 | +3. ionscale verifies the authentication and checks if: |
| 105 | + - The user is a system administrator (based on the `system_admins` configuration). |
| 106 | + - The user has access to any tailnets (based on IAM policies configured for individual tailnets). |
| 107 | + |
| 108 | +## Provider-specific setup instructions |
| 109 | + |
| 110 | +### Google |
| 111 | + |
| 112 | +1. Go to the [Google Cloud Console](https://console.cloud.google.com/). |
| 113 | +2. Create a new project or select an existing one. |
| 114 | +3. Navigate to "APIs & Services" > "Credentials". |
| 115 | +4. Click "Create Credentials" > "OAuth client ID". |
| 116 | +5. Select "Web application" as the application type. |
| 117 | +6. Add `https://your-ionscale-domain.com/auth/callback` as an authorized redirect URI. |
| 118 | +7. Copy the client ID and client secret. |
| 119 | + |
| 120 | +Configure ionscale: |
| 121 | +```yaml |
| 122 | +auth: |
| 123 | + provider: |
| 124 | + issuer: "https://accounts.google.com" |
| 125 | + client_id: "your-client-id.apps.googleusercontent.com" |
| 126 | + client_secret: "your-client-secret" |
| 127 | +``` |
| 128 | + |
| 129 | +### Auth0 |
| 130 | + |
| 131 | +1. Go to the [Auth0 Dashboard](https://manage.auth0.com/). |
| 132 | +2. Create a new application or select an existing one of type "Regular Web Application". |
| 133 | +3. Under "Settings", configure: |
| 134 | + - Allowed Callback URLs: `https://your-ionscale-domain.com/auth/callback` |
| 135 | +4. Copy the Domain, Client ID, and Client Secret. |
| 136 | + |
| 137 | +Configure ionscale: |
| 138 | +```yaml |
| 139 | +auth: |
| 140 | + provider: |
| 141 | + issuer: "https://your-tenant.auth0.com/" |
| 142 | + client_id: "your-client-id" |
| 143 | + client_secret: "your-client-secret" |
| 144 | +``` |
| 145 | + |
| 146 | +### Microsoft Azure AD / Entra ID |
| 147 | + |
| 148 | +1. Go to the [Azure Portal](https://portal.azure.com/). |
| 149 | +2. Navigate to "Azure Active Directory" > "App registrations". |
| 150 | +3. Create a new registration. |
| 151 | +4. Add `https://your-ionscale-domain.com/auth/callback` as a redirect URI of type "Web". |
| 152 | +5. Under "Certificates & secrets", create a new client secret. |
| 153 | +6. Copy the Application (client) ID and the new secret. |
| 154 | + |
| 155 | +Configure ionscale: |
| 156 | +```yaml |
| 157 | +auth: |
| 158 | + provider: |
| 159 | + issuer: "https://login.microsoftonline.com/your-tenant-id/v2.0" |
| 160 | + client_id: "your-client-id" |
| 161 | + client_secret: "your-client-secret" |
| 162 | + additional_scopes: "offline_access" |
| 163 | +``` |
| 164 | + |
| 165 | +## Complete configuration example |
| 166 | + |
| 167 | +```yaml |
| 168 | +auth: |
| 169 | + provider: |
| 170 | + issuer: "https://accounts.google.com" |
| 171 | + client_id: "your-client-id.apps.googleusercontent.com" |
| 172 | + client_secret: "your-client-secret" |
| 173 | + additional_scopes: "groups" |
| 174 | + |
| 175 | + system_admins: |
| 176 | + emails: |
| 177 | + - "admin@example.com" |
| 178 | + filters: |
| 179 | + - "domain == \"example.com\" && token.groups contains \"admin\"" |
| 180 | +``` |
| 181 | + |
| 182 | +## OIDC without system admin |
| 183 | + |
| 184 | +If you've configured OIDC but no system administrators, you can still use the system admin key from your initial setup for administrative tasks: |
| 185 | + |
| 186 | +```bash |
| 187 | +export IONSCALE_URL="https://your-ionscale-domain.com" |
| 188 | +export IONSCALE_KEY="your-system-admin-key" |
| 189 | +ionscale tailnet list |
| 190 | +``` |
| 191 | + |
0 commit comments