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

Fix warnings #888

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
34 changes: 22 additions & 12 deletions Sources/AppAuth/iOS/OIDExternalUserAgentIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ @implementation OIDExternalUserAgentIOS {
__weak id<OIDExternalUserAgentSession> _session;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__weak SFSafariViewController *_safariVC;
SFAuthenticationSession *_authenticationVC;
ASWebAuthenticationSession *_webAuthenticationVC;
Expand Down Expand Up @@ -140,26 +141,31 @@ - (BOOL)presentExternalUserAgentRequest:(id<OIDExternalUserAgentRequest>)request
if (!openedUserAgent && !UIAccessibilityIsGuidedAccessEnabled()) {
__weak OIDExternalUserAgentIOS *weakSelf = self;
NSString *redirectScheme = request.redirectScheme;
SFAuthenticationSession *authenticationVC =
[[SFAuthenticationSession alloc] initWithURL:requestURL
callbackURLScheme:redirectScheme
completionHandler:^(NSURL * _Nullable callbackURL,
NSError * _Nullable error) {
SFAuthenticationCompletionHandler completionHandler = ^(NSURL * _Nullable callbackURL,
NSError * _Nullable error) {
__strong OIDExternalUserAgentIOS *strongSelf = weakSelf;
if (!strongSelf) {
return;
return;
}
strongSelf->_authenticationVC = nil;
if (callbackURL) {
[strongSelf->_session resumeExternalUserAgentFlowWithURL:callbackURL];
} else {
NSError *safariError =
[OIDErrorUtilities errorWithCode:OIDErrorCodeUserCanceledAuthorizationFlow
underlyingError:error
description:@"User cancelled."];
[strongSelf->_session failExternalUserAgentFlowWithError:safariError];
[OIDErrorUtilities errorWithCode:OIDErrorCodeUserCanceledAuthorizationFlow
underlyingError:error
description:@"User cancelled."];
[strongSelf->_session failExternalUserAgentFlowWithError:safariError];
}
}];
};

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SFAuthenticationSession *authenticationVC =
[[SFAuthenticationSession alloc] initWithURL:requestURL
callbackURLScheme:redirectScheme
completionHandler:completionHandler];
#pragma clang diagnostic pop
_authenticationVC = authenticationVC;
openedUserAgent = [authenticationVC start];
}
Expand All @@ -176,8 +182,11 @@ - (BOOL)presentExternalUserAgentRequest:(id<OIDExternalUserAgentRequest>)request
}
}
// iOS 8 and earlier, use mobile Safari
if (!openedUserAgent){
if (!openedUserAgent) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
openedUserAgent = [[UIApplication sharedApplication] openURL:requestURL];
#pragma clang diagnostic pop
}

if (!openedUserAgent) {
Expand All @@ -199,6 +208,7 @@ - (void)dismissExternalUserAgentAnimated:(BOOL)animated completion:(void (^)(voi

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SFSafariViewController *safariVC = _safariVC;
SFAuthenticationSession *authenticationVC = _authenticationVC;
ASWebAuthenticationSession *webAuthenticationVC = _webAuthenticationVC;
Expand Down
6 changes: 6 additions & 0 deletions Sources/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id<OIDExternalUserAgentRequest>
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:_appStoreURL options:@{} completionHandler:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] openURL:_appStoreURL];
#pragma clang diagnostic pop
}
return NO;
}
Expand All @@ -162,8 +165,11 @@ - (BOOL)presentExternalUserAgentRequest:(nonnull id<OIDExternalUserAgentRequest>
[[UIApplication sharedApplication] openURL:requestURL options:@{} completionHandler:nil];
return willOpen;
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL];
return openedInBrowser;
#pragma clang diagnostic pop
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AppAuth/macOS/OIDRedirectHTTPHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
Calling this more than once will result in the previous listener being cancelled (equivalent
of @c cancelHTTPListener being called).
*/
- (NSURL *)startHTTPListener:(NSError **)returnError withPort:(uint16_t)port;
- (nullable NSURL *)startHTTPListener:(NSError **)returnError withPort:(uint16_t)port;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment above indicates this is intentional:

