-
Notifications
You must be signed in to change notification settings - Fork 10
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
add support for token based access #8
Conversation
add support for token based access api
@@ -4,6 +4,11 @@ | |||
from urlparse import urlparse | |||
class GraylogAPI(object): | |||
def __init__(self, url, username=None, password=None, api_key=None): | |||
|
|||
# check if the username / password vs. api_key cannot be provided at same time | |||
if username is not None and api_key is not None: |
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.
This check is raising an error in the unit tests. My question is: should it not matter if the username, password and api_key are set? We could just prefer the API key if it is provided, which is what seems like you added on line 42.
|
||
# use the api_key if it is been provided | ||
if self.api_key is not None: | ||
payload = self.api_key + ':token' |
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.
👍 this looks like the way Graylog constructs the token header, http://docs.graylog.org/en/2.2/pages/configuration/rest_api.html
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.
I think the authorization header looks correct, and it matches documentation. Thanks for the P/R!
Could you please add some unit tests and fix the current broken unit test? It throws an exception since we generate a Graylog Object w/ username/password & an API key. I would split that unit test into a username/password one and a token based one. Lastly, could you increment setup.py
version of pygraylog so I can do a pypi release?
Thank you!
One last observation - update readme to show token based auth as well! |
update version from 0.3.1 to 0.3.2
update the patch-1 branch for
|
Thank you @jafferli ! I'll get this pushed to pypi asap |
add support for token based access api