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

Error code & other related tasks refactoring #153

Merged
merged 21 commits into from
Jun 26, 2018
Merged

Conversation

unpluggedk
Copy link
Contributor

@unpluggedk unpluggedk commented Jun 18, 2018

Removed not-being-used errors, feel free to re-introduce them when needed.

Categorized errors into

  • General errors
  • Cache Errors
  • Server errors
  • Interactive flow errors.

Other additions:

  • include additional checks to disable system webview from project
  • minor fixes

// Server returned a refresh token reject response
MSIDErrorServerRefreshTokenRejected = -51403,
// Other specific server response errors
MSIDErrorInvalidRequest = -51404,
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 it also have "server" in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
MSIDErrorSessionCanceled = -51020,
// The interactive flow was cancelled programmatically.
MSIDErrorSessionCanceled = -51513,
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 the error name "hint" that it was canceled programmatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -101,7 +101,7 @@ - (MSIDAccountType)accountType

- (MSIDErrorCode)oauthErrorCode
{
return MSIDErrorCodeForOAuthError(self.error, MSIDErrorInteractionRequired);
return MSIDErrorCodeForOAuthError(self.error, MSIDErrorServerOauth);
Copy link
Member

Choose a reason for hiding this comment

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

will the clients know to show UI on MSIDErrorServerOauth? I think the reason to have MSIDErrorInteractionRequired as default is so that client show UI in MSAL? Can we check what was MSAL and ADAL implementation before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Top level : Interaction required
Underlying : ServerOAuth

and double check converter in MSAL and ADAL

@@ -45,7 +45,10 @@ - (instancetype)initWithURL:(NSURL *)url
{
if (error)
{
*error = MSIDCreateError(MSIDOAuthErrorDomain, MSIDErrorInvalidParameter, @"Unexpected error has occured. There is no auth code nor an error", nil, nil, nil, context.correlationId, nil);
*error = MSIDCreateError(MSIDOAuthErrorDomain,
MSIDErrorServerInvalidResponse,
Copy link
Member

Choose a reason for hiding this comment

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

👍

@unpluggedk
Copy link
Contributor Author

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.

Just a couple of questions and nit fixes :)

@@ -134,7 +134,6 @@
6035CD8D207EA67300369E69 /* MSIDTelemetryIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6035CD8B207EA67300369E69 /* MSIDTelemetryIntegrationTests.m */; };
6057EE9020B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6057EE8F20B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m */; };
6057EE9120B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6057EE8F20B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m */; };
606830052098ACED00CCA6AB /* MSIDNegotiateHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 606830042098ACED00CCA6AB /* MSIDNegotiateHandler.m */; };
Copy link
Member

Choose a reason for hiding this comment

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

why this got removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was removed for iOS. There is a separate issue for this in #157

// Authority Validation Errors
@(MSIDErrorAuthorityValidation),
@(MSIDErrorAuthorityValidation),
@(MSIDErrorAuthorityValidation),
Copy link
Member

Choose a reason for hiding this comment

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

MSIDErrorAuthorityValidation error is triple :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops, removed.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -83,7 +83,7 @@ + (void)startSession:(MSIDWebviewSession *)session
// check session nil
if (!session)
{
NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorInvalidRequest, @"Interactive session failed to create.", nil, nil, nil, context.correlationId, nil);
NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorInvalidDeveloperParameter, @"Interactive session failed to create.", nil, nil, nil, context.correlationId, nil);
Copy link
Member

Choose a reason for hiding this comment

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

why is this developer parameter? This feels like it would be MSAL internal error or system error :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an argument to the method itself. But I do understand where the argument is coming from - this method is only called by other methods that should create a session.
Thus, changing it to MSIDErrorInvalidInternalParameter.

@@ -114,7 +114,16 @@ - (void)cancel
MSID_LOG_INFO(self.context, @"Cancel Web Auth...");

// End web auth with error
NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorUserCancel, @"The user/application has cancelled the authorization.", nil, nil, nil, self.context.correlationId, nil);
NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorSessionCanceledProgramatically, @"Authorization session was cancelled programatically.", nil, nil, nil, self.context.correlationId, nil);
Copy link
Member

Choose a reason for hiding this comment

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

👍

self.navigationItem.leftBarButtonItem = cancelButton;
}

// Authentication was cancelled by the user
- (IBAction)onCancel:(__unused id)sender
Copy link
Member

@oldalton oldalton Jun 26, 2018

Choose a reason for hiding this comment

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

just confirming if this was changed also in the subclasses, because I didn't see onCancel changes in the subclasses :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

onCancel method is no longer needed. Button was set up programatically to simply call "userCancel" now. Some comments around methods were added for clarity nonetheless.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@unpluggedk unpluggedk merged commit a9c8443 into dev Jun 26, 2018
@unpluggedk unpluggedk deleted the jak/error-coding branch June 26, 2018 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants