-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow to override credential lookup. #5
Conversation
Hi. Thanks for the patch. What you added looks useful for programmatic use but for regular Django usage it would be easier if one could configure a lookup function using a setting. For example:
Can you try adding that? Actually, another person asked for this feature too. You could implement it using Django's import_string. |
…n django settings.
Ok. I've implemented it. Although I prefer the other way around because it allows to make a self contained module without needing to modify the settings file. It also makes it possible to use hawk in different apis inside the same app. |
from django.utils.module_loading import import_string | ||
except ImportError: | ||
# compatibility with django < 1.7 | ||
from django.utils.module_loading import import_by_path |
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.
nice! Thanks for adding that
Looks great, I just made some minor stylistic comments. Do you have time to add a patch to the docs showing how this setting can be used? If not, I can file an issue to add that later. The new setting would need a mention underneath the HAWK_CREDENTIALS example. Here are instructions for how to build the docs locally while in development. |
Good point! Maybe you could expand on this patch where the Django setting can be used to set a lookup function but also where one could subclass the |
Alright, I added the aesthetic changes and the documentation. |
Awesome. I like the example in the docs. Thanks again. |
Allow to override credential lookup.
I pushed a release with your feature to PyPI: https://pypi.python.org/pypi/hawkrest This new setting will be super helpful. By the way, if you wanted to follow up with another patch that added in your class approach (so that one could subclass it) then I think that would be fine. |
No description provided.