|
2 | 2 | title: "Kong Identity" |
3 | 3 | content_type: reference |
4 | 4 | layout: reference |
5 | | -beta: true |
6 | 5 |
|
7 | 6 | products: |
8 | 7 | - konnect |
@@ -165,3 +164,133 @@ Claims support templating via the context passed to the client during the authen |
165 | 164 |
|
166 | 165 | To test the templating, you can use the [`/v1/auth-servers/$authServerId/clients/$clientId/test-claim` endpoint](/api/konnect/kong-identity/v1/#/operations/testClaimForClient). |
167 | 166 |
|
| 167 | + |
| 168 | +## Configure Kong Identity |
| 169 | + |
| 170 | +To configure Kong Identity, do the following: |
| 171 | + |
| 172 | +{% navtabs "api-version" %} |
| 173 | +{% navtab "{{site.konnect_short_name}} UI" %} |
| 174 | +1. In the {{site.konnect_short_name}} sidebar, click [**Identity**](https://cloud.konghq.com/identity/). |
| 175 | +1. Click **New authorization server**. |
| 176 | +1. In the **Name** field, enter a name. |
| 177 | +1. In the **Audience** field, enter the audience. |
| 178 | + |
| 179 | + {:.info} |
| 180 | + > **Note:** The value in the **Audience** field is the audience that the token is intended for, like a client ID or the upstream URL of the Gateway Service for the API resource. For example, `https://api.example.com/payments` and `http://myhttpbin.dev`. If you don't have an intended audience, you can put a placeholder value, like `orders-api`, in this field. |
| 181 | +1. Click **Create**. |
| 182 | +1. Click **New scope**. |
| 183 | +1. In the **Name** field, enter a name for your scope. |
| 184 | +1. Click **Create**. |
| 185 | +1. Navigate back to your authorization server. |
| 186 | +1. Click **New claim**. |
| 187 | +1. In the **Name** field, enter a name for your claim. |
| 188 | +1. In the **Value** field, enter the value for your claim. These can also be [dynamic](#dynamic-claim-templates). |
| 189 | +1. From the **When to include this claim in tokens** dropdown menu, select an option. |
| 190 | +1. Click **Create**. |
| 191 | +1. Navigate back to your authorization server. |
| 192 | +1. Click **New client**. |
| 193 | +1. In the **Name** field, enter a name for your client. |
| 194 | +1. From the **Allowed scopes** dropdown menu, select an option. |
| 195 | +1. Click **Create**. |
| 196 | +1. Copy and save your client ID and secret. |
| 197 | +{% endnavtab %} |
| 198 | +{% navtab "{{site.konnect_short_name}} API" %} |
| 199 | +1. Create an auth server using the [`/v1/auth-servers` endpoint](/api/konnect/kong-identity/v1/#/operations/createAuthServer): |
| 200 | +<!--vale off--> |
| 201 | +{% capture auth-server %} |
| 202 | +{% konnect_api_request %} |
| 203 | +url: /v1/auth-servers |
| 204 | +status_code: 200 |
| 205 | +method: POST |
| 206 | +headers: |
| 207 | + - 'Content-Type: application/json' |
| 208 | +body: |
| 209 | + name: "Appointments Dev" |
| 210 | + audience: "http://myhttpbin.dev" |
| 211 | + description: "Auth server for the Appointment dev environment" |
| 212 | +{% endkonnect_api_request %} |
| 213 | +{% endcapture %} |
| 214 | +{{ auth-server | indent: 3 }} |
| 215 | +<!--vale on--> |
| 216 | +1. Export the auth server ID and issuer URL: |
| 217 | + ```sh |
| 218 | + export AUTH_SERVER_ID='YOUR-AUTH-SERVER-ID' |
| 219 | + export ISSUER_URL='YOUR-ISSUER-URL' |
| 220 | + ``` |
| 221 | +1. Configure a scope in your auth server using the [`/v1/auth-servers/$AUTH_SERVER_ID/scopes` endpoint](/api/konnect/kong-identity/v1/#/operations/createAuthServerScope): |
| 222 | +<!--vale off--> |
| 223 | +{% capture scope %} |
| 224 | +{% konnect_api_request %} |
| 225 | +url: /v1/auth-servers/$AUTH_SERVER_ID/scopes |
| 226 | +status_code: 200 |
| 227 | +method: POST |
| 228 | +headers: |
| 229 | + - 'Content-Type: application/json' |
| 230 | +body: |
| 231 | + name: "my-scope" |
| 232 | + description: "Scope to test Kong Identity" |
| 233 | + default: false |
| 234 | + include_in_metadata: false |
| 235 | + enabled: true |
| 236 | +{% endkonnect_api_request %} |
| 237 | +{% endcapture %} |
| 238 | +{{ scope | indent: 3 }} |
| 239 | +<!--vale on--> |
| 240 | +1. Export your scope ID: |
| 241 | + ```sh |
| 242 | + export SCOPE_ID='YOUR-SCOPE-ID' |
| 243 | + ``` |
| 244 | +1. Configure a custom claim using the [`/v1/auth-servers/$AUTH_SERVER_ID/claims` endpoint](/api/konnect/kong-identity/v1/#/operations/createAuthServerClaim): |
| 245 | +<!--vale off--> |
| 246 | +{% capture claim %} |
| 247 | +{% konnect_api_request %} |
| 248 | +url: /v1/auth-servers/$AUTH_SERVER_ID/claims |
| 249 | +status_code: 200 |
| 250 | +method: POST |
| 251 | +headers: |
| 252 | + - 'Content-Type: application/json' |
| 253 | +body: |
| 254 | + name: "test-claim" |
| 255 | + value: test |
| 256 | + include_in_token: true |
| 257 | + include_in_all_scopes: false |
| 258 | + include_in_scopes: |
| 259 | + - $SCOPE_ID |
| 260 | + enabled: true |
| 261 | +{% endkonnect_api_request %} |
| 262 | +{% endcapture %} |
| 263 | +{{ claim | indent: 3 }} |
| 264 | + |
| 265 | +1. Configure the client using the [`/v1/auth-servers/$AUTH_SERVER_ID/clients` endpoint](/api/konnect/kong-identity/v1/#/operations/createAuthServerClient): |
| 266 | +<!--vale off--> |
| 267 | +{% capture client %} |
| 268 | +{% konnect_api_request %} |
| 269 | +url: /v1/auth-servers/$AUTH_SERVER_ID/clients |
| 270 | +status_code: 201 |
| 271 | +method: POST |
| 272 | +headers: |
| 273 | + - 'Content-Type: application/json' |
| 274 | +body: |
| 275 | + name: Client |
| 276 | + grant_types: |
| 277 | + - client_credentials |
| 278 | + allow_all_scopes: false |
| 279 | + allow_scopes: |
| 280 | + - $SCOPE_ID |
| 281 | + access_token_duration: 3600 |
| 282 | + id_token_duration: 3600 |
| 283 | + response_types: |
| 284 | + - id_token |
| 285 | + - token |
| 286 | +{% endkonnect_api_request %} |
| 287 | +{% endcapture %} |
| 288 | +{{ client | indent: 3 }} |
| 289 | + |
| 290 | +1. Export your client secret and client ID: |
| 291 | + ```sh |
| 292 | + export CLIENT_SECRET='YOUR-CLIENT-SECRET' |
| 293 | + export CLIENT_ID='YOUR-CLIENT-ID' |
| 294 | + ``` |
| 295 | +{% endnavtab %} |
| 296 | +{% endnavtabs %} |
0 commit comments