Skip to content

Network stack Integration #296

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

Merged
merged 12 commits into from
Aug 24, 2018
Merged

Network stack Integration #296

merged 12 commits into from
Aug 24, 2018

Conversation

jasoncoolmax
Copy link
Member

@jasoncoolmax jasoncoolmax commented Jul 30, 2018

@jasoncoolmax jasoncoolmax changed the title Network stack Integration Network stack Integration [On Hold] Jul 31, 2018
Copy link
Member

@oldalton oldalton left a comment

Choose a reason for hiding this comment

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

Looking good, added a couple of nit comments :)

CHECK_COMPLETION(!error);

NSMutableDictionary *responseDic = (NSMutableDictionary *)response;
Copy link
Member

Choose a reason for hiding this comment

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

nit: should we check that response is actually a dictionary? or should the request maybe already return a dictionary?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -252,7 +259,7 @@ - (BOOL)isRealmTrustedFromWebFingerPayload:(NSArray<MSALWebFingerLink *> *)links
for (MSALWebFingerLink *link in links)
{
if ([link.rel caseInsensitiveCompare:TRUSTED_REALM] == NSOrderedSame &&
[[NSURL URLWithString:link.href] msidIsEquivalentAuthority:authority])
[[NSURL URLWithString:link.href] msidIsEquivalentAuthorityHost:authority])
Copy link
Member

Choose a reason for hiding this comment

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

👍

return nil;
}

- (NSURL *)tokenEndpointWithSliceParameter
Copy link
Member

Choose a reason for hiding this comment

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

can we make this more generic? slice parameter is like any other EQP.

Copy link
Member Author

Choose a reason for hiding this comment

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

the main purpose of the function is to get the token endpoint, will it be better to rename it - (NSURL *)tokenEndpoint? adding the slice parameter is just some internal details

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I like tokenEndpoint more

@jasoncoolmax jasoncoolmax changed the title Network stack Integration [On Hold] Network stack Integration Aug 1, 2018
@oldalton oldalton added the 0.1.5 label Aug 2, 2018
@oldalton oldalton added this to the 0.1.5 milestone Aug 2, 2018
if (error)
{
completionBlock(nil, error);
return;
}

if(response && ![response isKindOfClass:[NSMutableDictionary class]])
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the response need to be a mutable dict?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't. Now changed to NSDictionary :)

CHECK_COMPLETION(!error);

if(response && ![response isKindOfClass:[NSMutableDictionary class]])
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

context:context];

[request sendGet:^(MSALHttpResponse *response, NSError *error) {
NSURL *url = [MSALAdfsAuthorityResolver urlForWebFinger:authenticationEndpoint absoluteAuthority:authority.absoluteString];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: NSURL *url to be NSURL *webfingerUrl?

Copy link
Member Author

Choose a reason for hiding this comment

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

changed.

CHECK_COMPLETION(!error);

if(response && ![response isKindOfClass:[NSMutableDictionary class]])
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before. nsmutabledict?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

return;
}

if(response && ![response isKindOfClass:[NSMutableDictionary class]])
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Member Author

Choose a reason for hiding this comment

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

done


NSMutableDictionary *jsonDictionary = (NSMutableDictionary *)response;

MSIDAADV2TokenResponse *tokenResponse = (MSIDAADV2TokenResponse *)[self.oauth2Factory tokenResponseFromJSON:jsonDictionary context:nil error:&error];
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to use a local error for the whole block in this sendWithBlock, instead of re-using the "error" you got in line 170

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

done

return [[MSIDAADAuthorizationCodeGrantRequest alloc] initWithEndpoint:[self tokenEndpoint]
clientId:_parameters.clientId
scope:[[self requestScopes:nil] msalToString]
redirectUri:[_parameters.redirectUri absoluteString]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd rather see a .absoluteString than [ ]

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@AzureAD AzureAD deleted a comment from unpluggedk Aug 4, 2018
@AzureAD AzureAD deleted a comment from unpluggedk Aug 4, 2018
Copy link
Member

@oldalton oldalton left a comment

Choose a reason for hiding this comment

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

A couple of questions + JK's comments, otherwise looking good :)

if(response && ![response isKindOfClass:[NSMutableDictionary class]])
{
NSError *localError = CREATE_MSID_LOG_ERROR(context, MSALErrorInternal, @"response is not of the expected type: NSMutableDictionary.");
completionBlock(nil, localError);
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we check that completionBlock is not nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

MSIDAccessToken *accessToken = [self.oauth2Factory accessTokenFromResponse:tokenResponse configuration:configuration];
MSIDIdToken *idToken = [self.oauth2Factory idTokenFromResponse:tokenResponse configuration:configuration];

MSALResult *result = [MSALResult resultWithAccessToken:accessToken idToken:idToken];
Copy link
Member

Choose a reason for hiding this comment

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

nit: check that accessToken and idToken are not nil

Copy link
Member Author

Choose a reason for hiding this comment

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

done


NSString* messagePII = [NSString stringWithFormat:@"Error raised: (Domain: \"%@\" Response Code: %ld \n%@", @"Domain", (long)response.statusCode, errorData];

NSMutableDictionary *userInfo = [@{MSALHTTPResponseCodeKey : [NSString stringWithFormat: @"%ld", (long)response.statusCode]} mutableCopy];
Copy link
Member

Choose a reason for hiding this comment

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

Just double checking: does the new network stack have the feature to return http response code and headers?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently nope. But I have added them, they will be in another PR :)

@jasoncoolmax jasoncoolmax dismissed unpluggedk’s stale review August 5, 2018 19:16

all comments addressed :)

# Conflicts:
#	MSAL/IdentityCore
#	MSAL/MSAL.xcodeproj/project.pbxproj
#	MSAL/src/requests/MSALBaseRequest.m
#	MSAL/src/requests/MSALInteractiveRequest.m
#	MSAL/test/unit/MSALB2CPolicyTests.m
#	MSAL/test/unit/MSALInteractiveRequestTests.m
@oldalton
Copy link
Member

@jasoncoolmax, can we merge this one? It's approved.
I think #314 will need to be updated after this one is merged :)

# Conflicts:
#	MSAL/MSAL.xcodeproj/project.pbxproj
#	MSAL/src/requests/MSALBaseRequest.m
@jasoncoolmax jasoncoolmax merged commit 6314562 into dev Aug 24, 2018
@jasoncoolmax jasoncoolmax deleted the jason/networkIntegration branch January 31, 2019 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants