-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: Added OidcTokenExpiredEvent
and OidcTokenExpiringEvent
#91
feat: Added OidcTokenExpiredEvent
and OidcTokenExpiringEvent
#91
Conversation
994a534
to
878f36f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #91 +/- ##
==========================================
- Coverage 21.34% 21.28% -0.07%
==========================================
Files 60 63 +3
Lines 1799 1809 +10
==========================================
+ Hits 384 385 +1
- Misses 1415 1424 +9 ☔ View full report in Codecov by Sentry. |
878f36f
to
670bd98
Compare
@@ -803,6 +794,8 @@ abstract class OidcUserManagerBase { | |||
|
|||
@protected | |||
Future<void> handleTokenExpiring(OidcToken event) async { | |||
settings.onTokenExpiring?.call(event); |
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.
should we still refresh using refreshToken
if the user provides their own onTokenExpiring
callback?
also would it make sense to expose a stream of expiring/expired events instead of callbacks ?
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.
should we still refresh using refreshToken if the user provides their own onTokenExpiring callback?
Maybe there are scenarios where the user has to do some preparatory work before refresh can happen?
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.
also would it make sense to expose a stream of expiring/expired events instead of callbacks ?
Whatever you prefer. I could also add events to the existing events
stream using new subclasses of OidcEvent
(OidcTokenExpiring
and OidcTokenExpired
)
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.
@ahmednfwela Any news from your side? Are there any open points that prevent you from merging this PR? This is somehow important to me as I'm currently referencing my fork in our production app 🙈
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 got busy the past months, I want to use a stream based approach instead of callbacks
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.
@ahmednfwela Please have another look, I changed to a stream-based approach. No idea why the CI run failed though (web integration tests)...
5004c16
to
efeae2d
Compare
hi @akaegi can you please rebase off the latest main to trigger the new CI ? |
…OidcTokenExpiringEvent/OidcTokenExpiredEvent
efeae2d
to
9a4cc47
Compare
done |
eventsController.add( | ||
OidcTokenExpiringEvent.now(currentToken: event), | ||
); | ||
|
||
final refreshToken = event.refreshToken; | ||
if (refreshToken == null) { |
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.
we should also check here if the server supports refresh_token grants
if (!discoveryDocument.grantTypesSupportedOrDefault
.contains(OidcConstants_GrantType.refreshToken)) {
//Server doesn't support refresh_token grant.
return;
}
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.
Added
please run dart format to fix ci |
OidcTokenExpiredEvent
and OidcTokenExpiringEvent
Thank you for merging @ahmednfwela |
Background: I use auth flow jwt-bearer where there is no refresh token. Still I want to auto-refresh before the token expires. The new callback
onTokenExpiring
can be used to achieve this.