|
| 1 | +# Configuring OAuth Integration in Rdiffweb |
| 2 | + |
| 3 | +This documentation guides you through configuring OAuth integration in Rdiffweb. OAuth is an authorization framework that allows third-party applications to obtain limited access to user accounts on an HTTP service. Rdiffweb is a web-based interface for managing file and directory backups. Integrating OAuth with Rdiffweb enables seamless authentication using external identity providers within your organization. |
| 4 | + |
| 5 | +This integration works with most OAuth/OpenID-compliant providers, including: |
| 6 | + |
| 7 | +- Google |
| 8 | +- GitLab |
| 9 | +- Auth0 |
| 10 | +- and others |
| 11 | + |
| 12 | +## Basic Configuration Settings |
| 13 | + |
| 14 | +Open the Rdiffweb configuration file (`/etc/rdiffweb/rdw.conf`) and add the following lines: |
| 15 | + |
| 16 | +```ini |
| 17 | +oauth_client_id = <OAUTH_CLIENT_ID> |
| 18 | +oauth_client_secret = <OAUTH_CLIENT_SECRET> |
| 19 | +oauth_auth_url = <OAUTH_AUTH_URL> |
| 20 | +oauth_token_url = <OAUTH_TOKEN_URL> |
| 21 | +oauth_userinfo_url = <OAUTH_USERINFO_URL> |
| 22 | +oauth_scope = <OAUTH_SCOPE> |
| 23 | +``` |
| 24 | + |
| 25 | +Replace the placeholders with the appropriate values from your OAuth provider. |
| 26 | + |
| 27 | +The following settings are available for OAuth integration with Rdiffweb: |
| 28 | + |
| 29 | +| Option | Description | |
| 30 | +|-------------------------------|-------------| |
| 31 | +| `--oauth-client-id` (Required) | The client ID provided by your OAuth provider when you register your application. Example: `abc123-def456-ghi789` | |
| 32 | +| `--oauth-client-secret` (Required) | The client secret provided by your OAuth provider. This is sensitive data and should be properly protected. | |
| 33 | +| `--oauth-auth-url` (Required) | The authorization endpoint URL of your OAuth provider. Example: `https://accounts.google.com/o/oauth2/v2/auth` | |
| 34 | +| `--oauth-token-url` (Required) | The token endpoint URL for obtaining access tokens. Example: `https://oauth2.googleapis.com/token` | |
| 35 | +| `--oauth-userinfo-url` (Required) | The user information endpoint URL for retrieving user profile data. Example: `https://www.googleapis.com/oauth2/v2/userinfo` | |
| 36 | +| `--oauth-scope` | The OAuth scopes to request. Common scopes include `openid`, `profile`, and `email`. Multiple scopes should be space-separated. Default: `openid profile email` | |
| 37 | + |
| 38 | +## Creating or Updating Users from OAuth |
| 39 | + |
| 40 | +When OAuth integration is enabled, Rdiffweb can automatically create users in the internal database upon their first successful login. To use this feature, ensure you have a custom and trusted OAuth provider. If this feature is disabled, users must be created manually before they can log in. |
| 41 | + |
| 42 | +### Enabling Automatic User Creation |
| 43 | + |
| 44 | +To enable automatic user creation, use the `--add-missing-user` option. Additional options let you control the creation process. |
| 45 | + |
| 46 | +### Configuration Options |
| 47 | + |
| 48 | +The following settings control user creation and attribute mapping from OAuth claims: |
| 49 | + |
| 50 | +| Option | Description | Example | |
| 51 | +|--------|-------------|---------| |
| 52 | +| `--add-missing-user` | Enables automatic user creation upon successful OAuth authentication. | `--add-missing-user` | |
| 53 | +| `--add-user-default-role` | Specifies the default role for users created from OAuth. Only effective with `--add-missing-user` enabled. | `--add-user-default-role=user` | |
| 54 | +| `--add-user-default-userroot` | Specifies the default root directory for new users. Supports OAuth claim substitution via `{claim}` syntax. Only effective with `--add-missing-user`. | `--add-user-default-userroot=/backups/{sub}/` | |
| 55 | +| `--oauth-fullname-claim` | Specifies the OAuth claim for the user's full display name. If unavailable, constructs the name from first and last name claims. | `--oauth-fullname-claim=name` | |
| 56 | +| `--oauth-firstname-claim` | Specifies the OAuth claim for the user's first name (fallback). | `--oauth-firstname-claim=given_name` | |
| 57 | +| `--oauth-lastname-claim` | Specifies the OAuth claim for the user's last name (fallback). | `--oauth-lastname-claim=family_name` | |
| 58 | +| `--oauth-email-claim` | Specifies the OAuth claim for the user's email address. | `--oauth-email-claim=email` | |
| 59 | +| `--oauth-userkey-claim` | Specifies the OAuth claim to use as the username. Defaults to the email claim if unspecified. | `--oauth-userkey-claim=email` | |
| 60 | +| `--oauth-required-claim` | Requires a specific OAuth claim to have a defined value, formatted as `<claim> <value>`. | `--oauth-required-claim=email_verified true` | |
| 61 | + |
| 62 | +## Example OAuth Configurations |
| 63 | + |
| 64 | +### Private OAuth Provider with Automatic User Creation |
| 65 | + |
| 66 | +For private OAuth providers (e.g., Auth0), it is expected that your organization manages user accounts similarly to an LDAP directory. In this scenario, configure Rdiffweb to automatically create users upon first login. |
| 67 | + |
| 68 | +Ensure you have a unique claim to use as the account username (`oauth-userkey-claim`). |
| 69 | + |
| 70 | +```ini |
| 71 | +oauth-client-id = your-client-id |
| 72 | +oauth-client-secret = your-client-secret |
| 73 | +oauth-auth-url = https://changeme.us.auth0.com/authorize |
| 74 | +oauth-token-url = https://changeme.us.auth0.com/oauth/token |
| 75 | +oauth-userinfo-url = https://changeme.us.auth0.com/userinfo |
| 76 | +oauth-scope = openid profile email |
| 77 | +oauth-userkey-claim = preferred_username |
| 78 | + |
| 79 | +add-missing-user = True |
| 80 | +login-with-email = True |
| 81 | +``` |
| 82 | + |
| 83 | +### Public OAuth with Email Verification |
| 84 | + |
| 85 | +If using a public provider such as Google Accounts, pre-populate all users allowed to access the application. Let them authenticate with their Google account. In this case, define `oauth-required-claim` like `email_verified true`, and set `oauth-userkey-claim` to `email` to associate accounts by email address. |
| 86 | + |
| 87 | +```ini |
| 88 | +oauth-client-id = your-client-id |
| 89 | +oauth-client-secret = your-client-secret |
| 90 | +oauth-auth-url = https://accounts.google.com/o/oauth2/v2/auth |
| 91 | +oauth-token-url = https://oauth2.googleapis.com/token |
| 92 | +oauth-userinfo-url = https://openidconnect.googleapis.com/v1/userinfo |
| 93 | +oauth-scope = openid profile email |
| 94 | +oauth-required-claim = email_verified true |
| 95 | +oauth-userkey-claim = email |
| 96 | + |
| 97 | +add-missing-user = False |
| 98 | +login-with-email = True |
| 99 | +``` |
0 commit comments