-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: flexible Authorization header type of HTTP request #3190
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
The JWT token implementation inc8y_remote_access_plugin
seems duplicated toC8YJwtRetriever
implementation...
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 a
BasicAuthRetriver`. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
C8yMqttJwtTokenRetriever
and 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
C8yMqttJwtTokenRetriever
and 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.
C8YJwtRetriever
returnsHeaderMap
, previously it was just JWT token (String
).Auth
enum 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_plugin
seems duplicated toC8YJwtRetriever
implementation...=> I understand they are different level.
Types of changes
Paste Link to the issue
#3036
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments