Changes for page Версія 6: Налаштування
Last modified by Ashterix on 2024/07/11 10:08
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -Bundle config 1 +Version 6. Bundle config - Content
-
... ... @@ -2,6 +2,11 @@ 2 2 {{toc/}} 3 3 {{/box}} 4 4 5 +{{error}} 6 +**WARNING!!! **This version of the documentation is out of date. 7 +In JsonRpcBundle version 7, the configuration has undergone significant changes and is not backwards compatible with version 6. 8 +{{/error}} 9 + 5 5 (% class="wikigeneratedid" %) 6 6 All bundle settings are located in the file {{code language="none"}}config/packages/ufo_json_rpc.yaml{{/code}}. 7 7 ... ... @@ -53,6 +53,9 @@ 53 53 - RFC Standards: Header requirements are regulated by RFC documents that define standards for Internet protocols. For example, common headers and their use are described in RFC 7231. 54 54 {{/spoiler}} 55 55 61 + 62 + 63 + 56 56 == Parameter {{code language="none"}}clients_tokens{{/code}} == 57 57 58 58 Now you need to specify an array of client tokens that will have access to the API. ... ... @@ -126,7 +126,7 @@ 126 126 127 127 public function __construct(protected UserService $userService) {} 128 128 129 - public function isValid(string $token): bool137 + 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 170 += Block {{code language="none"}}async{{/code}} = 171 + 172 +This block is for configuring [[asynchronous transport>>doc:docs.JsonRpcBundle.functionality.async.WebHome]]. 173 + 174 +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]]. 175 + 176 +{{code language="yaml" layout="LINENUMBERS" title="config/packages/ufo_json_rpc.yaml"}} 177 +ufo_json_rpc: 178 + async: 179 + rpc_async: '%env(resolve:RPC_TRANSPORT_DSN)%' 180 + 181 +{{/code}} 182 + 183 +(% class="box warningmessage" %) 184 +((( 185 +This configuration implies that you have an environment variable RPC_TRANSPORT_DSN set, which contains the DSN string. 186 +))) 187 + 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 220 +=== Parameter {{code language="none"}}async_dsn_info{{/code}} === 221 + 222 +Responsible for displaying information about asynchronous transport in the documentation. 223 + 224 +{{code language="yaml" layout="LINENUMBERS" title="config/packages/ufo_json_rpc.yaml"}} 225 +ufo_json_rpc: 226 + async_dsn_info: true # or false 227 +{{/code}} 228 + 229 +==== **Documentation Example** ==== 230 + 231 +{{code language="json" layout="LINENUMBERS" title="GET: /api"}} 232 +{ 233 + "envelope": "JSON-RPC-2.0/UFO-RPC-6", 234 + "contentType": "application/json", 235 + "description": "", 236 + "transport": { 237 + "sync": { 238 + "scheme": "http", 239 + "host": "example.com", 240 + "path": "/api", 241 + "method": "POST" 242 + }, 243 + "async": { 244 + "scheme": "amqp", 245 + "user": "{user}", 246 + "pass": "{pass}", 247 + "host": "async_rabbit", 248 + "port": 5672, 249 + "path": "/%2f/json-rpc" 250 + } 251 + }, 252 + "methods": { 253 + ... 254 + } 255 +} 256 +{{/code}} 257 + 258 +{{info}} 259 +Do not worry about the security of your authorization data contained in the DSN. 260 + 261 +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. 262 + 263 +The template for protecting data is {{code language="none"}}/([\w\d_]*(?:secret|access|token|key)[_\w]*)=((?:\w|\d)+(?=&?))/{{/code}}. 264 + 265 +Example: 266 + 267 +{{code language="json" layout="LINENUMBERS" title="RPC_TRANSPORT_DSN=https://sqs.eu-west-3.amazonaws.com/123456789012/messages?access_key=AKIAIOSFODNN7EXAMPLE&secret_key=j17M97ffSVoKI0briFoo9a"}} 268 +{ 269 + "async": { 270 + "scheme": "https", 271 + "host": "sqs.eu-west-3.amazonaws.com", 272 + "path": "/123456789012/messages", 273 + "query": "access_key={access_key}&secret_key={secret_key}" 274 + } 275 +} 276 +{{/code}} 277 +{{/info}} 278 + 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. ... ... @@ -215,11 +215,10 @@ 215 215 (% class="box infomessage" %) 216 216 ((( 217 217 In this example, I removed the content of the objects symfony_assertions to simplify the example. 218 -For more information on method validation, see the page **[[Validate procedures>>doc:.add_rpc_service.assertions.WebHome]]** 303 +For more information on method validation, see the page **[[Validate procedures>>doc:docs.JsonRpcBundle.add_rpc_service.assertions.WebHome]]** 219 219 ))) 220 220 221 -{{code language="json" layout="LINENUMBERS" title=" 222 -GET: /api"}} 306 +{{code language="json" layout="LINENUMBERS" title="GET: /api"}} 223 223 { 224 224 "envelope": "JSON-RPC-2.0/UFO-RPC-6", 225 225 "transport": "POST",