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

[flutter_appauth] added logic to recreate AuthorizationService objects if disposed but were needed #556

Merged
merged 6 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flutter_appauth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [8.0.0-dev.4]

* [Android] no functional changes but some code around dealing with `allowInsecureConnections` has been done in response to issue [554](https://github.com/MaikuB/flutter_appauth/issues/554)
* [Android] some refactoring around code related to `allowInsecureConnections` has been done in response to issue [554](https://github.com/MaikuB/flutter_appauth/issues/554)
* [Android] added logic to help with issues like [205](https://github.com/MaikuB/flutter_appauth/issues/205) where an app tries to refresh a token but the instances of `AuthorizationService` have been disposed

## [8.0.0-dev.3]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,17 @@ public void onDetachedFromActivity() {
}

private void createAuthorizationServices() {
defaultAuthorizationService = new AuthorizationService(this.applicationContext);
AppAuthConfiguration.Builder authConfigBuilder = new AppAuthConfiguration.Builder();
authConfigBuilder.setConnectionBuilder(InsecureConnectionBuilder.INSTANCE);
authConfigBuilder.setSkipIssuerHttpsCheck(true);
insecureAuthorizationService =
new AuthorizationService(applicationContext, authConfigBuilder.build());
if (defaultAuthorizationService == null) {
defaultAuthorizationService = new AuthorizationService(this.applicationContext);
}

if (insecureAuthorizationService == null) {
AppAuthConfiguration.Builder authConfigBuilder = new AppAuthConfiguration.Builder();
authConfigBuilder.setConnectionBuilder(InsecureConnectionBuilder.INSTANCE);
authConfigBuilder.setSkipIssuerHttpsCheck(true);
insecureAuthorizationService =
new AuthorizationService(applicationContext, authConfigBuilder.build());
}
}

private void disposeAuthorizationServices() {
Expand Down Expand Up @@ -579,6 +584,9 @@ private void performEndSessionRequest(
}

private AuthorizationService getAuthorizationService() {
// Call to createAuthorizationService() is done as there have been some reported instances where
// the services have been disposed but they're still needed e.g. to refresh tokens
createAuthorizationServices();
AuthorizationService authorizationService =
allowInsecureConnections ? insecureAuthorizationService : defaultAuthorizationService;
return authorizationService;
Expand Down
Loading