-
Notifications
You must be signed in to change notification settings - Fork 146
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
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
MSAL/src/requests/MSALBaseRequest.m
Outdated
return nil; | ||
} | ||
|
||
- (NSURL *)tokenEndpointWithSliceParameter |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
if (error) | ||
{ | ||
completionBlock(nil, error); | ||
return; | ||
} | ||
|
||
if(response && ![response isKindOfClass:[NSMutableDictionary class]]) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as before
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as before. nsmutabledict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
MSAL/src/requests/MSALBaseRequest.m
Outdated
return; | ||
} | ||
|
||
if(response && ![response isKindOfClass:[NSMutableDictionary class]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
MSAL/src/requests/MSALBaseRequest.m
Outdated
|
||
NSMutableDictionary *jsonDictionary = (NSMutableDictionary *)response; | ||
|
||
MSIDAADV2TokenResponse *tokenResponse = (MSIDAADV2TokenResponse *)[self.oauth2Factory tokenResponseFromJSON:jsonDictionary context:nil error:&error]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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 [ ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
MSAL/src/requests/MSALBaseRequest.m
Outdated
MSIDAccessToken *accessToken = [self.oauth2Factory accessTokenFromResponse:tokenResponse configuration:configuration]; | ||
MSIDIdToken *idToken = [self.oauth2Factory idTokenFromResponse:tokenResponse configuration:configuration]; | ||
|
||
MSALResult *result = [MSALResult resultWithAccessToken:accessToken idToken:idToken]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
# 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
@jasoncoolmax, can we merge this one? It's approved. |
# Conflicts: # MSAL/MSAL.xcodeproj/project.pbxproj # MSAL/src/requests/MSALBaseRequest.m
Uh oh!
There was an error while loading. Please reload this page.