From 4ce37dead7403fc8077d0d68530005c2a3a408df Mon Sep 17 00:00:00 2001 From: Lucas Farris Date: Mon, 12 Feb 2018 20:12:17 +0100 Subject: [PATCH] Reworking the changes so that it stays compatible with previous version --- AppAuth.xcodeproj/project.pbxproj | 16 +++++++-- Source/AppAuth.h | 2 ++ Source/OIDAuthState.h | 3 +- Source/OIDAuthState.m | 4 +-- Source/OIDAuthorizationFlowSession.h | 42 ++++++++++++++++++++++ Source/OIDAuthorizationService.h | 3 +- Source/OIDAuthorizationService.m | 13 +++++-- Source/iOS/OIDAuthState+IOS.h | 2 +- Source/iOS/OIDAuthState+IOS.m | 2 +- Source/iOS/OIDAuthorizationService+IOS.h | 2 +- Source/iOS/OIDAuthorizationService+IOS.m | 2 +- Source/macOS/OIDAuthState+Mac.h | 2 +- Source/macOS/OIDAuthState+Mac.m | 2 +- Source/macOS/OIDAuthorizationService+Mac.h | 2 +- Source/macOS/OIDAuthorizationService+Mac.m | 2 +- Source/macOS/OIDRedirectHTTPHandler.h | 6 ++-- Source/macOS/OIDRedirectHTTPHandler.m | 13 +++---- 17 files changed, 93 insertions(+), 25 deletions(-) create mode 100644 Source/OIDAuthorizationFlowSession.h diff --git a/AppAuth.xcodeproj/project.pbxproj b/AppAuth.xcodeproj/project.pbxproj index 0466acaf9..0e22f8e2b 100644 --- a/AppAuth.xcodeproj/project.pbxproj +++ b/AppAuth.xcodeproj/project.pbxproj @@ -370,6 +370,10 @@ 60140F801DE4344200DA0DC3 /* OIDRegistrationResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 60140F7F1DE4344200DA0DC3 /* OIDRegistrationResponse.m */; }; 60140F831DE43BAF00DA0DC3 /* OIDRegistrationRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 60140F821DE43BAF00DA0DC3 /* OIDRegistrationRequestTests.m */; }; 60140F861DE43CC700DA0DC3 /* OIDRegistrationResponseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 60140F851DE43CC700DA0DC3 /* OIDRegistrationResponseTests.m */; }; + A6339DAA20321ADD0043D1C9 /* OIDAuthorizationFlowSession.h in Headers */ = {isa = PBXBuildFile; fileRef = A6339DA3203211320043D1C9 /* OIDAuthorizationFlowSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A6339DAB20321AE50043D1C9 /* OIDAuthorizationFlowSession.h in Headers */ = {isa = PBXBuildFile; fileRef = A6339DA3203211320043D1C9 /* OIDAuthorizationFlowSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A6339DAC20321AE70043D1C9 /* OIDAuthorizationFlowSession.h in Headers */ = {isa = PBXBuildFile; fileRef = A6339DA3203211320043D1C9 /* OIDAuthorizationFlowSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A6339DAD20321AEB0043D1C9 /* OIDAuthorizationFlowSession.h in Headers */ = {isa = PBXBuildFile; fileRef = A6339DA3203211320043D1C9 /* OIDAuthorizationFlowSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; A6DEAB9B2018E4AD0022AC32 /* OIDExternalUserAgentUICoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = A6DEAB982018E4A20022AC32 /* OIDExternalUserAgentUICoordinator.h */; settings = {ATTRIBUTES = (Public, ); }; }; A6DEAB9C2018E4AD0022AC32 /* OIDExternalUserAgentUICoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = A6DEAB982018E4A20022AC32 /* OIDExternalUserAgentUICoordinator.h */; settings = {ATTRIBUTES = (Public, ); }; }; A6DEAB9D2018E4AD0022AC32 /* OIDExternalUserAgentUICoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = A6DEAB982018E4A20022AC32 /* OIDExternalUserAgentUICoordinator.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -565,6 +569,7 @@ 60140F821DE43BAF00DA0DC3 /* OIDRegistrationRequestTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OIDRegistrationRequestTests.m; sourceTree = ""; }; 60140F841DE43C8C00DA0DC3 /* OIDRegistrationResponseTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OIDRegistrationResponseTests.h; sourceTree = ""; }; 60140F851DE43CC700DA0DC3 /* OIDRegistrationResponseTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OIDRegistrationResponseTests.m; sourceTree = ""; }; + A6339DA3203211320043D1C9 /* OIDAuthorizationFlowSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OIDAuthorizationFlowSession.h; sourceTree = ""; }; A6DEAB982018E4A20022AC32 /* OIDExternalUserAgentUICoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OIDExternalUserAgentUICoordinator.h; sourceTree = ""; }; A6DEAB992018E4A20022AC32 /* OIDExternalUserAgentFlowSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OIDExternalUserAgentFlowSession.h; sourceTree = ""; }; A6DEAB9A2018E4A20022AC32 /* OIDExternalUserAgentRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OIDExternalUserAgentRequest.h; sourceTree = ""; }; @@ -740,6 +745,7 @@ 340DAE241D581FE700EC285B /* macOS */, F6F60FAF1D2BFEF000325CB3 /* iOS */, 341741AF1C5D8243000EF209 /* AppAuth.h */, + A6339DA3203211320043D1C9 /* OIDAuthorizationFlowSession.h */, 341741B41C5D8243000EF209 /* OIDAuthorizationRequest.h */, 341741B51C5D8243000EF209 /* OIDAuthorizationRequest.m */, 341741B61C5D8243000EF209 /* OIDAuthorizationResponse.h */, @@ -748,9 +754,6 @@ 341741B91C5D8243000EF209 /* OIDAuthorizationService.m */, 341741BA1C5D8243000EF209 /* OIDAuthState.h */, 341741BB1C5D8243000EF209 /* OIDAuthState.m */, - A6DEAB992018E4A20022AC32 /* OIDExternalUserAgentFlowSession.h */, - A6DEAB9A2018E4A20022AC32 /* OIDExternalUserAgentRequest.h */, - A6DEAB982018E4A20022AC32 /* OIDExternalUserAgentUICoordinator.h */, 341741BC1C5D8243000EF209 /* OIDAuthStateChangeDelegate.h */, 341741BD1C5D8243000EF209 /* OIDAuthStateErrorDelegate.h */, 60140F781DE4262000DA0DC3 /* OIDClientMetadataParameters.h */, @@ -760,6 +763,9 @@ 341741C01C5D8243000EF209 /* OIDError.m */, 341741C11C5D8243000EF209 /* OIDErrorUtilities.h */, 341741C21C5D8243000EF209 /* OIDErrorUtilities.m */, + A6DEAB992018E4A20022AC32 /* OIDExternalUserAgentFlowSession.h */, + A6DEAB9A2018E4A20022AC32 /* OIDExternalUserAgentRequest.h */, + A6DEAB982018E4A20022AC32 /* OIDExternalUserAgentUICoordinator.h */, 341741C31C5D8243000EF209 /* OIDFieldMapping.h */, 341741C41C5D8243000EF209 /* OIDFieldMapping.m */, 60140F7E1DE4335200DA0DC3 /* OIDRegistrationResponse.h */, @@ -909,6 +915,7 @@ 343AAAF91E83499000F9D36E /* OIDTokenUtilities.h in Headers */, 343AAAEC1E83499000F9D36E /* OIDError.h in Headers */, A6DEABAB2018E5C50022AC32 /* OIDExternalUserAgentUICoordinatorIOS.h in Headers */, + A6339DAA20321ADD0043D1C9 /* OIDAuthorizationFlowSession.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -936,6 +943,7 @@ 343AAB101E83499100F9D36E /* OIDTokenResponse.h in Headers */, 343AAAFC1E83499100F9D36E /* OIDAuthorizationResponse.h in Headers */, 343AAB0C1E83499100F9D36E /* OIDScopeUtilities.h in Headers */, + A6339DAB20321AE50043D1C9 /* OIDAuthorizationFlowSession.h in Headers */, 343AAB011E83499100F9D36E /* OIDAuthStateErrorDelegate.h in Headers */, 343AAAFB1E83499100F9D36E /* OIDAuthorizationRequest.h in Headers */, 343AAB051E83499100F9D36E /* OIDErrorUtilities.h in Headers */, @@ -966,6 +974,7 @@ 343AAB281E83499200F9D36E /* OIDTokenResponse.h in Headers */, 343AAB141E83499200F9D36E /* OIDAuthorizationResponse.h in Headers */, 343AAB241E83499200F9D36E /* OIDScopeUtilities.h in Headers */, + A6339DAC20321AE70043D1C9 /* OIDAuthorizationFlowSession.h in Headers */, 343AAB191E83499200F9D36E /* OIDAuthStateErrorDelegate.h in Headers */, 343AAB131E83499200F9D36E /* OIDAuthorizationRequest.h in Headers */, 343AAB1D1E83499200F9D36E /* OIDErrorUtilities.h in Headers */, @@ -998,6 +1007,7 @@ 343AAAE11E83494A00F9D36E /* OIDLoopbackHTTPServer.h in Headers */, 343AAB311E83499200F9D36E /* OIDAuthStateErrorDelegate.h in Headers */, 343AAB2F1E83499200F9D36E /* OIDAuthState.h in Headers */, + A6339DAD20321AEB0043D1C9 /* OIDAuthorizationFlowSession.h in Headers */, 343AAB3E1E83499200F9D36E /* OIDServiceDiscovery.h in Headers */, A6DEAB9E2018E4AE0022AC32 /* OIDExternalUserAgentUICoordinator.h in Headers */, 343AAADE1E83494400F9D36E /* OIDAuthorizationService+Mac.h in Headers */, diff --git a/Source/AppAuth.h b/Source/AppAuth.h index c3bd90c97..873590536 100644 --- a/Source/AppAuth.h +++ b/Source/AppAuth.h @@ -17,6 +17,7 @@ */ #import "OIDAuthState.h" +#import "OIDAuthorizationFlowSession.h" #import "OIDAuthStateChangeDelegate.h" #import "OIDAuthStateErrorDelegate.h" #import "OIDAuthorizationRequest.h" @@ -24,6 +25,7 @@ #import "OIDAuthorizationService.h" #import "OIDError.h" #import "OIDErrorUtilities.h" +#import "OIDExternalUserAgentFlowSession.h" #import "OIDExternalUserAgentUICoordinator.h" #import "OIDGrantTypes.h" #import "OIDRegistrationRequest.h" diff --git a/Source/OIDAuthState.h b/Source/OIDAuthState.h index fbd3ac206..c45c5a32b 100644 --- a/Source/OIDAuthState.h +++ b/Source/OIDAuthState.h @@ -23,6 +23,7 @@ @class OIDRegistrationResponse; @class OIDTokenResponse; @class OIDTokenRequest; +@protocol OIDAuthorizationFlowSession; @protocol OIDAuthStateChangeDelegate; @protocol OIDAuthStateErrorDelegate; @protocol OIDExternalUserAgentUICoordinator; @@ -148,7 +149,7 @@ typedef void (^OIDAuthStateAuthorizationCallback)(OIDAuthState *_Nullable authSt receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a @c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message. */ -+ (id) ++ (id) authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest UICoordinator:(id)UICoordinator callback:(OIDAuthStateAuthorizationCallback)callback; diff --git a/Source/OIDAuthState.m b/Source/OIDAuthState.m index b4162c79a..c2832b5d1 100644 --- a/Source/OIDAuthState.m +++ b/Source/OIDAuthState.m @@ -104,12 +104,12 @@ @implementation OIDAuthState #pragma mark - Convenience initializers -+ (id) ++ (id) authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest UICoordinator:(id)UICoordinator callback:(OIDAuthStateAuthorizationCallback)callback { // presents the authorization request - id authFlowSession = [OIDAuthorizationService + id authFlowSession = [OIDAuthorizationService presentAuthorizationRequest:authorizationRequest UICoordinator:UICoordinator callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse, diff --git a/Source/OIDAuthorizationFlowSession.h b/Source/OIDAuthorizationFlowSession.h new file mode 100644 index 000000000..0201e3520 --- /dev/null +++ b/Source/OIDAuthorizationFlowSession.h @@ -0,0 +1,42 @@ +/*! @file OIDAuthorizationRequest.h + @brief AppAuth iOS SDK + @copyright + Copyright 2015 Google Inc. All Rights Reserved. + @copydetails + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +/*! @brief Represents an in-flight authorization flow session. + */ +@protocol OIDAuthorizationFlowSession + +/*! @brief Clients should call this method with the result of the authorization code flow if it + becomes available. + @param URL The redirect URL invoked by the authorization server. + @discussion When the URL represented a valid authorization response, implementations + should clean up any left-over UI state from the authorization, for example by + closing the \SFSafariViewController or looback HTTP listener if those were used. + The completion block of the pending authorization request should then be invoked. + @remarks Has no effect if called more than once, or after a @c cancel message was received. + @return YES if the passed URL matches the expected redirect URL and was consumed, NO otherwise. + */ +- (BOOL)resumeAuthorizationFlowWithURL:(NSURL *)URL; + +/*! @brief @c OIDAuthorizationUICoordinator or clients should call this method when the + authorization flow failed with a non-OAuth error. + @param error The error that is the reason for the failure of this authorization flow. + @remarks Has no effect if called more than once, or after a @c cancel message was received. + */ +- (void)failAuthorizationFlowWithError:(NSError *)error; + +@end diff --git a/Source/OIDAuthorizationService.h b/Source/OIDAuthorizationService.h index bd1554c6f..6bf8f3418 100644 --- a/Source/OIDAuthorizationService.h +++ b/Source/OIDAuthorizationService.h @@ -26,6 +26,7 @@ @class OIDServiceConfiguration; @class OIDTokenRequest; @class OIDTokenResponse; +@protocol OIDAuthorizationFlowSession; @protocol OIDExternalUserAgentFlowSession; @protocol OIDExternalUserAgentUICoordinator; @@ -119,7 +120,7 @@ typedef void (^OIDRegistrationCompletion)(OIDRegistrationResponse *_Nullable reg receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a @c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message. */ -+ (id) ++ (id) presentAuthorizationRequest:(OIDAuthorizationRequest *)request UICoordinator:(id)UICoordinator callback:(OIDAuthorizationCallback)callback; diff --git a/Source/OIDAuthorizationService.m b/Source/OIDAuthorizationService.m index 13bab356a..9ee53f6b7 100644 --- a/Source/OIDAuthorizationService.m +++ b/Source/OIDAuthorizationService.m @@ -22,6 +22,7 @@ #import "OIDAuthorizationResponse.h" #import "OIDDefines.h" #import "OIDErrorUtilities.h" +#import "OIDAuthorizationFlowSession.h" #import "OIDExternalUserAgentFlowSession.h" #import "OIDExternalUserAgentUICoordinator.h" #import "OIDRegistrationRequest.h" @@ -41,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface OIDAuthorizationFlowSessionImplementation : NSObject { +@interface OIDAuthorizationFlowSessionImplementation : NSObject { // private variables OIDAuthorizationRequest *_request; id _UICoordinator; @@ -170,6 +171,14 @@ - (void)didFinishWithResponse:(nullable OIDAuthorizationResponse *)response } } +- (void)failAuthorizationFlowWithError:(NSError *)error { + [self failAuthorizationFlowWithError:error]; +} + +- (BOOL)resumeAuthorizationFlowWithURL:(NSURL *)URL { + return [self resumeExternalUserAgentFlowWithURL:URL]; +} + @end @implementation OIDAuthorizationService @@ -244,7 +253,7 @@ + (void)discoverServiceConfigurationForDiscoveryURL:(NSURL *)discoveryURL #pragma mark - Authorization Endpoint -+ (id) ++ (id) presentAuthorizationRequest:(OIDAuthorizationRequest *)request UICoordinator:(id)UICoordinator callback:(OIDAuthorizationCallback)callback { diff --git a/Source/iOS/OIDAuthState+IOS.h b/Source/iOS/OIDAuthState+IOS.h index fbf4d2b19..a55fab2c7 100644 --- a/Source/iOS/OIDAuthState+IOS.h +++ b/Source/iOS/OIDAuthState+IOS.h @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a @c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message. */ -+ (id) ++ (id) authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest presentingViewController:(UIViewController *)presentingViewController callback:(OIDAuthStateAuthorizationCallback)callback; diff --git a/Source/iOS/OIDAuthState+IOS.m b/Source/iOS/OIDAuthState+IOS.m index 0129524c2..01e60c21e 100644 --- a/Source/iOS/OIDAuthState+IOS.m +++ b/Source/iOS/OIDAuthState+IOS.m @@ -22,7 +22,7 @@ @implementation OIDAuthState (IOS) -+ (id) ++ (id) authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest presentingViewController:(UIViewController *)presentingViewController callback:(OIDAuthStateAuthorizationCallback)callback { diff --git a/Source/iOS/OIDAuthorizationService+IOS.h b/Source/iOS/OIDAuthorizationService+IOS.h index 91ca35748..fc81a4460 100644 --- a/Source/iOS/OIDAuthorizationService+IOS.h +++ b/Source/iOS/OIDAuthorizationService+IOS.h @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a @c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message. */ -+ (id) ++ (id) presentAuthorizationRequest:(OIDAuthorizationRequest *)request presentingViewController:(UIViewController *)presentingViewController callback:(OIDAuthorizationCallback)callback; diff --git a/Source/iOS/OIDAuthorizationService+IOS.m b/Source/iOS/OIDAuthorizationService+IOS.m index 8e34b042c..42fd7dfcc 100644 --- a/Source/iOS/OIDAuthorizationService+IOS.m +++ b/Source/iOS/OIDAuthorizationService+IOS.m @@ -24,7 +24,7 @@ @implementation OIDAuthorizationService (IOS) -+ (id) ++ (id) presentAuthorizationRequest:(OIDAuthorizationRequest *)request presentingViewController:(UIViewController *)presentingViewController callback:(OIDAuthorizationCallback)callback { diff --git a/Source/macOS/OIDAuthState+Mac.h b/Source/macOS/OIDAuthState+Mac.h index 8a3140959..4103a75a5 100644 --- a/Source/macOS/OIDAuthState+Mac.h +++ b/Source/macOS/OIDAuthState+Mac.h @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a @c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message. */ -+ (id) ++ (id) authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest callback:(OIDAuthStateAuthorizationCallback)callback; @end diff --git a/Source/macOS/OIDAuthState+Mac.m b/Source/macOS/OIDAuthState+Mac.m index 8ec007f9b..6e7562ca9 100644 --- a/Source/macOS/OIDAuthState+Mac.m +++ b/Source/macOS/OIDAuthState+Mac.m @@ -22,7 +22,7 @@ @implementation OIDAuthState (Mac) -+ (id) ++ (id) authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest callback:(OIDAuthStateAuthorizationCallback)callback { OIDExternalUserAgentUICoordinatorMac *coordinator = [[OIDExternalUserAgentUICoordinatorMac alloc] init]; diff --git a/Source/macOS/OIDAuthorizationService+Mac.h b/Source/macOS/OIDAuthorizationService+Mac.h index 556f79024..ce4cf9569 100644 --- a/Source/macOS/OIDAuthorizationService+Mac.h +++ b/Source/macOS/OIDAuthorizationService+Mac.h @@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a @c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message. */ -+ (id)presentAuthorizationRequest:(OIDAuthorizationRequest *)request ++ (id)presentAuthorizationRequest:(OIDAuthorizationRequest *)request callback:(OIDAuthorizationCallback)callback; @end diff --git a/Source/macOS/OIDAuthorizationService+Mac.m b/Source/macOS/OIDAuthorizationService+Mac.m index cd8fa9124..c7dd2076f 100644 --- a/Source/macOS/OIDAuthorizationService+Mac.m +++ b/Source/macOS/OIDAuthorizationService+Mac.m @@ -24,7 +24,7 @@ @implementation OIDAuthorizationService (Mac) -+ (id)presentAuthorizationRequest:(OIDAuthorizationRequest *)request ++ (id)presentAuthorizationRequest:(OIDAuthorizationRequest *)request callback:(OIDAuthorizationCallback)callback { OIDExternalUserAgentUICoordinatorMac *coordinator = [[OIDExternalUserAgentUICoordinatorMac alloc] init]; return [self presentAuthorizationRequest:request UICoordinator:coordinator callback:callback]; diff --git a/Source/macOS/OIDRedirectHTTPHandler.h b/Source/macOS/OIDRedirectHTTPHandler.h index 9a7c3b21d..59212fb9c 100644 --- a/Source/macOS/OIDRedirectHTTPHandler.h +++ b/Source/macOS/OIDRedirectHTTPHandler.h @@ -21,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @class HTTPServer; +@protocol OIDAuthorizationFlowSession; @protocol OIDExternalUserAgentFlowSession; /*! @brief Start a HTTP server on the loopback interface (i.e. @c 127.0.0.1) to receive the OAuth @@ -31,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN HTTPServer *_httpServ; NSURL *_successURL; // property variables - NSObject *_currentExternalUserAgentFlow; + NSObject *_currentAuthorizationFlow; } /*! @brief The external user-agent request flow session which receives the return URL from the @@ -40,7 +41,8 @@ NS_ASSUME_NONNULL_BEGIN redirect handler to continue the flow. This should be set while an external user-agent request flow is in progress. */ -@property(nonatomic, strong, nullable) id currentExternalUserAgentFlow; +@property(nonatomic, strong, nullable) id currentAuthorizationFlow; /*! @brief Creates an a loopback HTTP redirect URI handler with the given success URL. @param successURL The URL that the user is redirected to after the request flow completes diff --git a/Source/macOS/OIDRedirectHTTPHandler.m b/Source/macOS/OIDRedirectHTTPHandler.m index b20646e79..4b284e69b 100644 --- a/Source/macOS/OIDRedirectHTTPHandler.m +++ b/Source/macOS/OIDRedirectHTTPHandler.m @@ -18,6 +18,7 @@ #import "OIDRedirectHTTPHandler.h" +#import "OIDAuthorizationFlowSession.h" #import "OIDAuthorizationService.h" #import "OIDErrorUtilities.h" #import "OIDExternalUserAgentFlowSession.h" @@ -49,7 +50,7 @@ @implementation OIDRedirectHTTPHandler -@synthesize currentExternalUserAgentFlow = _currentExternalUserAgentFlow; +@synthesize currentAuthorizationFlow = _currentAuthorizationFlow; - (instancetype)init { return [self initWithSuccessURL:nil]; @@ -98,8 +99,8 @@ - (void)cancelHTTPListener { [OIDErrorUtilities errorWithCode:OIDErrorCodeProgramCanceledAuthorizationFlow underlyingError:nil description:@"The HTTP listener was cancelled programmatically."]; - [_currentExternalUserAgentFlow failExternalUserAgentFlowWithError:cancelledError]; - _currentExternalUserAgentFlow = nil; + [_currentAuthorizationFlow failExternalUserAgentFlowWithError:cancelledError]; + _currentAuthorizationFlow = nil; } /*! @brief Stops listening on the loopback interface without modifying the state of the @@ -115,11 +116,11 @@ - (void)stopHTTPListener { - (void)HTTPConnection:(HTTPConnection *)conn didReceiveRequest:(HTTPServerRequest *)mess { // Sends URL to AppAuth. CFURLRef url = CFHTTPMessageCopyRequestURL(mess.request); - BOOL handled = [_currentExternalUserAgentFlow resumeExternalUserAgentFlowWithURL:(__bridge NSURL *)url]; + BOOL handled = [_currentAuthorizationFlow resumeExternalUserAgentFlowWithURL:(__bridge NSURL *)url]; // Stops listening to further requests after the first valid authorization response. if (handled) { - _currentExternalUserAgentFlow = nil; + _currentAuthorizationFlow = nil; [self stopHTTPListener]; } @@ -128,7 +129,7 @@ - (void)HTTPConnection:(HTTPConnection *)conn didReceiveRequest:(HTTPServerReque NSInteger httpResponseCode = (_successURL) ? 302 : 200; // Returns an error page if a URL other than the expected redirect is requested. if (!handled) { - if (_currentExternalUserAgentFlow) { + if (_currentAuthorizationFlow) { bodyText = kHTMLErrorRedirectNotValid; httpResponseCode = 404; } else {