@return The URL containing the address of the server with the specified port, or nil if there was an error.


/*! @brief Starts listening on the loopback interface on a random available port, and returns a URL
with the base address. Use the returned redirect URI to build a @c OIDExternalUserAgentRequest,
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppAuth/macOS/OIDRedirectHTTPHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (instancetype)initWithSuccessURL:(nullable NSURL *)successURL {
return self;
}

- (NSURL *)startHTTPListener:(NSError **)returnError withPort:(uint16_t)port {
- (nullable NSURL *)startHTTPListener:(NSError **)returnError withPort:(uint16_t)port {
// Cancels any pending requests.
[self cancelHTTPListener];

Expand Down
2 changes: 1 addition & 1 deletion Sources/AppAuthCore/OIDAuthState.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static NSString *const kRefreshTokenRequestException =
/*! @brief The most recent authorization response used to update the authorization state. For the
implicit flow, this will contain the latest access token.
*/
@property(nonatomic, readonly) OIDAuthorizationResponse *lastAuthorizationResponse;
@property(nonatomic, readonly, nullable) OIDAuthorizationResponse *lastAuthorizationResponse;

/*! @brief The most recent token response used to update this authorization state. This will
contain the latest access token.
Expand Down
4 changes: 2 additions & 2 deletions Sources/AppAuthCore/OIDRegistrationRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
@see Section 3 of OpenID Connect Dynamic Client Registration 1.0
https://openid.net/specs/openid-connect-registration-1_0.html#ClientRegistration
*/
@property(nonatomic, readonly) NSString *initialAccessToken;
@property(nonatomic, readonly, nullable) NSString *initialAccessToken;

/*! @brief The application type to register, will always be 'native'.
@remarks application_type
Expand Down Expand Up @@ -134,7 +134,7 @@ NS_ASSUME_NONNULL_BEGIN
/*! @brief Constructs an @c NSURLRequest representing the registration request.
@return An @c NSURLRequest representing the registration request.
*/
- (NSURLRequest *)URLRequest;
- (nullable NSURLRequest *)URLRequest;

@end

Expand Down
2 changes: 1 addition & 1 deletion Sources/AppAuthCore/OIDRegistrationRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ - (NSString *)description {
requestBody];
}

- (NSURLRequest *)URLRequest {
- (nullable NSURLRequest *)URLRequest {
static NSString *const kHTTPPost = @"POST";
static NSString *const kBearer = @"Bearer";
static NSString *const kHTTPContentTypeHeaderKey = @"Content-Type";
Expand Down
16 changes: 10 additions & 6 deletions Sources/AppAuthCore/OIDServiceDiscovery.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,19 @@ - (nullable instancetype)initWithJSONData:(NSData *)serviceDiscoveryJSONData
NSDictionary *json =
[NSJSONSerialization JSONObjectWithData:serviceDiscoveryJSONData options:0 error:&jsonError];
if (!json || jsonError) {
*error = [OIDErrorUtilities errorWithCode:OIDErrorCodeJSONDeserializationError
underlyingError:jsonError
description:jsonError.localizedDescription];
if (error) {
*error = [OIDErrorUtilities errorWithCode:OIDErrorCodeJSONDeserializationError
underlyingError:jsonError
description:jsonError.localizedDescription];
}
return nil;
}
if (![json isKindOfClass:[NSDictionary class]]) {
*error = [OIDErrorUtilities errorWithCode:OIDErrorCodeInvalidDiscoveryDocument
underlyingError:nil
description:@"Discovery document isn't a dictionary"];
if (error) {
*error = [OIDErrorUtilities errorWithCode:OIDErrorCodeInvalidDiscoveryDocument
underlyingError:nil
description:@"Discovery document isn't a dictionary"];
}
return nil;
}

Expand Down