Skip to content

Commit

Permalink
Renaming user agent to external user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Farris committed Jan 26, 2018
1 parent 67c291a commit e572a99
Show file tree
Hide file tree
Showing 26 changed files with 231 additions and 232 deletions.
100 changes: 50 additions & 50 deletions AppAuth.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Source/AppAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#import "OIDAuthorizationRequest.h"
#import "OIDAuthorizationResponse.h"
#import "OIDAuthorizationService.h"
#import "OIDUserAgentUICoordinator.h"
#import "OIDExternalUserAgentUICoordinator.h"
#import "OIDError.h"
#import "OIDErrorUtilities.h"
#import "OIDGrantTypes.h"
Expand All @@ -43,11 +43,11 @@
#elif TARGET_OS_IOS
#import "OIDAuthState+IOS.h"
#import "OIDAuthorizationService+IOS.h"
#import "OIDUserAgentUICoordinatorIOS.h"
#import "OIDExternalUserAgentUICoordinatorIOS.h"
#elif TARGET_OS_MAC
#import "OIDAuthState+Mac.h"
#import "OIDAuthorizationService+Mac.h"
#import "OIDUserAgentUICoordinatorMac.h"
#import "OIDExternalUserAgentUICoordinatorMac.h"
#import "OIDRedirectHTTPHandler.h"
#else
#error "Platform Undefined"
Expand Down
6 changes: 3 additions & 3 deletions Source/Framework/AppAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FOUNDATION_EXPORT const unsigned char AppAuthVersionString[];
#import <AppAuth/OIDAuthorizationRequest.h>
#import <AppAuth/OIDAuthorizationResponse.h>
#import <AppAuth/OIDAuthorizationService.h>
#import <AppAuth/OIDUserAgentUICoordinator.h>
#import <AppAuth/OIDExternalUserAgentUICoordinator.h>
#import <AppAuth/OIDError.h>
#import <AppAuth/OIDErrorUtilities.h>
#import <AppAuth/OIDGrantTypes.h>
Expand All @@ -50,11 +50,11 @@ FOUNDATION_EXPORT const unsigned char AppAuthVersionString[];
#elif TARGET_OS_IOS
#import <AppAuth/OIDAuthState+IOS.h>
#import <AppAuth/OIDAuthorizationService+IOS.h>
#import <AppAuth/OIDUserAgentUICoordinatorIOS.h>
#import <AppAuth/OIDExternalUserAgentUICoordinatorIOS.h>
#elif TARGET_OS_MAC
#import <AppAuth/OIDAuthState+Mac.h>
#import <AppAuth/OIDAuthorizationService+Mac.h>
#import <AppAuth/OIDUserAgentUICoordinatorMac.h>
#import <AppAuth/OIDExternalUserAgentUICoordinatorMac.h>
#import <AppAuth/OIDRedirectHTTPHandler.h>
#else
#error "Platform Undefined"
Expand Down
16 changes: 8 additions & 8 deletions Source/OIDAuthState.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
@class OIDTokenRequest;
@protocol OIDAuthStateChangeDelegate;
@protocol OIDAuthStateErrorDelegate;
@protocol OIDUserAgentUICoordinator;
@protocol OIDUserAgentFlowSession;
@protocol OIDExternalUserAgentUICoordinator;
@protocol OIDExternalUserAgentFlowSession;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -142,15 +142,15 @@ typedef void (^OIDAuthStateAuthorizationCallback)(OIDAuthState *_Nullable authSt
/*! @brief Convenience method to create a @c OIDAuthState by presenting an authorization request
and performing the authorization code exchange in the case of code flow requests.
@param authorizationRequest The authorization request to present.
@param UICoordinator Generic UI coordinator that can present an user-agent request.
@param UICoordinator Generic UI coordinator that can present an external user-agent request.
@param callback The method called when the request has completed or failed.
@return A @c OIDUserAgentFlowSession instance which will terminate when it
receives a @c OIDUserAgentFlowSession.cancel message, or after processing a
@c OIDUserAgentFlowSession.resumeUserAgentFlowWithURL: message.
@return A @c OIDExternalUserAgentFlowSession instance which will terminate when it
receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a
@c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message.
*/
+ (id<OIDUserAgentFlowSession>)
+ (id<OIDExternalUserAgentFlowSession>)
authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest
UICoordinator:(id<OIDUserAgentUICoordinator>)UICoordinator
UICoordinator:(id<OIDExternalUserAgentUICoordinator>)UICoordinator
callback:(OIDAuthStateAuthorizationCallback)callback;

/*! @internal
Expand Down
6 changes: 3 additions & 3 deletions Source/OIDAuthState.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ @implementation OIDAuthState

#pragma mark - Convenience initializers

+ (id<OIDUserAgentFlowSession>)
+ (id<OIDExternalUserAgentFlowSession>)
authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest
UICoordinator:(id<OIDUserAgentUICoordinator>)UICoordinator
UICoordinator:(id<OIDExternalUserAgentUICoordinator>)UICoordinator
callback:(OIDAuthStateAuthorizationCallback)callback {
// presents the authorization request
id<OIDUserAgentFlowSession> authFlowSession = [OIDAuthorizationService
id<OIDExternalUserAgentFlowSession> authFlowSession = [OIDAuthorizationService
presentAuthorizationRequest:authorizationRequest
UICoordinator:UICoordinator
callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse,
Expand Down
4 changes: 2 additions & 2 deletions Source/OIDAuthorizationRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// so they are imported here for convenience.
#import "OIDResponseTypes.h"
#import "OIDScopes.h"
#import "OIDUserAgentRequest.h"
#import "OIDExternalUserAgentRequest.h"

@class OIDServiceConfiguration;

Expand All @@ -38,7 +38,7 @@ extern NSString *const OIDOAuthorizationRequestCodeChallengeMethodS256;
@see https://tools.ietf.org/html/rfc6749#section-4
@see https://tools.ietf.org/html/rfc6749#section-4.1.1
*/
@interface OIDAuthorizationRequest : NSObject <NSCopying, NSSecureCoding, OIDUserAgentRequest> {
@interface OIDAuthorizationRequest : NSObject <NSCopying, NSSecureCoding, OIDExternalUserAgentRequest> {
// property variables
OIDServiceConfiguration *_configuration;
NSString *_responseType;
Expand Down
4 changes: 2 additions & 2 deletions Source/OIDAuthorizationRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ - (NSURL *)authorizationRequestURL {
return [query URLByReplacingQueryInURL:_configuration.authorizationEndpoint];
}

#pragma mark - OIDUserAgentRequest
#pragma mark - OIDExternalUserAgentRequest

- (NSURL *)userAgentRequestURL {
- (NSURL *)externalUserAgentRequestURL {
return [self authorizationRequestURL];
}

Expand Down
14 changes: 7 additions & 7 deletions Source/OIDAuthorizationService.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
@class OIDServiceConfiguration;
@class OIDTokenRequest;
@class OIDTokenResponse;
@protocol OIDUserAgentFlowSession;
@protocol OIDUserAgentUICoordinator;
@protocol OIDExternalUserAgentFlowSession;
@protocol OIDExternalUserAgentUICoordinator;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -115,13 +115,13 @@ typedef void (^OIDRegistrationCompletion)(OIDRegistrationResponse *_Nullable reg
@param UICoordinator Generic authorization UI coordinator that can present an authorization
request.
@param callback The method called when the request has completed or failed.
@return A @c OIDUserAgentFlowSession instance which will terminate when it
receives a @c OIDUserAgentFlowSession.cancel message, or after processing a
@c OIDUserAgentFlowSession.resumeUserAgentFlowWithURL: message.
@return A @c OIDExternalUserAgentFlowSession instance which will terminate when it
receives a @c OIDExternalUserAgentFlowSession.cancel message, or after processing a
@c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message.
*/
+ (id<OIDUserAgentFlowSession>)
+ (id<OIDExternalUserAgentFlowSession>)
presentAuthorizationRequest:(OIDAuthorizationRequest *)request
UICoordinator:(id<OIDUserAgentUICoordinator>)UICoordinator
UICoordinator:(id<OIDExternalUserAgentUICoordinator>)UICoordinator
callback:(OIDAuthorizationCallback)callback;

/*! @brief Performs a token request.
Expand Down
42 changes: 20 additions & 22 deletions Source/OIDAuthorizationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#import "OIDAuthorizationRequest.h"
#import "OIDAuthorizationResponse.h"
#import "OIDUserAgentUICoordinator.h"
#import "OIDUserAgentFlowSession.h"
#import "OIDExternalUserAgentUICoordinator.h"
#import "OIDExternalUserAgentFlowSession.h"
#import "OIDDefines.h"
#import "OIDErrorUtilities.h"
#import "OIDRegistrationRequest.h"
Expand All @@ -41,10 +41,10 @@

NS_ASSUME_NONNULL_BEGIN

@interface OIDAuthorizationFlowSessionImplementation : NSObject<OIDUserAgentFlowSession> {
@interface OIDAuthorizationFlowSessionImplementation : NSObject<OIDExternalUserAgentFlowSession> {
// private variables
OIDAuthorizationRequest *_request;
id<OIDUserAgentUICoordinator> _UICoordinator;
id<OIDExternalUserAgentUICoordinator> _UICoordinator;
OIDAuthorizationCallback _pendingauthorizationFlowCallback;
}

Expand All @@ -65,12 +65,12 @@ - (instancetype)initWithRequest:(OIDAuthorizationRequest *)request {
return self;
}

- (void)presentAuthorizationWithCoordinator:(id<OIDUserAgentUICoordinator>)UICoordinator
- (void)presentAuthorizationWithCoordinator:(id<OIDExternalUserAgentUICoordinator>)UICoordinator
callback:(OIDAuthorizationCallback)authorizationFlowCallback {
_UICoordinator = UICoordinator;
_pendingauthorizationFlowCallback = authorizationFlowCallback;
BOOL authorizationFlowStarted =
[_UICoordinator presentUserAgentRequest:_request session:self];
[_UICoordinator presentExternalUserAgentRequest:_request session:self];
if (!authorizationFlowStarted) {
NSError *safariError = [OIDErrorUtilities errorWithCode:OIDErrorCodeSafariOpenError
underlyingError:nil
Expand All @@ -80,14 +80,13 @@ - (void)presentAuthorizationWithCoordinator:(id<OIDUserAgentUICoordinator>)UICoo
}

- (void)cancel {
[_UICoordinator dismissUserAgentUIAnimated:YES
completion:^{
NSError *error = [OIDErrorUtilities
errorWithCode:OIDErrorCodeUserCanceledAuthorizationFlow
underlyingError:nil
description:nil];
[self didFinishWithResponse:nil error:error];
}];
[_UICoordinator dismissExternalUserAgentUIAnimated:YES completion:^{
NSError *error = [OIDErrorUtilities
errorWithCode:OIDErrorCodeUserCanceledAuthorizationFlow
underlyingError:nil
description:nil];
[self didFinishWithResponse:nil error:error];
}];
}

- (BOOL)shouldHandleURL:(NSURL *)URL {
Expand All @@ -102,7 +101,7 @@ - (BOOL)shouldHandleURL:(NSURL *)URL {
OIDIsEqualIncludingNil(standardizedURL.path, standardizedRedirectURL.path);
}

- (BOOL)resumeUserAgentFlowWithURL:(NSURL *)URL {
- (BOOL)resumeExternalUserAgentFlowWithURL:(NSURL *)URL {
// rejects URLs that don't match redirect (these may be completely unrelated to the authorization)
if (![self shouldHandleURL:URL]) {
return NO;
Expand Down Expand Up @@ -146,15 +145,14 @@ - (BOOL)resumeUserAgentFlowWithURL:(NSURL *)URL {
}
}

[_UICoordinator dismissUserAgentUIAnimated:YES
completion:^{
[self didFinishWithResponse:response error:error];
}];
[_UICoordinator dismissExternalUserAgentUIAnimated:YES completion:^{
[self didFinishWithResponse:response error:error];
}];

return YES;
}

- (void)failUserAgentFlowWithError:(NSError *)error {
- (void)failExternalUserAgentFlowWithError:(NSError *)error {
[self didFinishWithResponse:nil error:error];
}

Expand Down Expand Up @@ -246,9 +244,9 @@ + (void)discoverServiceConfigurationForDiscoveryURL:(NSURL *)discoveryURL

#pragma mark - Authorization Endpoint

+ (id<OIDUserAgentFlowSession>)
+ (id<OIDExternalUserAgentFlowSession>)
presentAuthorizationRequest:(OIDAuthorizationRequest *)request
UICoordinator:(id<OIDUserAgentUICoordinator>)UICoordinator
UICoordinator:(id<OIDExternalUserAgentUICoordinator>)UICoordinator
callback:(OIDAuthorizationCallback)callback {
OIDAuthorizationFlowSessionImplementation *flowSession =
[[OIDAuthorizationFlowSessionImplementation alloc] initWithRequest:request];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! @file OIDUserAgentFlowSession.h
/*! @file OIDExternalUserAgentFlowSession.h
@brief AppAuth iOS SDK
@copyright
Copyright 2017 The AppAuth Authors. All Rights Reserved.
Expand All @@ -17,21 +17,21 @@
*/


/*! @brief Represents an in-flight user-agent flow session.
/*! @brief Represents an in-flight external user-agent flow session.
*/
@protocol OIDUserAgentFlowSession <NSObject>
@protocol OIDExternalUserAgentFlowSession <NSObject>

/*! @brief Cancels the code flow session, invoking the request's callback with a cancelled error.
@remarks Has no effect if called more than once, or after a
@c OIDUserAgentFlowSession.resumeUserAgentFlowWithURL: message was received. Will
cause an error with code: @c ::OIDErrorCodeProgramCanceledAuthorizationFlow to be passed to
the @c callback block passed to
@c OIDExternalUserAgentFlowSession.resumeExternalUserAgentFlowWithURL: message was received.
Will cause an error with code: @c ::OIDErrorCodeProgramCanceledAuthorizationFlow to be
passed to the @c callback block passed to
@c OIDAuthorizationService.presentAuthorizationRequest:presentingViewController:callback:
*/
- (void)cancel;

/*! @brief Clients should call this method with the result of the user-agent code flow if it
becomes available.
/*! @brief Clients should call this method with the result of the external user-agent code flow if
it becomes available.
@param URL The redirect URL invoked by the server.
@discussion When the URL represented a valid response, implementations should clean up any
left-over UI state from the request, for example by closing the
Expand All @@ -40,13 +40,13 @@
@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)resumeUserAgentFlowWithURL:(NSURL *)URL;
- (BOOL)resumeExternalUserAgentFlowWithURL:(NSURL *)URL;

/*! @brief @c OIDUserAgentUICoordinator or clients should call this method when the user-agent flow
failed with a non-OAuth error.
@param error The error that is the reason for the failure of this user-agent flow.
/*! @brief @c OIDExternalUserAgentUICoordinator or clients should call this method when the
external user-agent flow failed with a non-OAuth error.
@param error The error that is the reason for the failure of this external flow.
@remarks Has no effect if called more than once, or after a @c cancel message was received.
*/
- (void)failUserAgentFlowWithError:(NSError *)error;
- (void)failExternalUserAgentFlowWithError:(NSError *)error;

@end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! @file OIDUserAgentUICoordinator.h
/*! @file OIDExternalUserAgentUICoordinator.h
@brief AppAuth iOS SDK
@copyright
Copyright 2017 The AppAuth Authors. All Rights Reserved.
Expand All @@ -16,20 +16,20 @@
limitations under the License.
*/

/*! @protocol OIDUserAgentUICoordinator
@brief An interface that any user-agent request may implement to use the @c
OIDUserAgentUICoordinator flow.
/*! @protocol OIDExternalUserAgentUICoordinator
@brief An interface that any external user-agent request may implement to use the
@c OIDExternalUserAgentUICoordinator flow.
*/
@protocol OIDUserAgentRequest
@protocol OIDExternalUserAgentRequest

/*! @brief Method to create and return the complete request URL instance.
@return A @c NSURL instance which contains the URL to be opened in a user-agent (i.e. browser)
@return A @c NSURL instance which contains the URL to be opened in an external UI (i.e. browser)
*/
- (NSURL*)userAgentRequestURL;
- (NSURL*)externalUserAgentRequestURL;

/*! @brief If this user-agent request has a redirect URL, this should return its scheme. Since some
user-agent requests have optional callbacks (such as the end session endpoint), the return
value of this method is nullable.
/*! @brief If this external user-agent request has a redirect URL, this should return its scheme.
Since some external requests have optional callbacks (such as the end session endpoint), the
return value of this method is nullable.
@return A @c NSString instance that contains the scheme of a callback url, or nil if there is
no callback url for this request.
*/
Expand Down
Loading

0 comments on commit e572a99

Please sign in to comment.