fix: skip chown for cert and key when using Basic Auth#3479
fix: skip chown for cert and key when using Basic Auth#3479Ruadhri17 merged 2 commits intothin-edge:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Robot Results
|
| if bridge_config | ||
| .auth_method | ||
| .is_some_and(|auth_method| auth_method == AuthMethod::Basic) |
There was a problem hiding this comment.
Actually, this condition doesn't cover when auth_method == AuthMethod::Auto and auto chooses basic. You could use auth_method.is_basic(<path_to_credentials_toml>) instead, however, you need to parse the credentials file path, which is not available in this function.
Alternatively, if both remote_username and remote_password are set, you can consider that auth method is basic.
| if bridge_config | |
| .auth_method | |
| .is_some_and(|auth_method| auth_method == AuthMethod::Basic) | |
| if bridge_config.remote_username.is_some() && bridge_config.remote_password.is_some() |
There was a problem hiding this comment.
When Bridge Config is created, based on remote_username it is either AuthMethod::Certificate or AuthMethod::Basic. For aws and azure it is set to None. However, using if bridge_config.remote_username.is_some() && bridge_config.remote_password.is_some() is also what I considered.
There was a problem hiding this comment.
When Bridge Config is created, based on remote_username it is either AuthMethod::Certificate or AuthMethod::Basic. For aws and azure it is set to None.
This is correct. So, just to fix the issue, your change is enough.
However, there is a misuse of the type in the code.
BridgeConfig::auth_methodshould have beenOption<AuthType>,AuthTypehas onlyBasicorCertificate.AuthMethodis just a representation ofc8y.auth_methodconfig. Internally, we should useAuthTypesince it doesn't haveAuto.- Next, what does
Nonemean for authentication? AWS/Azure, we use certificate based authentication.
So, BridgeConfig::auth_method should be no longer Option, just AuthType.
There was a problem hiding this comment.
As the condition seems no so obvious, it would be better to extract it into a BridgeConfig method.
13ceb93 to
fc17416
Compare
didier-wenzek
left a comment
There was a problem hiding this comment.
Approved. Pre-computing bridge_config.auth_type makes things clearer. Thanks.
fc17416 to
f6f97d5
Compare
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
f6f97d5 to
793c72d
Compare
Proposed changes
Skip changing ownership for device certificate as it is not needed when connecting via Basic Auth credentials.
Types of changes
Paste Link to the issue
#3476
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments