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

[BugBash] MSA - Add exception handler for access denied #5485

Merged
merged 5 commits into from
Feb 16, 2018
Merged

Conversation

shishirx34
Copy link
Contributor

The OpenIdConnect library throws exception upon failed authentication which resulted in 500 when access was denied by user on MSA/AAD auth. This fixes #5451 and shows ExternalLinkFailed error.

image

@@ -33,6 +35,9 @@ public static class AuthenticationType
public static readonly string V2CommonTenant = "common";
public static readonly string Authority = "https://login.microsoftonline.com/{0}/v2.0";

private string redirectUrl;
Copy link
Member

Choose a reason for hiding this comment

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

authenticator instance is per request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! good catch, it is a SingleInstance. this won't work.

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 ignore the redirectUrl in the error case, and just redirect to home with the info message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found another way. This is cleaner.

if (notification.Exception.Message == ACCESS_DENIED)
{
notification.HandleResponse();
notification.Response.Redirect(redirectUrl);
Copy link
Member

Choose a reason for hiding this comment

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

For confirm transform by the org admin, it makes sense to redirect so the user sees the transform failed error page if the AAD linking failed or was cancelled.

For UIAuthorize actions that don't support deprecated password auth, will the user still see the info message if the UIAuthorize redirects them to the homepage for the link/transform prompt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will only be shown once when the permission was denied to access permissions, consumed from cookie and is removed so won't repeat upon further UIAuthorize redirects.

.Unprotect(authenticationPropertiesEncodedString[1]);

notification.HandleResponse();
notification.Response.Redirect(authenticationProperties.RedirectUri);
Copy link
Member

Choose a reason for hiding this comment

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

Is this guaranteed to be set, or do we need to default to redirecting to homepage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its guaranteed to be set, see

var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };

@shishirx34 shishirx34 merged commit ea02fa6 into dev Feb 16, 2018
@shishirx34 shishirx34 deleted the fix-500 branch May 1, 2018 19:41
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