Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Basic auth for api #349

Merged
merged 3 commits into from
Oct 25, 2011
Merged

Basic auth for api #349

merged 3 commits into from
Oct 25, 2011

Conversation

csainty
Copy link
Contributor

@csainty csainty commented Oct 17, 2011

Added an option to the Basic Authentication plugin to stop it sending back the WWW-Authenticate header which prompts the browser to pop up a login dialog.

This popup is no good for ajax requests to a REST API.

Second commit reformats the class as it was indented with tabs instead of the spaces I saw through the rest of the project. I have done this as a seperate commit to help isolate the real changes to the file in the first commit. Hope that helps.

@grumpydev
Copy link
Member

I wonder whether this would be improved by making the property an enum with the values:

  • Never
  • Always
  • NonAjax

The latter potentially being the default (we already "detect" ajax requests for forms auth to remove the redirect).

@csainty
Copy link
Contributor Author

csainty commented Oct 25, 2011

I think that is a good idea. I approached the problem only from the AJAX perspective as that is the only part of my site that is using the authentication, but if you were mixing AJAX and regular pages, then you would probably want this level of flexibility.
I'll take a look at it.

Chris Sainty added 3 commits October 25, 2011 20:11
…at tells the browser to prompt the user for credentials.

This is a poor user experience for an ajax request.
…ool to an enum with three option. Always, Never, NonAjax.

NonAjax allows for regular requests to respond with the challenge HTTP header while AJAX responses will not.
In this commit, NonAjax is the default, which is a change in behaviour from the current build. To replicate current behaviour, use Always.
@csainty
Copy link
Contributor Author

csainty commented Oct 25, 2011

New commit that encapsulates this.
Keep in mind that setting NonAjax as the default is a change in behaviour, a correct one in my opinion, but a change none the less.

grumpydev added a commit that referenced this pull request Oct 25, 2011
@grumpydev grumpydev merged commit 422f04e into NancyFx:master Oct 25, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants