refactor: flexible Authorization header type of HTTP request#3190
Conversation
Robot Results
|
95d782a to
02a3a44
Compare
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
|
@rina23q @didier-wenzek @albinsuresh Wouldn't it make more sense to have a generic "Add N Headers"...that way we could write providers to inject any required headers and not assume it was just be the "Authorization" header? |
didier-wenzek
left a comment
There was a problem hiding this comment.
Question:
The JWT token implementation inc8y_remote_access_pluginseems duplicated toC8YJwtRetrieverimplementation...
This is not a duplicate, just a difference on the API level which is used. The c8y_remote_access_plugin directly invokes C8yMqttJwtTokenRetriever::get_jwt_token() instead as wrapping this call behind an actor as done by C8YJwtRetriever.
=> The implication for that refactoring PR is that the difference between the misc auth method has to be addressed in the c8y_api with a facade over the ``C8yMqttJwtTokenRetrieverand aBasicAuthRetriver`. Both returning an authentication header ready to be used.
| @@ -32,16 +32,17 @@ impl C8YJwtRetriever { | |||
|
|
|||
| #[async_trait] | |||
| impl Server for C8YJwtRetriever { | |||
There was a problem hiding this comment.
Adding the new C8YBasicAuthProvider in this PR would really help to validate the refactoring, even if not use yet.
There was a problem hiding this comment.
Sorry, I should have remove this comment which is conflicting with my other comment #3190 (review), telling that:
the difference between the misc auth method has to be addressed in the c8y_api with a facade over the
C8yMqttJwtTokenRetrieverand aBasicAuthRetriver. Both returning an authentication header ready to be used.
Anyway. This can be done in the next step.
Ah like returning So it means Or even getting a help from the http crate's |
Or even better, it results a vector of header name/value 's)...As some more complicated authenticated mechanisms need to set multiple header properties, for example AWS S3 API allows users to also add |
Then this |
didier-wenzek
left a comment
There was a problem hiding this comment.
Approved. This refactoring PR is a nice progress forward.
Also, I removed unused code in 897c102. If they should stay in our code, please inform me. Then I can revert in that case.
Removing dead code is always a good thing.
| @@ -32,16 +32,17 @@ impl C8YJwtRetriever { | |||
|
|
|||
| #[async_trait] | |||
| impl Server for C8YJwtRetriever { | |||
There was a problem hiding this comment.
Sorry, I should have remove this comment which is conflicting with my other comment #3190 (review), telling that:
the difference between the misc auth method has to be addressed in the c8y_api with a facade over the
C8yMqttJwtTokenRetrieverand aBasicAuthRetriver. Both returning an authentication header ready to be used.
Anyway. This can be done in the next step.
- Change JWT token retriever actor to return "Bearer {token}",
previously it was just "{token}"
- Deprecate Auth enum in downloader so that downloader can
accept any authorization header value easily
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
HttpHeaderRetriever returns HeaderMap. So, C8YJwtRetriever now returns HeaderMap. The retrieved JWT token is included in the map. In the future, there will be C8YBasicAuthRetriever, which will also returns HeaderMap. Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
e7b8724 to
9711f81
Compare
Proposed changes
Pure refactoring PR to make a progress of #3036 easier.
C8YJwtRetrieverreturnsHeaderMap, previously it was just JWT token (String).Authenum in downloader so that downloader can accept any headers easilyWhy this refactoring is needed?
#3036 needs to introduce Basic authentication instead of JWT token authentication. However, the current implementation, especially HTTP APIs, are designed to use Authorization header together with JWT token. Since the JWT actor is actually a server trait, for basic authentication, we can just implement a server trait.
Question:
The JWT token inplementation in
c8y_remote_access_pluginseems duplicated toC8YJwtRetrieverimplementation...=> I understand they are different level.
Types of changes
Paste Link to the issue
#3036
Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments