Last modified by Ashterix on 2024/07/11 10:08

From version 1.1
edited by Ashterix
on 2024/05/09 19:27
Change comment: There is no comment for this version
To version 3.1
edited by Ashterix
on 2024/05/16 11:31
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Bundle config
1 +2. Bundle config
Content
... ... @@ -126,7 +126,7 @@
126 126  
127 127   public function __construct(protected UserService $userService) {}
128 128  
129 - public function isValid(string $token): bool
129 + public function isValid(string $token): true
130 130   {
131 131   try {
132 132   this.userService.getUserByToken(token);
... ... @@ -159,6 +159,24 @@
159 159   class: App\Services\RpcSecurity\UserTokenValidator
160 160  {{/code}}
161 161  
162 += Block {{code language="none"}}async{{/code}} =
163 +
164 +This block is for configuring [[asynchronous transport>>doc:.functionality.async.WebHome]].
165 +
166 +Add the parameter {{code language="none"}}rpc_async{{/code}} which contains a string in DSN format. This string is the configuration for [[Symfony Messenger>>https://symfony.com/doc/current/messenger.html]], and it points to the asynchronous transport where the RPC Server will be waiting for incoming requests if you have a consumer running ({{code language="none"}}php bin/console messenger:consume rpc_async{{/code}}). For a more detailed understanding of this process, read the [[Symfony Messenger documentation>>https://symfony.com/doc/current/messenger.html]].
167 +
168 +{{code language="yaml" layout="LINENUMBERS" title="config/packages/ufo_json_rpc.yaml"}}
169 +ufo_json_rpc:
170 + async:
171 + rpc_async: '%env(resolve:RPC_TRANSPORT_DSN)%'
172 +
173 +{{/code}}
174 +
175 +(% class="box warningmessage" %)
176 +(((
177 +This configuration implies that you have an environment variable RPC_TRANSPORT_DSN set, which contains the DSN string.
178 +)))
179 +
162 162  = The {{code language="none"}}docs{{/code}} block =
163 163  
164 164  This block configures the generation of documentation when you make a GET request on the RPC Server
... ... @@ -191,6 +191,65 @@
191 191   key_for_methods: some_custom_key
192 192  {{/code}}
193 193  
212 +=== Parameter {{code language="none"}}async_dsn_info{{/code}} ===
213 +
214 +Responsible for displaying information about asynchronous transport in the documentation.
215 +
216 +{{code language="yaml" layout="LINENUMBERS" title="config/packages/ufo_json_rpc.yaml"}}
217 +ufo_json_rpc:
218 + async_dsn_info: true # or false
219 +{{/code}}
220 +
221 +==== **Documentation Example** ====
222 +
223 +{{code language="json" layout="LINENUMBERS" title="GET: /api"}}
224 +{
225 + "envelope": "JSON-RPC-2.0/UFO-RPC-6",
226 + "contentType": "application/json",
227 + "description": "",
228 + "transport": {
229 + "sync": {
230 + "scheme": "http",
231 + "host": "example.com",
232 + "path": "/api",
233 + "method": "POST"
234 + },
235 + "async": {
236 + "scheme": "amqp",
237 + "user": "{user}",
238 + "pass": "{pass}",
239 + "host": "async_rabbit",
240 + "port": 5672,
241 + "path": "/%2f/json-rpc"
242 + }
243 + },
244 + "methods": {
245 + ...
246 + }
247 +}
248 +{{/code}}
249 +
250 +{{info}}
251 +Do not worry about the security of your authorization data contained in the DSN.
252 +
253 +The documenter is designed in such a way that before displaying DSN information, it removes user data and passwords, as well as other sensitive information, such as tokens, secret keys, etc.
254 +
255 +The template for protecting data is {{code language="none"}}/([\w\d_]*(?:secret|access|token|key)[_\w]*)=((?:\w|\d)+(?=&?))/{{/code}}.
256 +
257 +Example:
258 +
259 +{{code language="json" layout="LINENUMBERS" title="RPC_TRANSPORT_DSN=https://sqs.eu-west-3.amazonaws.com/123456789012/messages?access_key=AKIAIOSFODNN7EXAMPLE&secret_key=j17M97ffSVoKI0briFoo9a"}}
260 +{
261 + "async": {
262 + "scheme": "https",
263 + "host": "sqs.eu-west-3.amazonaws.com",
264 + "path": "/123456789012/messages",
265 + "query": "access_key={access_key}&secret_key={secret_key}"
266 + }
267 +}
268 +{{/code}}
269 +{{/info}}
270 +
194 194  === Parameter {{code language="none"}}validations{{/code}} ===
195 195  
196 196  Responsible for displaying in the documentation methods additional blocks that indicate data validation requirements.
... ... @@ -218,8 +218,7 @@
218 218  For more information on method validation, see the page **[[Validate procedures>>doc:.add_rpc_service.assertions.WebHome]]**
219 219  )))
220 220  
221 -{{code language="json" layout="LINENUMBERS" title="
222 -GET: /api"}}
298 +{{code language="json" layout="LINENUMBERS" title="GET: /api"}}
223 223  {
224 224   "envelope": "JSON-RPC-2.0/UFO-RPC-6",
225 225   "transport": "POST",