-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp remember/forget API #3423
Comments
Is it crazy to suggest that Pyramid doesn't enforce a forget/remember API? We could expose the identity policy to the user and allow it to provide whatever it thinks is best. e.g. implement |
I don't think it's the responsibility of the policy directly but I would like remember/forget to handle session invalidation if a session factory is registered. I can't see an argument why it shouldn't do it, even if the user is already doing something else themselves. The idea would be that |
Invalidating the session is a bit draconian, but I can see it's important for security by default. Do you still want remember/forget to return a dict? |
Invalidating the session is required for good security and to disallow the potential of session fixation. All of the projects I've built do this, and my |
Current issues include:
|
So, taking another look at this and mulling over things, here's a brain dump: I understand To me return a dict of token/body/session still doesn't sit right. It's too many things, makes it unclear what remember is supposed to be. Different policies could have drastically different ways to use remember. Also remember returning an access token doesn't seem right, because in that case its not remembering anything, that responsibility is now on the application. "remember" implies a modification of some persistent state, i.e. cookie/session. That being said I like the idea of having a way to generate access tokens. What about leaving remember as-is and adding a new method to the securitypolicy interface? I think that also works well with the talk of remember+forget invalidating the session. Since remember+forget modify the state, it makes sense to wipe that state. But generate_access_token might be used for something like oauth, where you're handing the token off to another application and you definitely don't want to nuke the user's session. Hopefully that's somewhat coherent and helpful. |
I'm basically resolved to not changing this api because I can't think of anything that really solves the issue atm. The only "right" option imo is to return a response object and give the policy full control of login/logout. However I just don't like it! It's hard to test and often the responses should be more app-specific versus what a policy can do - like determining where to redirect (but that could be a kwarg to |
I'm okay with not changing the API, with the new policies I think it is easier than ever to create custom policies and thus change the response from |
Works for me. Since the answer is to let remember/forget be whatever the user wants, will we remove "returns a list of headers" from the interface docs, or will that remain the "official" API? |
I'm closing this. Please open a PR to tweak the docs if anyone wants to improve them a bit but I don't think we'll change pyramid's underlying impl. |
One wishlist item for Pyramid 2.0 is to revamp
remember
andforget
in the authentication API. This issue is to continue discussion started in #3422.@mmerickel says:
The text was updated successfully, but these errors were encountered: