Skip to content

Commit

Permalink
add an example for app-reg
Browse files Browse the repository at this point in the history
  • Loading branch information
raoxiaoyan committed Mar 29, 2024
1 parent 372729b commit a78aa34
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion app/_hub/kong-inc/application-registration/how-to/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Replace `<service>` with your service name or ID, and `<my_service_display_name>
`display_name` of your service:

```
curl -X POST http://localhost:8001/services/<service> \
curl -X POST http://localhost:8001/services/<service>/plugins \
--data "name=application-registration" \
--data "config.display_name=<my_service_display_name>" \
--data "config.auto_approve=true
Expand All @@ -36,6 +36,63 @@ curl -X PATCH http://localhost:8001/plugins/<plugin_id> \
--data "config.auto_approve=true"
```

### Enable proxy with consumer's credential

Activating application registration will restrict access to the service using consumer credentials. To regain this functionality, you can enable `enable_proxy_with_consumer_credential`. It will introduce
an additional method for accessing the service using the consumer's credential.

```
curl -X POST http://localhost:8001/services/<service>/plugins \
--data "name=application-registration" \
--data "config.display_name=<my_service_display_name>" \
--data "config.enable_proxy_with_consumer_credential=true"
```

Or, update your current configuration with a `PATCH` request.
Replace `<plugin_id>` with the `id` of your plugin.

```
curl -X PATCH http://localhost:8001/plugins/<plugin_id> \
--data "config.enable_proxy_with_consumer_credential=true"
```

And then, create a plugin `key-auth` and route for the service.

```
curl -X POST http://localhost:8001/services/<service>/routes \
--data "path=/test"
```

```
curl -X POST http://localhost:8001/services/<service>/plugins \
--data "name=key-auth" \
--data "config.key_names=apikey"
```

Create a consumer and a consumer's credential for the `key-auth`.

```
curl -X POST http://localhost:8001/consumers \
--data "username=test"
```

```
curl -X POST http://localhost:8001/consumers/<consumer_id>/key-auth \
--data "key:<apikey>"
```

When `enable_proxy_with_consumer_credential` is enabled, constructing a request to the service should yield a 200 response, rather than the 401 response when disabled.

```
curl http://localhost:8000/test?apikey=<apikey>
```

The route should still be accessible with the `client_id` of the Application.

```
curl http://localhost:8000/test?apikey=<client_id>
```

### Enable show issuer URL

Enable `show_issuer` to expose the **Issuer URL** in the **Service Details** dialog.
Expand Down

0 comments on commit a78aa34

Please sign in to comment.