|
37 | 37 | */
|
38 | 38 | static NSString *const kOpenIDConfigurationWellKnownPath = @".well-known/openid-configuration";
|
39 | 39 |
|
40 |
| -/*! @brief The state authorization parameter. |
41 |
| - */ |
42 |
| -static NSString *const kStateParameter = @"state"; |
43 | 40 |
|
44 | 41 | NS_ASSUME_NONNULL_BEGIN
|
45 | 42 |
|
@@ -127,25 +124,25 @@ - (BOOL)resumeAuthorizationFlowWithURL:(NSURL *)URL {
|
127 | 124 | underlyingError:nil];
|
128 | 125 | }
|
129 | 126 |
|
130 |
| - // verifies that the state in the response matches the state in the request, or both are nil |
131 |
| - if (!OIDIsEqualIncludingNil(_request.state, query.dictionaryValue[kStateParameter])) { |
132 |
| - NSMutableDictionary *userInfo = [query.dictionaryValue mutableCopy]; |
133 |
| - userInfo[NSLocalizedDescriptionKey] = |
134 |
| - [NSString stringWithFormat:@"State mismatch, expecting %@ but got %@ in authorization " |
135 |
| - "response %@", |
136 |
| - _request.state, |
137 |
| - response.state, |
138 |
| - response]; |
139 |
| - response = nil; |
140 |
| - error = [NSError errorWithDomain:OIDOAuthAuthorizationErrorDomain |
141 |
| - code:OIDErrorCodeOAuthAuthorizationClientError |
142 |
| - userInfo:userInfo]; |
143 |
| - } |
144 |
| - |
145 | 127 | // no error, should be a valid OAuth 2.0 response
|
146 | 128 | if (!error) {
|
147 | 129 | response = [[OIDAuthorizationResponse alloc] initWithRequest:_request
|
148 | 130 | parameters:query.dictionaryValue];
|
| 131 | + |
| 132 | + // verifies that the state in the response matches the state in the request, or both are nil |
| 133 | + if (!OIDIsEqualIncludingNil(_request.state, response.state)) { |
| 134 | + NSMutableDictionary *userInfo = [query.dictionaryValue mutableCopy]; |
| 135 | + userInfo[NSLocalizedDescriptionKey] = |
| 136 | + [NSString stringWithFormat:@"State mismatch, expecting %@ but got %@ in authorization " |
| 137 | + "response %@", |
| 138 | + _request.state, |
| 139 | + response.state, |
| 140 | + response]; |
| 141 | + response = nil; |
| 142 | + error = [NSError errorWithDomain:OIDOAuthAuthorizationErrorDomain |
| 143 | + code:OIDErrorCodeOAuthAuthorizationClientError |
| 144 | + userInfo:userInfo]; |
| 145 | + } |
149 | 146 | }
|
150 | 147 |
|
151 | 148 | [_UICoordinator dismissAuthorizationAnimated:YES
|
|
0 commit comments