feat: read device.id from credentials.toml when basic auth mode#3242
Conversation
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
8c5a53c to
6ba5896
Compare
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
Why don't we permanently switch this setting to
If someone consciously sets |
|
Since both Proposal 1:
If tedge config macro has Probably the #[tedge_config(try_from(
error = "\
The device id is read from the device certificate if it exists.\n\
To create a device certificate, you can use `tedge cert create --device-id <id>`.",
function = "device_id",
))]
#[tedge_config(example = "Raspberrypi-4d18303a-6d3a-11eb-b1a6-175f6bb72665")]
#[tedge_config(note = "This setting is derived from the device certificate if it is set.")]
#[doku(as = "String")]
id: Result<String, ReadError>,Proposal 2:
Since it removes the block for the inconsistency of the certificate's CN and the value of
The code can look like below. #[tedge_config(note ="\
The device id is read from the device certificate if it exists.\n\
To create a device certificate, you can use `tedge cert create --device-id <id>`."
)]
#[tedge_config(default(function = "device_id")]
#[tedge_config(example = "Raspberrypi-4d18303a-6d3a-11eb-b1a6-175f6bb72665")]
#[doku(as = "String")]
id: String, |
I'd go with proposal 2, as that is sounds straightforward. If someone has explicitly set a value using |
Things are already too complicated and both proposals are only making things more complicated. I do think we must stop reading the device id from the certificate:
This is the key. I propose to:
|
|
Adding a bit of further detail to Didier's proposed solution as we discussed, we'll need to gracefully handle cases where the device ID isn't explicitly set. This can be done by setting |
|
The PR #3326 took over the contents, therefore, I would close this PR. |
Proposed changes
Draft for further discussion.
c8y.auth_mode. This PR proposes to keepdevice_idin thecredentials.tomlfile alternatively.c8yrequires a profile name. However, it cannot be determined whentedge config get device.idis called. I parsedNoneas the device profile. Correct me if I am wrong.Types of changes
Paste Link to the issue
#3240
Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments