Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-25 Thread Markus Bertheau
I'd like to argue in favor of exercising caution when using CBVs. In my experience, CBVs shine when the requirements closely match the use case for a certain CBV and all customizations are purely declarative, often just setting the model. With the level of expressiveness that Python gives us a

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-23 Thread Joachim Jablon
I'm +1 with Baptiste, Ben, Josh and João. Also, Luke, you said : > 1. Recognise that CBVs are much harder to reason about, and therefore > require much more care. 2. Avoid using CBVs unless you really need them. > Just wanted to note that this means never. FBV vs CBV is a choice, there's re

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread Luke Plant
Hi all, First, I want to say that complex things fail in complex ways, so there it's probably a fallacy to look for a single root cause. I agree with various other points about mistakes that were made, but not others. Particularly: On 22/11/16 12:41, Florian Apolloner wrote: Hi, On Monday,

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread João Sampaio
+1 to Baptiste, Ben and Josh. Especially as Ben said, I think this does not justify removing the auth CBVs. The bug happened because of a *misuse* of the abstractions involved. ``.get_context_data()`` is not the correct place for a security check (as nobody overriding it would expect that, nor from

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread Josh Smeaton
+1 to everything Baptiste and Ben have said. A bug in a CBV isn't a good argument for throwing away CBVs entirely. We should probably review patches that touch security systems quite a bit more thoroughly in the future - meaning more eyes rather than a single set of eyes spending more time. On

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread benjaoming
As a big fan of GCBVs, this got me out of the chair :) I am -1 for removing GCBVs for authentication. My reasons: 1) Security improvements also happen over time, finding a security hole in a component is not a reason to point the finger at the architecture. If you entirely remove something, yo

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread Erik Romijn
Hello, Thank you for raising this, Markus. I am +1 to everything Baptiste said. In particular, if our conclusion of this bug would be that CBV are entirely unsuitable for security sensitive features, I don’t think removing CBV for auth is enough. Because by that logic, our users will be making

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread Florian Apolloner
Hi, On Monday, November 21, 2016 at 11:56:56 PM UTC+1, Tim Graham wrote: > > … that the existing tests would catch this type of obviously incorrect > issue. > I think that is the main issue here. I was also really surprised to discover that the tests were missing cases like this -- then again,

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread Baptiste Mispelon
Hi Markus, Thanks for your clear description and for bringing this up for discussion. I don't agree with your conclusions though. 1) Keeping around two implementations of auth views seems counter-productive to me in terms of security because it effectively doubles the potential for bugs or s

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-22 Thread Claude Paroz
Le lundi 21 novembre 2016 23:56:56 UTC+1, Tim Graham a écrit : > > When reviewing the patch for the auth class-based view additions, I made > the mistake of assuming that the existing tests would catch this type of > obviously incorrect issue. Perhaps with the function-based views, the code > wa

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-21 Thread Yoong Kang Lim
> I think that patch was just an example of bad abstraction. For instance, _log_and_response was strange and confusingly named, and seemed to be there mostly for vanity, to mask the imperative nature of the top level of control. Proposed patch author here. Yes, I agree that wasn't a very successfu

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-21 Thread Yo-Yo Ma
> I found it much more difficult to follow to the point where I didn't feel it > was an improvement. I think that patch was just an example of bad abstraction. For instance, _log_and_response was strange and confusingly named, and seemed to be there mostly for vanity, to mask the imperative nat

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-21 Thread Tim Graham
I haven't extended these views much, so I can't talk about the pain points of extending the function-based views compared to the ease of extending the classes. I'm certainly more confident about reasoning with function-based code. There was a draft patch [0] a few months ago that converted some

Re: Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-21 Thread Tom Christie
Just to be absolutely clear, in case it's needed... > is to hold off the deprecation of the function-based views. Markus is specifically referring to the FBV implementations of the contrib.auth views here. (Not to FBVs generally, which we've no intention of deprecating whatsoever) - Tom > -

Consider reverting or adding guidelines on how to use class based views for security sensitive features

2016-11-21 Thread Markus Holtermann
Hi all, As it turned out [1], due to their complexity, using class-based generic views for security-sensitive functionality can result in unintended behavior. Essentially, the reset token was only checked on GET requests, not on POST. This was due to the check being in `get_context_data()` (whi