Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented Nov 9, 2017

#955 A lot of users mess up their auth scheme registrations. This adds more information to the error messages to help them figure out what's wrong.

@Tratcher Tratcher added this to the 2.1.0 milestone Nov 9, 2017
@Tratcher Tratcher self-assigned this Nov 9, 2017
@Tratcher Tratcher requested review from HaoK and davidfowl November 9, 2017 00:07
if (handler == null)
{
throw new InvalidOperationException($"No authentication handler is configured to authenticate for the scheme: {scheme}");
var schemes = await GetAllSchemeNames();
Copy link
Member

Choose a reason for hiding this comment

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

Helper like throw await CreateMissingHandlerError(scheme)?


if (string.IsNullOrEmpty(schemes))
{
return "[none]";
Copy link
Member

Choose a reason for hiding this comment

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

Naw, I think the message should be different instead of saying none.

Copy link
Member Author

Choose a reason for hiding this comment

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

"There are no registered authentication schemes."?
Then what?

Copy link
Member

@HaoK HaoK Nov 9, 2017

Choose a reason for hiding this comment

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

"You need to add your authentication scheme to the AuthenticationBuilder returned by AddAuthentication()"

Copy link
Member

Choose a reason for hiding this comment

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

Or "Did you forget to call AddAuthentication().AddScheme()?"

Copy link
Member Author

Choose a reason for hiding this comment

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

There's only so much we can cram in here. How about a fwlink to the auth docs instead?

Copy link
Member

Choose a reason for hiding this comment

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

The EF team is notorious for good error message like this. It's super valuable.

@Tratcher Tratcher merged commit 4763337 into dev Nov 16, 2017
@Tratcher Tratcher deleted the tratcher/errors branch November 16, 2017 17:18
{
// CookieAuth is the only implementation of sign-in.
return new InvalidOperationException(mismatchError
+ $"Did you intended to call AddAuthentication().AddCookies(\"Cookies\") and SignInAsync(\"Cookies\",...)?");
Copy link
Member

Choose a reason for hiding this comment

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

Typo: intended => intend

Copy link
Member

Choose a reason for hiding this comment

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

Or should just be consistent and use forget?

{
// CookieAuth is the most common implementation of sign-out, but OpenIdConnect and WsFederation also support it.
return new InvalidOperationException(mismatchError
+ $"Did you intended to call AddAuthentication().AddCookies(\"Cookies\") and {nameof(SignOutAsync)}(\"Cookies\",...)?");
Copy link
Member

Choose a reason for hiding this comment

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

Typo here too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants