Skip to content
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

Issue 245: Async token refresh #251

Merged
merged 8 commits into from
May 6, 2021
Merged

Issue 245: Async token refresh #251

merged 8 commits into from
May 6, 2021

Conversation

Tristan1900
Copy link
Member

Change log description
Currently token refresh is using a Runtime which makes it impossible to work in a async context. Use async way to refresh the token instead.

Purpose of the change
Fix #245

What the code does
Use async way to refresh token

Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
@Tristan1900 Tristan1900 requested a review from shrids April 29, 2021 23:27
Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
Wenqi Mou added 2 commits May 3, 2021 00:29
Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
fix
Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
@codecov-commenter
Copy link

codecov-commenter commented May 3, 2021

Codecov Report

Merging #251 (fd37f9a) into master (fff2b36) will decrease coverage by 0.08%.
The diff coverage is 57.69%.

@@            Coverage Diff             @@
##           master     #251      +/-   ##
==========================================
- Coverage   78.47%   78.38%   -0.09%     
==========================================
  Files          51       51              
  Lines       10412    10541     +129     
==========================================
+ Hits         8171     8263      +92     
- Misses       2241     2278      +37     
Impacted Files Coverage Δ
controller-client/src/mock_controller.rs 44.98% <0.00%> (-0.45%) ⬇️
wire_protocol/src/connection.rs 10.48% <0.00%> (-0.54%) ⬇️
config/src/credentials.rs 31.11% <14.81%> (-0.47%) ⬇️
controller-client/src/lib.rs 67.33% <66.95%> (+0.76%) ⬆️
controller-client/src/model_helper.rs 63.63% <90.00%> (+2.63%) ⬆️
config/src/lib.rs 97.34% <100.00%> (+0.02%) ⬆️
shared/src/lib.rs 88.11% <100.00%> (+0.35%) ⬆️
src/transaction/pinger.rs 78.20% <0.00%> (-0.47%) ⬇️
...c/transaction/transactional_event_stream_writer.rs 87.34% <0.00%> (+0.16%) ⬆️

controller-client/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@shrids shrids left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the code duplication comment the changes look good.

@shrids shrids requested a review from tkaitchuck May 3, 2021 08:28
Wenqi Mou added 4 commits May 3, 2021 10:25
Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
Signed-off-by: Wenqi Mou <wenqi.mou@dell.com>
self.stream
.as_mut()
.expect("get connection")
.flush()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API Flushes this stream, ensuring that all intermediately buffered contents reach their destination.
https://docs.rs/tokio-rustls/0.22.0/src/tokio_rustls/client.rs.html#93-94 snippet indicates a TlsStream.flush() is required to ensure data actually reaches the destination.
Is this different with a TcpStream ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think TcpStream itself doesn't have a buffer and any write is directly sent over the wire. However this TlsStream has a buffer inside that needs to be flushed. The name TlsStream is kind of misleading.

@shrids shrids merged commit 94a4351 into master May 6, 2021
@shrids shrids deleted the async-token-refresh branch May 6, 2021 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keycloak authentication token does not get refreshed
3 participants