mirror of https://github.com/dapr/docs.git
Added docs for API denylists
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
parent
ebd730cc5c
commit
456767d19c
|
@ -6,14 +6,18 @@ weight: 4500
|
|||
description: "Choose which Dapr sidecar APIs are available to the app"
|
||||
---
|
||||
|
||||
In certain scenarios such as zero trust networks or when exposing the Dapr sidecar to external traffic through a frontend, it's recommended to only enable the Dapr sidecar APIs that are being used by the app. Doing so reduces the attack surface and helps keep the Dapr APIs scoped to the actual needs of the application.
|
||||
In certain scenarios, such as zero trust networks or when exposing the Dapr sidecar to external traffic through a frontend, it's recommended to only enable the Dapr sidecar APIs that are being used by the app. Doing so reduces the attack surface and helps keep the Dapr APIs scoped to the actual needs of the application.
|
||||
|
||||
Dapr allows developers to control which APIs are accessible to the application by setting an API allow list using a [Dapr Configuration]({{<ref "configuration-overview.md">}}).
|
||||
Dapr allows developers to control which APIs are accessible to the application by setting an API allowlist or denylist using a [Dapr Configuration]({{<ref "configuration-overview.md">}}).
|
||||
|
||||
### Default behavior
|
||||
|
||||
If an API allow list section is not specified, the default behavior is to allow access to all Dapr APIs.
|
||||
Once an allow list is set, only the specified APIs are accessible.
|
||||
If no API allowlist or denylist is specified, the default behavior is to allow access to all Dapr APIs.
|
||||
|
||||
- If only a denylist is defined, all Dapr APIs are allowed except those defined in the denylist
|
||||
- If only an allowlist is defined, only the Dapr APIs listed in the allowlist are allowed
|
||||
- If both an allowlist and a denylist are defined, the allowed APIs are those defined in the allowlist, unless they are also included in the denylist. In other terms, the denylist overrides the allowlist for APIs that are defined in both places.
|
||||
- If neither is defined, all APIs are allowed.
|
||||
|
||||
For example, the following configuration enables all APIs for both HTTP and gRPC:
|
||||
|
||||
|
@ -28,9 +32,11 @@ spec:
|
|||
samplingRate: "1"
|
||||
```
|
||||
|
||||
### Enabling specific HTTP APIs
|
||||
### Using an allowlist
|
||||
|
||||
The following example enables the state `v1.0` HTTP API and block all the rest:
|
||||
#### Enabling specific HTTP APIs
|
||||
|
||||
The following example enables the state `v1.0` HTTP API and block all other HTTP APIs:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -41,14 +47,14 @@ metadata:
|
|||
spec:
|
||||
api:
|
||||
allowed:
|
||||
- name: state
|
||||
version: v1.0
|
||||
protocol: http
|
||||
- name: state
|
||||
version: v1.0
|
||||
protocol: http
|
||||
```
|
||||
|
||||
### Enabling specific gRPC APIs
|
||||
#### Enabling specific gRPC APIs
|
||||
|
||||
The following example enables the state `v1` gRPC API and block all the rest:
|
||||
The following example enables the state `v1` gRPC API and block all other gRPC APIs:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -59,9 +65,47 @@ metadata:
|
|||
spec:
|
||||
api:
|
||||
allowed:
|
||||
- name: state
|
||||
version: v1
|
||||
protocol: grpc
|
||||
- name: state
|
||||
version: v1
|
||||
protocol: grpc
|
||||
```
|
||||
|
||||
### Using a denylist
|
||||
|
||||
#### Disabling specific HTTP APIs
|
||||
|
||||
The following example disables the state `v1.0` HTTP API, allowing all other HTTP APIs:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: myappconfig
|
||||
namespace: default
|
||||
spec:
|
||||
api:
|
||||
denied:
|
||||
- name: state
|
||||
version: v1.0
|
||||
protocol: http
|
||||
```
|
||||
|
||||
#### Disabling specific gRPC APIs
|
||||
|
||||
The following example disables the state `v1` gRPC API, allowing all other gRPC APIs:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Configuration
|
||||
metadata:
|
||||
name: myappconfig
|
||||
namespace: default
|
||||
spec:
|
||||
api:
|
||||
denied:
|
||||
- name: state
|
||||
version: v1
|
||||
protocol: grpc
|
||||
```
|
||||
|
||||
### List of Dapr APIs
|
||||
|
|
Loading…
Reference in New Issue