-
Notifications
You must be signed in to change notification settings - Fork 72
allow setting the device.id when using c8y basic auth #3240
Description
Is your feature improvement request related to a problem? Please describe.
With the introduction of Basic Auth in #3036 (to support existing/legacy Cumulocity solutions), the solution still requires a dummy certificate to be set so that the correct device.id field can be read. The device.id tedge configuration property is a special property which is read from the existing public device certificate, however when using Basic Auth, a certificate is not required, so it is unexpected to demand that the user create a dummy certificate.
Describe the solution you'd like
When either of the following conditions is true:
- c8y.auth_mode is set to
basic - c8y.auth_mode is set to
autoand thec8y.credentials_pathfile exists
Then, the device.id tedge configuration property should be read from.
[device]
id = "<device_id>"This would require the user to set the value via the tedge config set command.
tedge config set device.id mydeviceidHowever, if the above conditions are not met, then the user should be presented with the current error message (when trying to set the device.id when using device certificates):
tedge config set device.id mydeviceid
error: invalid value 'device.id' for '<KEY>': The device id is read from the device certificate and cannot be set directly.
To set 'device.id' to some <id>, you can use `tedge cert create --device-id <id>`.
For more information, try '--help'.Describe alternatives you've considered
When using Cumulocity Basic Auth mode, the device.id could be derived from the c8y.username property in the c8y.credentials_path file, for example a value of t1234/device_myexample would be interpreted as myexample.
This solution is not ideal as it relies on very specific Cumulocity parsing of the username, and also assumes that the username and the device.id are the same (where technically they do not need to match!)
Additional context