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

Relax redirect URL matching for the forward slash path case #710

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 4 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
9 changes: 8 additions & 1 deletion Source/AppAuthCore/OIDAuthorizationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,20 @@ - (void)cancelWithCompletion:(nullable void (^)(void))completion {
+ (BOOL)URL:(NSURL *)URL matchesRedirectionURL:(NSURL *)redirectionURL {
NSURL *standardizedURL = [URL standardizedURL];
NSURL *standardizedRedirectURL = [redirectionURL standardizedURL];
// Some servers adds '/' to the end when there is no 'path'. To relax the equality rules below
AlexPlekhov marked this conversation as resolved.
Show resolved Hide resolved
// were decided to normalize pathes. So, pathes like '' are the same to '/' now.
// Read more https://github.com/openid/AppAuth-iOS/issues/446
NSString *normalizedPath = [standardizedURL.path isEqualToString:@"/"] ? @""
AlexPlekhov marked this conversation as resolved.
Show resolved Hide resolved
: standardizedURL.path;
NSString *normalizedRedirectPath = [standardizedRedirectURL.path isEqualToString:@"/"] ? @""
: standardizedRedirectURL.path;

return [standardizedURL.scheme caseInsensitiveCompare:standardizedRedirectURL.scheme] == NSOrderedSame
&& OIDIsEqualIncludingNil(standardizedURL.user, standardizedRedirectURL.user)
&& OIDIsEqualIncludingNil(standardizedURL.password, standardizedRedirectURL.password)
&& OIDIsEqualIncludingNil(standardizedURL.host, standardizedRedirectURL.host)
&& OIDIsEqualIncludingNil(standardizedURL.port, standardizedRedirectURL.port)
&& OIDIsEqualIncludingNil(standardizedURL.path, standardizedRedirectURL.path);
&& OIDIsEqualIncludingNil(normalizedPath, normalizedRedirectPath);
}

AlexPlekhov marked this conversation as resolved.
Show resolved Hide resolved
- (BOOL)shouldHandleURL:(NSURL *)URL {
Expand Down