You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 0002-RCBS-Crypto-building-block.md
+30-4Lines changed: 30 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ The new building block will feature 7 low-level APIs:
54
54
55
55
The high-level APIs at launch will only include support for **encrypting** and **decrypting** messages (of arbitrary length), using the [Dapr encryption scheme](#dapr-encryption-scheme-daprioencv1).
56
56
57
-
These APIs will only be available over gRPC, because they will work over a stream of data from the client. An HTTP implementation would require keeping the entire message in-memory, which is not acceptable (messages could be multiple GBs in size).
57
+
Although these APIs will be available over both gRPC and HTTP, the gRPC implementation is **strongly** preferred, since it allows encrypting/decrypting data as a stream. The HTTP implementation requires keeping the entire message inmemory, both as plaintext and ciphertext (a limitation in the HTTP protocol itself we cannot work around), which is not desirable unless users are encrypting very small files.
58
58
59
59
### Components
60
60
@@ -658,9 +658,11 @@ The `Encrypt` and `Decrypt` methods are stream-based. Dapr will read from the cl
658
658
659
659
## HTTP APIs
660
660
661
-
The HTTP APIs are developed in a way that is the exact "port" of the gRPC "subtle" APIs, and the contents of the request and response bodies match exactly the fields in the gRPC APIs (except for the component name).
661
+
### Low-level
662
662
663
-
Methods are:
663
+
The low-level HTTP APIs are developed in a way that is the exact "port" of the gRPC "subtle" APIs, and the contents of the request and response bodies match exactly the fields in the gRPC APIs (except for the component name in the URL).
664
+
665
+
List of HTTP endpoints and the corresponding gRPC method:
> Note: URL will begin with `/v1.0-alpha1` while in preview
674
676
675
-
**Currently, higher-level APIs are not offered via HTTP**. This is because it's not possible, using HTTP, to have a stream where Dapr sends back data to the client before the client's request is complete. Without that, we'd have to buffer the entire data in-memory in the runtime, which would be not practical when encrypting very large files.
677
+
> These APIs are implemented as "Universal" APIs in Dapr, where the business logic is implemented in gRPC only, and the APIs are then exposed as HTTP using the Universal API wrapper.
678
+
679
+
### High-level
680
+
681
+
For high-level APIs, we cannot use Universal APIs because we cannot perform bi-directional streaming with HTTP.
682
+
683
+
As mentioned earlier, using HTTP for the high-level APIs is **highly inefficient** and users will be strongly advised against doing that outside of development or testing scenarios. In fact, while the Dapr encryption scheme is designed for streaming, that is not possible when using HTTP: first, the Dapr sidecar needs to receive the entire message (e.g. plaintext while encrypting), and only after that can begin responding to the caller; this means the Dapr sidecar needs to keep the entire message in-memory.
684
+
685
+
List of high-level HTTP endpoints:
686
+
687
+
-`PUT /v1.0/crypto/[component]/encrypt`
688
+
- Query-string arguments:
689
+
-`key` (required): name–or name/version (URL-encoded)–of the key
690
+
-`algorithm` (optional): `aes-gcm` (default) or `chacha20-poly1305`
691
+
- Body: the plain-text message to encrypt (in "raw format", e.g. not using multipart/form-data)
692
+
- Response: the ciphertext (in "raw format")
693
+
-`PUT /v1.0/crypto/[component]/decrypt`
694
+
- Query-string arguments:
695
+
-`key` (required): name–or name/version (URL-encoded)–of the key
696
+
- Body: the ciphertext to decrypt (in "raw format", e.g. not using multipart/form-data)
697
+
- Response: the plain-text message (in "raw format")
698
+
699
+
> Note: URL will begin with `/v1.0-alpha1` while in preview
700
+
701
+
> Note: the body is limited by Dapr's ["http-max-request-size" option](https://docs.dapr.io/operations/configuration/increase-request-size/).
0 commit comments