Skip to content
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

Fix path rules, add basic auth #106

Closed
wants to merge 1 commit into from

Conversation

isbm
Copy link

@isbm isbm commented Oct 10, 2019

This PR rewrites path rules in a standard way, using urlparse/urlunparse as well as adds sometimes required Basic authentication via headers, so the XML-RPC API URL can be at all accessed before even calling any functions.

Example usage:

# coding: utf-8
import bugzilla
import getpass

bug_id = input("Bug ID: ")
user = input("Username: ")
pwd = getpass.getpass("Password: ")

bz = bugzilla.Bugzilla(url='https://apibugzilla.suse.com',
    user=user, password=pwd, basic_auth=True)
print(bz.getbug(bug_id).id)

Copy link
Member

@crobinso crobinso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patches. Pushed patch #1 with a tweak. I added some comments on the other two.

Do you know if this is a bugzilla feature, or is it something that's implemented site specific? Since this seems to be a general HTTP feature I'm trying to figure out if we should bake it into the API like this, or instead expose the transport object to the API user to tweak as needed.

bugzilla/base.py Outdated Show resolved Hide resolved
bugzilla/base.py Outdated Show resolved Hide resolved
bugzilla/base.py Show resolved Hide resolved
bugzilla/transport.py Show resolved Hide resolved
bugzilla/base.py Outdated Show resolved Hide resolved
@isbm
Copy link
Author

isbm commented Oct 11, 2019

API won't work at all if you cannot access the URL at first place. So this is a general feature to at all get to the XML-RPC API part. If your Bugzilla API is behind that auth, then you will always get HTTP 401 error for unauthorised URL, which renders this library unusable.

.gitignore Outdated Show resolved Hide resolved
@isbm
Copy link
Author

isbm commented Oct 12, 2019

Any other issues you still have?

@crobinso
Copy link
Member

Your patch layout is making this series difficult to review. Patch #4 should be squashed into patch #1. Patch #3 should be squashed into patch #2. Patch #5 seems like it was added mid review which makes this series a moving target.

Please split out your style change patches and submit them separately. Also indicate what tool you are using that flags these bits, because our pycodestyle and pylint configs aren't flagging anything.

We can keep this PR for tracking your auth additions

@isbm
Copy link
Author

isbm commented Oct 15, 2019

Is anything else I can help you?

@crobinso
Copy link
Member

Thank you for the contribution. The patch still had a stray newline, long line, and the 'import requests' movement which were unrelated to the patch. I adjusted all those and pushed. Please confirm git master still works correctly

@crobinso crobinso closed this Oct 15, 2019
@isbm isbm deleted the isbm-susepatch branch October 15, 2019 14:27
@crobinso
Copy link
Member

@isbm FYI, upstream I removed the basic_auth support, in favor of allowing API users to pass in their own requests.Session instance. Use Bugzilla(requests_session=MYSESSION). This offloads the basic_auth setup work to the user, but it's much much more flexible, and saves me from having to possibly support a never ending stream of HTTP features that will just be passed down to requests. Hopefully this works for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants