-
Notifications
You must be signed in to change notification settings - Fork 886
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
replace pyramid.require_default_csrf setting with config.set_default_csrf_options #2518
replace pyramid.require_default_csrf setting with config.set_default_csrf_options #2518
Conversation
Leaving |
I'm going back and forth on how deep the integration should go. I'd like to have If I went that route then I would set the signature like |
I like the idea that I as a user can influence the header/token name from a setting. Other than that, I really have no real preference either way. |
daa6546
to
f51d494
Compare
f51d494
to
783fb7c
Compare
Alright I've overhauled the automatic csrf api to be simpler.
Please review! |
9ab25e8
to
b7224ed
Compare
b7224ed
to
de3d0c7
Compare
if resolved_val is True: | ||
resolved_val = 'csrf_token' | ||
explicit_val = info.options.get('require_csrf') | ||
defaults = info.registry.queryUtility(IDefaultCSRFOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be simpler to always register a default utility, that can be overridden, rather than having to redefine the defaults here?
If we ever decide to change the safe_methods or the header, we need to change it in two places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pyramid tends to be fairly lazy about this stuff. I think no matter what you will have 2 spots unless I move things out of the signature of set_default_csrf_options
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries :-)
Besides a minor nitpick about duplication, this looks great. 👍 |
I realized that the csrf options should not really change per-environment and were more similar to default permissions. I'm removing the INI setting and adding
config.set_default_csrf_options
instead. Bonus aspect is that it will allow changing the default header and safe methods if desired.I don't currently plan to remove the
pyramid.csrf_trusted_origins
setting but it's also an option. I do expect the origins to be different per-environment (dev vs prod) but people could handle it themselves by passing it toset_default_csrf_options
.Thoughts?