|
| 1 | +# Authorization Configuration |
| 2 | + |
| 3 | +The `Authorization Configuration` is used to configure a connection to an Keycloak Authorization server. The configuration is later used by the plugin to authorize a user or search for them in the Keycloak. You can also configure multiple Keycloak servers by creating multiple authorization configurations. |
| 4 | + |
| 5 | +1. Login to the GoCD server as an administrator and navigate to **_Admin_** _>_ **_Security_** _>_ **_Authorization Configuration_**. |
| 6 | +2. Click on **_Add_** to create a new authorization configuration. |
| 7 | +3. Provide a unique identifier for this authorization configuration and select `Keycloak oauth authorization plugin` as the **Plugin**. |
| 8 | + |
| 9 | +4. **Keycloak Endpoint (`Mandatory`):** Specify your Keycloak Endpoint. |
| 10 | + |
| 11 | +  |
| 12 | + |
| 13 | + ```xml |
| 14 | + <property> |
| 15 | + <key>KeycloakEndpoint</key> |
| 16 | + <value>https://auth.example.com</value> |
| 17 | + </property> |
| 18 | + ``` |
| 19 | + > If you customize the Keycloak endpoint, Ex.: remove /auth context, you need to adapt the plugin. |
| 20 | + |
| 21 | +5. **Keycloak Realm (`Mandatory`):** Specify your Keycloak Realm. |
| 22 | + |
| 23 | +  |
| 24 | + |
| 25 | + ```xml |
| 26 | + <property> |
| 27 | + <key>KeycloakRealm</key> |
| 28 | + <value>master</value> |
| 29 | + </property> |
| 30 | + ``` |
| 31 | + |
| 32 | +6. **Keycloak Client ID (`Mandatory`):** Specify your Keycloak Client ID. |
| 33 | + |
| 34 | +  |
| 35 | + |
| 36 | + ```xml |
| 37 | + <property> |
| 38 | + <key>ClientId</key> |
| 39 | + <value>gocd-agent</value> |
| 40 | + </property> |
| 41 | + ``` |
| 42 | + |
| 43 | +7. **Keycloak Client Secret Key (`Mandatory`):** Specify your Keycloak Secret Key. |
| 44 | + |
| 45 | +  |
| 46 | + |
| 47 | + ```xml |
| 48 | + <property> |
| 49 | + <key>ClientSecret</key> |
| 50 | + <encryptedValue>YOUR_SECRET</encryptedValue> |
| 51 | + </property> |
| 52 | + ``` |
| 53 | + |
| 54 | +8. Click on **_Check connection_** to verify your configuration. The plugin will establish a connection with `Keycloak server` using the configuration and will return the verification status. |
| 55 | + |
| 56 | +9. Once check connection succeeds, click on **_Save_** to save the authorization configuration. |
| 57 | + |
| 58 | +#### Example authorization configuration |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +<hr/> |
| 63 | + |
| 64 | +**Alternatively, the configuration can be added directly to the GoCD config XML using the `<authConfig>` tag. It should be added under `<security/>` tag as described in the following example:** |
| 65 | + |
| 66 | +```xml |
| 67 | +<security> |
| 68 | + <authConfigs> |
| 69 | + <authConfig id="Keycloak" pluginId="cd.go.authorization.keycloak"> |
| 70 | + <property> |
| 71 | + <key>KeycloakEndpoint</key> |
| 72 | + <value>https://auth.example.com</value> |
| 73 | + </property> |
| 74 | + <property> |
| 75 | + <key>KeycloakRealm</key> |
| 76 | + <value>master</value> |
| 77 | + </property> |
| 78 | + <property> |
| 79 | + <key>ClientId</key> |
| 80 | + <value>gocd-agent</value> |
| 81 | + </property> |
| 82 | + <property> |
| 83 | + <key>ClientSecret</key> |
| 84 | + <encryptedValue>your_secret_key</encryptedValue> |
| 85 | + </property> |
| 86 | + </authConfig> |
| 87 | + </authConfigs> |
| 88 | + <admins> |
| 89 | + |
| 90 | + </admins> |
| 91 | +</security> |
| 92 | +``` |
0 commit comments