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

Refresh tokens 60 seconds before expire #165

Merged
merged 2 commits into from
Oct 1, 2022
Merged

Refresh tokens 60 seconds before expire #165

merged 2 commits into from
Oct 1, 2022

Conversation

ryanmelt
Copy link
Member

closes #142

@ryanmelt ryanmelt requested a review from jmthomas September 30, 2022 04:24
@codecov
Copy link

codecov bot commented Sep 30, 2022

Codecov Report

Base: 73.58% // Head: 73.55% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (e5d74bc) compared to base (98f6e88).
Patch coverage: 6.25% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
- Coverage   73.58%   73.55%   -0.04%     
==========================================
  Files         411      411              
  Lines       25526    25535       +9     
  Branches      561      561              
==========================================
- Hits        18783    18781       -2     
- Misses       6657     6668      +11     
  Partials       86       86              
Flag Coverage Δ
ruby-api 41.77% <0.00%> (-0.12%) ⬇️
ruby-backend 78.17% <20.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...enc3-cmd-tlm-api/app/controllers/api_controller.rb 11.47% <0.00%> (-1.74%) ⬇️
openc3/lib/openc3/utilities/authentication.rb 25.37% <20.00%> (+1.13%) ⬆️
openc3/lib/openc3/utilities/metric.rb 90.19% <0.00%> (-5.89%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

status = 401
content_type = "application/json-rpc"
body = response.to_json(:allow_nan => true)
end
Copy link
Member

Choose a reason for hiding this comment

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

So you're rescuing AuthErrors and explicitly setting the response. This will aid debugging but doesn't fix any issues with authentication.

@expires_at = current_time + oath["expires_in"]
@refresh_expires_at = current_time + oath["refresh_expires_in"]
@expires_at = current_time + oath["expires_in"] - REFRESH_OFFSET_SECONDS
@refresh_expires_at = current_time + oath["refresh_expires_in"] - REFRESH_OFFSET_SECONDS
Copy link
Member

Choose a reason for hiding this comment

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

Ahh we were previously letting the token go right down to the wire and then recreating? Do you think this resulted in a single bad un-authenticated request before the token was regenerated? Does this still have an issue where by if you don't make a request within 60s of the token expiring it will result in a single failure?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it would have lead to edge case requests, that failed, and the next request should have refreshed the token. If you completely miss the token expiring then it will refresh (potentially a complete reissue).

@ryanmelt ryanmelt merged commit 64f30ef into master Oct 1, 2022
@ryanmelt ryanmelt deleted the auth_updates branch October 1, 2022 03:34
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.

Server Response 500 Error when server is under heavy command load
2 participants