fix: [Access API] update the device identification section in info.description - #146
fix: [Access API] update the device identification section in info.description#146jimfengjinhua wants to merge 4 commits into
Conversation
… token types Rewrite the "Identifying the device from the access token" section to accurately describe behavior for both two-legged and three-legged access tokens, and align error handling descriptions with the CAMARA common definitions of MISSING_IDENTIFIER and UNNECESSARY_IDENTIFIER.
Co-authored-by: tlohmar <Thorsten.Lohmar@ericsson.com>
Co-authored-by: tlohmar <Thorsten.Lohmar@ericsson.com>
Co-authored-by: tlohmar <Thorsten.Lohmar@ericsson.com>
There was a problem hiding this comment.
The MISSING_IDENTIFIER / UNNECESSARY_IDENTIFIER swap from #144 is fixed, and now matches the Commonalities canonical template (identifying-device-from-access-token) word for word for those two bullets.
But copying the canonical text as-is doesn't quite fit here: the template assumes a single device field, but this API identifies devices via a devices array (CreateAccessRequest.devices), and for add/remove the array is the request body with no field wrapper at all. A few lines still say "the device object", which doesn't correspond to anything in the schema. Suggested line-level adaptations below — happy to have these adjusted rather than taken as-is.
| This API requires the API consumer to identify a device as the subject of the API as follows: | ||
| - Since this API can handle multiple devices in one request it is strongly recommended to use a two-legged access token | ||
| - When the API is invoked using a two-legged access token, each device will be identified by the respective `device` identifier, which therefore MUST be provided. | ||
| - When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided. |
There was a problem hiding this comment.
| - When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided. | |
| - When the API is invoked using a two-legged access token, the subject(s) will be identified from the device(s) provided in the request, which therefore MUST be provided. |
There was a problem hiding this comment.
| - When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided. | |
| - When the API is invoked using a two-legged access token, the subject(s) will be identified from the `device` object(s) provided in the request, which therefore MUST be provided. |
keeping the style of device
| - When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided. | ||
| - When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token. | ||
|
|
||
| Since this API can handle multiple devices in one request, it is strongly recommended to use a two-legged access token. |
There was a problem hiding this comment.
It is a consequence from the design, not really a recommendation:
| Since this API can handle multiple devices in one request, it is strongly recommended to use a two-legged access token. | |
| Because a three-legged access token identifies exactly one device (from the token itself) and does not allow an explicit device list, a two-legged access token MUST be used whenever a request includes multiple devices. |
| ## Error handling: | ||
|
|
||
| - If the subject can be identified from the access token and there is no matching `device` object, then the server will return an error with the `422 MISSING_IDENTIFIER` error code. | ||
| - If the subject cannot be identified from the access token and the optional `device` object is not included in the request, then the server will return an error with the `422 MISSING_IDENTIFIER` error code. |
There was a problem hiding this comment.
| - If the subject cannot be identified from the access token and the optional `device` object is not included in the request, then the server will return an error with the `422 MISSING_IDENTIFIER` error code. | |
| - If the subject cannot be identified from the access token and no device is included in the request, then the server will return an error with the `422 MISSING_IDENTIFIER` error code. |
There was a problem hiding this comment.
hmm, why not following L95 of the info.description template?
| - Since this API can handle multiple devices in one request it is strongly recommended to use a two-legged access token | ||
| - When the API is invoked using a two-legged access token, each device will be identified by the respective `device` identifier, which therefore MUST be provided. | ||
| - When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided. | ||
| - When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token. |
There was a problem hiding this comment.
| - When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token. | |
| - When a three-legged access token is used however, a device MUST NOT be provided in the request, as the subject will be uniquely identified from the access token. |
There was a problem hiding this comment.
L87 uses this optional identifier, while a device is much clearer.
Might be good to fix this in the template as well.
There was a problem hiding this comment.
L87 uses this optional identifier, while a device is much clearer.
Might be good to fix this in the template as well.
Actual it should be "the object devices MUST NOT be provided in the request".
In the template this sentence reads well in context, just not in isolation.
|
Another observation which is maybe more critical: |
| - If the subject can be identified from the access token and there is no matching `device` object, then the server will return an error with the `422 MISSING_IDENTIFIER` error code. | ||
| - If the subject cannot be identified from the access token and the optional `device` object is not included in the request, then the server will return an error with the `422 MISSING_IDENTIFIER` error code. | ||
|
|
||
| - If the subject can be identified from the access token and the optional `device` object is also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same device is identified by these two methods, as the server is unable to make this comparison. |
There was a problem hiding this comment.
One line I missed in my review above:
| - If the subject can be identified from the access token and the optional `device` object is also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same device is identified by these two methods, as the server is unable to make this comparison. | |
| - If the subject can be identified from the access token and one or more devices are also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same device is identified by these two methods, as the server is unable to make this comparison. |
There was a problem hiding this comment.
Good point.
Rephrasing to keep the style of object
| - If the subject can be identified from the access token and the optional `device` object is also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same device is identified by these two methods, as the server is unable to make this comparison. | |
| - If the subject can be identified from the access token and the one or more `device` objects are also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same device is identified by these two methods, as the server is unable to make this comparison. |
|
@tlohmar thanks for your comments. As said, feel free to adjust, not expected that the suggestions will be taken as-is. Just that the template does not fit fully. |
|
@hdamker @jimfengjinhua it could be simpler to not support the usage of three-legged access tokens (instead of fixing the operations with one device only). |
What type of PR is this?
What this PR does / why we need it:
Rewrite the "Identifying the device from the access token" section to accurately describe behavior for both two-legged and three-legged access tokens, and align error handling descriptions with the CAMARA common definitions of MISSING_IDENTIFIER and UNNECESSARY_IDENTIFIER.
Which issue(s) this PR fixes:
Fixes #144
Special notes for reviewers:
Changelog input
Additional documentation
This section can be blank.