Skip to content

Commit

Permalink
[various] cleanup and prepare for 8.0.0-dev.1 release (#544)
Browse files Browse the repository at this point in the history
* adjusted api docs for ExternalAgentType

* renamed file for GrantType class

* bumped minimum iOS plugin requirement to 11.0 to align with Flutter 3.13.0

* bumped macOS platform and target info to 10.14 to align with Flutter 3.13.0

* renamed ExternalAgentType and updated API docs for the enum

* renamed ExternalAgentType enum, preferredExternalAgent prop and updated more api docs

* updated mapping of ExternalUserAgent to native representing to be integer/index-based instead of string

suppressed deprecation warnings

Revert "suppressed deprecation warnings"

This reverts commit d20926f8f813a5198a7a34d047a3a0920494cf34.

* suppressed deprecation warning

* more updates to ExternalUserAgent api docs

* bump version in pubspec and updated changelog entries

* attempt to add formatting jobs to workflow again

* Revert "attempt to add formatting jobs to workflow again"

This reverts commit a3f3b7d.
  • Loading branch information
MaikuB authored Sep 28, 2024
1 parent aefb746 commit 1b1db82
Show file tree
Hide file tree
Showing 24 changed files with 146 additions and 107 deletions.
9 changes: 9 additions & 0 deletions flutter_appauth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [8.0.0-dev.1]

* **Breaking change** Replaced the `preferEphemeralSession` property in the `AuthorizationRequest`, `AuthorizationTokenRequest` and `EndSessionRequest` classes with `externalUserAgent`. Thanks to the PR from [john-slow](https://github.com/john-slow). `externalUserAgent` is presented by the newly `ExternalUserAgent` enum that has the following values
* `asWebAuthenticationSession`: uses the [ASWebAuthenticationSession](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession) APIs where possible. This is the default value and was the default behaviour behaviour that aligns with what the AppAuth iOS SDK would do in choosing the best available user-agent
* `ephemeralAsWebAuthenticationSession`: uses an ephemeral session via the [ASWebAuthenticationSession](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession) APIs. Applications that previously used `preferEphemeralSession` and specified to be `true` can migrate by specifying this enum value
* `sfSafariViewController`: uses the [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) APIs
* Updated iOS plugin details to indicate it needs a minimum iOS version of 11.0. This aligns with the minimum best supported version for Flutter 3.13.0
* Updated macOS plugin details to indicate it needs a minimum iOS version of 10.14. This aligns with the minimum best supported version for Flutter 3.13.0

# 7.0.0

* **Breaking change** Bumped minimum Flutter and Dart SDK constraints to 3.13.0 and 3.1.0 respectively
Expand Down
22 changes: 11 additions & 11 deletions flutter_appauth/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class _MyAppState extends State<MyApp> {
textAlign: TextAlign.center,
),
onPressed: () => _signInWithAutoCodeExchange(
preferredExternalAgent: ExternalAgentType
externalUserAgent: ExternalUserAgent
.ephemeralAsWebAuthenticationSession),
),
),
Expand All @@ -122,8 +122,8 @@ class _MyAppState extends State<MyApp> {
textAlign: TextAlign.center,
),
onPressed: () => _signInWithAutoCodeExchange(
preferredExternalAgent:
ExternalAgentType.sfSafariViewController),
externalUserAgent:
ExternalUserAgent.sfSafariViewController),
),
),
ElevatedButton(
Expand All @@ -146,7 +146,7 @@ class _MyAppState extends State<MyApp> {
onPressed: _idToken != null
? () async {
await _endSession(
preferredExternalAgent: ExternalAgentType
externalUserAgent: ExternalUserAgent
.ephemeralAsWebAuthenticationSession);
}
: null,
Expand All @@ -160,7 +160,7 @@ class _MyAppState extends State<MyApp> {
onPressed: _idToken != null
? () async {
await _endSession(
preferredExternalAgent: ExternalAgentType
externalUserAgent: ExternalUserAgent
.sfSafariViewController);
}
: null,
Expand Down Expand Up @@ -201,15 +201,15 @@ class _MyAppState extends State<MyApp> {
}

Future<void> _endSession(
{ExternalAgentType preferredExternalAgent =
ExternalAgentType.asWebAuthenticationSession}) async {
{ExternalUserAgent externalUserAgent =
ExternalUserAgent.asWebAuthenticationSession}) async {
try {
_setBusyState();
await _appAuth.endSession(EndSessionRequest(
idTokenHint: _idToken,
postLogoutRedirectUrl: _postLogoutRedirectUrl,
serviceConfiguration: _serviceConfiguration,
preferredExternalAgent: preferredExternalAgent));
externalUserAgent: externalUserAgent));
_clearSessionInfo();
} catch (e) {
_handleError(e);
Expand Down Expand Up @@ -332,8 +332,8 @@ class _MyAppState extends State<MyApp> {
}

Future<void> _signInWithAutoCodeExchange(
{ExternalAgentType preferredExternalAgent =
ExternalAgentType.asWebAuthenticationSession}) async {
{ExternalUserAgent externalUserAgent =
ExternalUserAgent.asWebAuthenticationSession}) async {
try {
_setBusyState();

Expand All @@ -346,7 +346,7 @@ class _MyAppState extends State<MyApp> {
AuthorizationTokenRequest(_clientId, _redirectUrl,
serviceConfiguration: _serviceConfiguration,
scopes: _scopes,
preferredExternalAgent: preferredExternalAgent),
externalUserAgent: externalUserAgent),
);

/*
Expand Down
26 changes: 13 additions & 13 deletions flutter_appauth/ios/Classes/AppAuthIOSAuthorization.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@implementation AppAuthIOSAuthorization

- (id<OIDExternalUserAgentSession>) performAuthorization:(OIDServiceConfiguration *)serviceConfiguration clientId:(NSString*)clientId clientSecret:(NSString*)clientSecret scopes:(NSArray *)scopes redirectUrl:(NSString*)redirectUrl additionalParameters:(NSDictionary *)additionalParameters preferredExternalAgent:(NSString*)preferredExternalAgent result:(FlutterResult)result exchangeCode:(BOOL)exchangeCode nonce:(NSString*)nonce{
- (id<OIDExternalUserAgentSession>) performAuthorization:(OIDServiceConfiguration *)serviceConfiguration clientId:(NSString*)clientId clientSecret:(NSString*)clientSecret scopes:(NSArray *)scopes redirectUrl:(NSString*)redirectUrl additionalParameters:(NSDictionary *)additionalParameters externalUserAgent:(NSNumber*)externalUserAgent result:(FlutterResult)result exchangeCode:(BOOL)exchangeCode nonce:(NSString*)nonce{
NSString *codeVerifier = [OIDAuthorizationRequest generateCodeVerifier];
NSString *codeChallenge = [OIDAuthorizationRequest codeChallengeS256ForVerifier:codeVerifier];

Expand All @@ -21,8 +21,8 @@ @implementation AppAuthIOSAuthorization
additionalParameters:additionalParameters];
UIViewController *rootViewController = [self rootViewController];
if(exchangeCode) {
id<OIDExternalUserAgent> externalUserAgent = [self userAgentWithViewController:rootViewController preferredExternalAgent:preferredExternalAgent];
return [OIDAuthState authStateByPresentingAuthorizationRequest:request externalUserAgent:externalUserAgent callback:^(OIDAuthState *_Nullable authState,
id<OIDExternalUserAgent> agent = [self userAgentWithViewController:rootViewController externalUserAgent:externalUserAgent];
return [OIDAuthState authStateByPresentingAuthorizationRequest:request externalUserAgent:agent callback:^(OIDAuthState *_Nullable authState,
NSError *_Nullable error) {
if(authState) {
result([FlutterAppAuth processResponses:authState.lastTokenResponse authResponse:authState.lastAuthorizationResponse]);
Expand All @@ -32,8 +32,8 @@ @implementation AppAuthIOSAuthorization
}
}];
} else {
id<OIDExternalUserAgent> externalUserAgent = [self userAgentWithViewController:rootViewController preferredExternalAgent:preferredExternalAgent];
return [OIDAuthorizationService presentAuthorizationRequest:request externalUserAgent:externalUserAgent callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse, NSError *_Nullable error) {
id<OIDExternalUserAgent> agent = [self userAgentWithViewController:rootViewController externalUserAgent:externalUserAgent];
return [OIDAuthorizationService presentAuthorizationRequest:request externalUserAgent:agent callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse, NSError *_Nullable error) {
if(authorizationResponse) {
NSMutableDictionary *processedResponse = [[NSMutableDictionary alloc] init];
[processedResponse setObject:authorizationResponse.additionalParameters forKey:@"authorizationAdditionalParameters"];
Expand All @@ -56,7 +56,7 @@ @implementation AppAuthIOSAuthorization
additionalParameters:requestParameters.additionalParameters];

UIViewController *rootViewController = [self rootViewController];
id<OIDExternalUserAgent> externalUserAgent = [self userAgentWithViewController:rootViewController preferredExternalAgent:requestParameters.preferredExternalAgent];
id<OIDExternalUserAgent> externalUserAgent = [self userAgentWithViewController:rootViewController externalUserAgent:requestParameters.externalUserAgent];


return [OIDAuthorizationService presentEndSessionRequest:endSessionRequest externalUserAgent:externalUserAgent callback:^(OIDEndSessionResponse * _Nullable endSessionResponse, NSError * _Nullable error) {
Expand All @@ -71,17 +71,17 @@ @implementation AppAuthIOSAuthorization
}];
}

- (id<OIDExternalUserAgent>)userAgentWithViewController:(UIViewController *)rootViewController preferredExternalAgent:(NSString*)preferredExternalAgent {
if ([preferredExternalAgent isEqual:@"ExternalAgentType.ephemeralAsWebAuthenticationSession"]) {
- (id<OIDExternalUserAgent>)userAgentWithViewController:(UIViewController *)rootViewController externalUserAgent:(NSNumber*)externalUserAgent {
if ([externalUserAgent integerValue] == EphemeralASWebAuthenticationSession) {
return [[OIDExternalUserAgentIOSNoSSO alloc]
initWithPresentingViewController:rootViewController];
} else if ([preferredExternalAgent isEqual:@"ExternalAgentType.sfSafariViewController"]) {
return [[OIDExternalUserAgentIOSSafariViewController alloc]
initWithPresentingViewController:rootViewController];
} else {
return [[OIDExternalUserAgentIOS alloc]
}
if ([externalUserAgent integerValue] == SafariViewController) {
return [[OIDExternalUserAgentIOSNoSSO alloc]
initWithPresentingViewController:rootViewController];
}
return [[OIDExternalUserAgentIOS alloc]
initWithPresentingViewController:rootViewController];
}

- (UIViewController *)rootViewController {
Expand Down
10 changes: 8 additions & 2 deletions flutter_appauth/ios/Classes/FlutterAppAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ static NSString *const END_SESSION_ERROR_MESSAGE_FORMAT = @"Failed to end sessio
@property(nonatomic, strong) NSString *discoveryUrl;
@property(nonatomic, strong) NSDictionary *serviceConfigurationParameters;
@property(nonatomic, strong) NSDictionary *additionalParameters;
@property(nonatomic, strong) NSString *preferredExternalAgent;
@property(nonatomic, strong) NSNumber *externalUserAgent;
@end

typedef NS_ENUM(NSInteger, ExternalUserAgent) {
ASWebAuthenticationSession,
EphemeralASWebAuthenticationSession,
SafariViewController
};

@interface AppAuthAuthorization : NSObject

- (id<OIDExternalUserAgentSession>)performAuthorization:(OIDServiceConfiguration *)serviceConfiguration clientId:(NSString*)clientId clientSecret:(NSString*)clientSecret scopes:(NSArray *)scopes redirectUrl:(NSString*)redirectUrl additionalParameters:(NSDictionary *)additionalParameters preferredExternalAgent:(NSString*)preferredExternalAgent result:(FlutterResult)result exchangeCode:(BOOL)exchangeCode nonce:(NSString*)nonce;
- (id<OIDExternalUserAgentSession>)performAuthorization:(OIDServiceConfiguration *)serviceConfiguration clientId:(NSString*)clientId clientSecret:(NSString*)clientSecret scopes:(NSArray *)scopes redirectUrl:(NSString*)redirectUrl additionalParameters:(NSDictionary *)additionalParameters externalUserAgent:(NSNumber*)externalUserAgent result:(FlutterResult)result exchangeCode:(BOOL)exchangeCode nonce:(NSString*)nonce;

- (id<OIDExternalUserAgentSession>)performEndSessionRequest:(OIDServiceConfiguration *)serviceConfiguration requestParameters:(EndSessionRequestParameters *)requestParameters result:(FlutterResult)result;

Expand Down
2 changes: 1 addition & 1 deletion flutter_appauth/ios/Classes/FlutterAppAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ + (NSString *) formatMessageWithError:(NSString *)messageFormat error:(NSError *

@implementation AppAuthAuthorization

- (id<OIDExternalUserAgentSession>)performAuthorization:(OIDServiceConfiguration *)serviceConfiguration clientId:(NSString*)clientId clientSecret:(NSString*)clientSecret scopes:(NSArray *)scopes redirectUrl:(NSString*)redirectUrl additionalParameters:(NSDictionary *)additionalParameters preferredExternalAgent:(NSString*)preferredExternalAgent result:(FlutterResult)result exchangeCode:(BOOL)exchangeCode nonce:(NSString*)nonce {
- (id<OIDExternalUserAgentSession>)performAuthorization:(OIDServiceConfiguration *)serviceConfiguration clientId:(NSString*)clientId clientSecret:(NSString*)clientSecret scopes:(NSArray *)scopes redirectUrl:(NSString*)redirectUrl additionalParameters:(NSDictionary *)additionalParameters externalUserAgent:(NSNumber*)externalUserAgent result:(FlutterResult)result exchangeCode:(BOOL)exchangeCode nonce:(NSString*)nonce {
return nil;
}

Expand Down
12 changes: 6 additions & 6 deletions flutter_appauth/ios/Classes/FlutterAppauthPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ @interface TokenRequestParameters : NSObject
@property(nonatomic, strong) NSArray *scopes;
@property(nonatomic, strong) NSDictionary *serviceConfigurationParameters;
@property(nonatomic, strong) NSDictionary *additionalParameters;
@property(nonatomic, strong) NSString *preferredExternalAgent;
@property(nonatomic, strong) NSNumber *externalUserAgent;

@end

Expand All @@ -47,7 +47,7 @@ - (void)processArguments:(NSDictionary *)arguments {
_scopes = [ArgumentProcessor processArgumentValue:arguments withKey:@"scopes"];
_serviceConfigurationParameters = [ArgumentProcessor processArgumentValue:arguments withKey:@"serviceConfiguration"];
_additionalParameters = [ArgumentProcessor processArgumentValue:arguments withKey:@"additionalParameters"];
_preferredExternalAgent = [ArgumentProcessor processArgumentValue:arguments withKey:@"preferredExternalAgent"];
_externalUserAgent = [ArgumentProcessor processArgumentValue:arguments withKey:@"externalUserAgent"];
}

- (id)initWithArguments:(NSDictionary *)arguments {
Expand Down Expand Up @@ -82,7 +82,7 @@ - (id)initWithArguments:(NSDictionary *)arguments {
_discoveryUrl = [ArgumentProcessor processArgumentValue:arguments withKey:@"discoveryUrl"];
_serviceConfigurationParameters = [ArgumentProcessor processArgumentValue:arguments withKey:@"serviceConfiguration"];
_additionalParameters = [ArgumentProcessor processArgumentValue:arguments withKey:@"additionalParameters"];
_preferredExternalAgent = [ArgumentProcessor processArgumentValue:arguments withKey:@"preferredExternalAgent"];
_externalUserAgent = [ArgumentProcessor processArgumentValue:arguments withKey:@"externalUserAgent"];
return self;
}
@end
Expand Down Expand Up @@ -149,7 +149,7 @@ -(void)handleAuthorizeMethodCall:(NSDictionary*)arguments result:(FlutterResult)

if(requestParameters.serviceConfigurationParameters != nil) {
OIDServiceConfiguration *serviceConfiguration = [self processServiceConfigurationParameters:requestParameters.serviceConfigurationParameters];
_currentAuthorizationFlow = [authorization performAuthorization:serviceConfiguration clientId:requestParameters.clientId clientSecret:requestParameters.clientSecret scopes:requestParameters.scopes redirectUrl:requestParameters.redirectUrl additionalParameters:requestParameters.additionalParameters preferredExternalAgent:requestParameters.preferredExternalAgent result:result exchangeCode:exchangeCode nonce:requestParameters.nonce];
_currentAuthorizationFlow = [authorization performAuthorization:serviceConfiguration clientId:requestParameters.clientId clientSecret:requestParameters.clientSecret scopes:requestParameters.scopes redirectUrl:requestParameters.redirectUrl additionalParameters:requestParameters.additionalParameters externalUserAgent:requestParameters.externalUserAgent result:result exchangeCode:exchangeCode nonce:requestParameters.nonce];
} else if (requestParameters.discoveryUrl) {
NSURL *discoveryUrl = [NSURL URLWithString:requestParameters.discoveryUrl];
[OIDAuthorizationService discoverServiceConfigurationForDiscoveryURL:discoveryUrl
Expand All @@ -161,7 +161,7 @@ -(void)handleAuthorizeMethodCall:(NSDictionary*)arguments result:(FlutterResult)
return;
}

self->_currentAuthorizationFlow = [authorization performAuthorization:configuration clientId:requestParameters.clientId clientSecret:requestParameters.clientSecret scopes:requestParameters.scopes redirectUrl:requestParameters.redirectUrl additionalParameters:requestParameters.additionalParameters preferredExternalAgent:requestParameters.preferredExternalAgent result:result exchangeCode:exchangeCode nonce:requestParameters.nonce];
self->_currentAuthorizationFlow = [authorization performAuthorization:configuration clientId:requestParameters.clientId clientSecret:requestParameters.clientSecret scopes:requestParameters.scopes redirectUrl:requestParameters.redirectUrl additionalParameters:requestParameters.additionalParameters externalUserAgent:requestParameters.externalUserAgent result:result exchangeCode:exchangeCode nonce:requestParameters.nonce];
}];
} else {
NSURL *issuerUrl = [NSURL URLWithString:requestParameters.issuer];
Expand All @@ -174,7 +174,7 @@ -(void)handleAuthorizeMethodCall:(NSDictionary*)arguments result:(FlutterResult)
return;
}

self->_currentAuthorizationFlow = [authorization performAuthorization:configuration clientId:requestParameters.clientId clientSecret:requestParameters.clientSecret scopes:requestParameters.scopes redirectUrl:requestParameters.redirectUrl additionalParameters:requestParameters.additionalParameters preferredExternalAgent:requestParameters.preferredExternalAgent result:result exchangeCode:exchangeCode nonce:requestParameters.nonce];
self->_currentAuthorizationFlow = [authorization performAuthorization:configuration clientId:requestParameters.clientId clientSecret:requestParameters.clientSecret scopes:requestParameters.scopes redirectUrl:requestParameters.redirectUrl additionalParameters:requestParameters.additionalParameters externalUserAgent:requestParameters.externalUserAgent result:result exchangeCode:exchangeCode nonce:requestParameters.nonce];
}];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ - (BOOL)presentExternalUserAgentRequest:(id<OIDExternalUserAgentRequest>)request
[_presentingViewController presentViewController:safariVC animated:YES completion:nil];
openedSafari = YES;
} else {
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
openedSafari = [[UIApplication sharedApplication] openURL:requestURL];
}

Expand Down Expand Up @@ -170,4 +171,4 @@ - (SFSafariViewController *)safariViewControllerWithURL:(NSURL *)URL NS_AVAILABL

@end

NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion flutter_appauth/ios/flutter_appauth.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A new flutter plugin project.
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'AppAuth', '1.7.4'
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '11.0'
s.resource_bundles = {'flutter_appauth_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
end

2 changes: 1 addition & 1 deletion flutter_appauth/lib/flutter_appauth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export 'package:flutter_appauth_platform_interface/flutter_appauth_platform_inte
AuthorizationTokenResponse,
EndSessionRequest,
EndSessionResponse,
ExternalAgentType,
ExternalUserAgent,
FlutterAppAuthOAuthError,
FlutterAppAuthPlatformErrorDetails,
FlutterAppAuthUserCancelledException,
Expand Down
Loading

0 comments on commit 1b1db82

Please sign in to comment.