Respect auth mode for redirects#186
Merged
mrlannigan merged 5 commits intohapijs:masterfrom May 27, 2018
Merged
Conversation
# Conflicts: # README.md # lib/index.js
Contributor
Author
|
@mrlannigan I fixed the merge conflicts caused by #183 going in first. Is there anything else I can do to help get this merged? I sincerely believe that this change will be very popular with the rest of the community. |
|
This PR is extremely desired, please, don't put it off. |
mrlannigan
approved these changes
May 27, 2018
Contributor
mrlannigan
left a comment
There was a problem hiding this comment.
Thank you again for this! I apologize for the delay.
Contributor
|
Version 9.0.0 has been released to npm. |
|
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a redo of PR #155, updated for hapi 17, and with no merge conflicts. I made this a new PR for a blank slate and so that the other PR can remain discoverable for hapi 16 users.
The goal here is to reduce boilerplate for configuring this plugin and to simplify routes.
hapi-auth-cookiehas a strange quirk where it redirects to login when the user visits a route whose auth mode istryoroptional. The reason this is unexpected is that the whole point of hapi'stryandoptionalmodes is to allow route handlers to process unauthenticated requests.hapi-auth-cookiemakes this impossible, because it redirects the user away, and thus the route handler never executes. This is rather frustrating because these routes are designed to not force the user to login.This PR ensures that
redirectTorespects the auth mode set for the route. It only redirects when the auth mode isrequired. You can still override the behavior in the route configuration, but that is the new default. This is a breaking change, but it would really make my day to see this merged, since I useoptionalroutes a lot.