Closed merwok closed 4 years ago
@merwok fyi, thanks for the offer to update What's New, but it is easier to do a single copy-pasta job at release time. See https://github.com/Pylons/pyramid/blob/master/RELEASING.txt#L49-L58 for process.
I keep wanting to add a note somewhere about this, but I don’t know if it’s appropriate:
This configuration will not work because the two view configs have the same specificity:
@view_config(route_name="home", is_authenticated=True)
def home_members(request):
...
@view_config(route_name="home", is_authenticated=False)
def home_login(request):
....
The right one is add is_authenticated to one of the functions and leave the other one without the param. It may be obvious to Pyramid devs, and the example in the docs is correct (https://github.com/Pylons/pyramid/pull/3598/files#diff-c0f6b28a439e308028cc66c9f0ac7aee), but it did trip me up for a moment on a project.
This configuration will not work because the two view configs have the same specificity:
They have the same view weighting but because they are properly mutually exclusive, the correct one will be selected for each request. This configuration will work.
There could definitely be issues with effective_principals because you could setup configurations that were not mutually exclusive. For example Everyone
vs Authenticated
is ambiguous, because authenticated users also contain the Everyone
principal.
Well that’s great! I think now that my error was probably that my code was doing return request.authenticated_userid is not None
without comparing to the boolean value stored as self.val
:man_facepalming: :laughing:
Oh also let me validate the whole thing with a tiny app! (can only trust unit tests so far)
I have added a bunch of routes and views to a minimal app and it looks good.
I saw the expected text when opening the URLs with and without security policy (a simple class with 7 lines that permits everything)!
I also deleted the original IsAuthenticated predicate in my project, installed this Pyramid branch and my tests all pass.
@mmerickel this is ready!
\o/ this is great, thank you @merwok!
Fixes #1602