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

LDAP username vs. authentication username #134

Open
carlsonp opened this issue Jan 29, 2018 · 3 comments
Open

LDAP username vs. authentication username #134

carlsonp opened this issue Jan 29, 2018 · 3 comments

Comments

@carlsonp
Copy link

I've run into the same issue as found previously:

#38

I'm running on the latest master: 4c3b08c

I get the following error:

wkspc:  None
project:  None
RallyRestResponse for Subscription, _stdFormat?: False, _servable: 1  _limit: 1  _served: 0 
RallyRestResponse for User, _stdFormat?: True, _servable: 0  _limit: 0  _served: 0 
Traceback (most recent call last):

  File "<ipython-input-5-1f8c64fd546b>", line 1, in <module>
    runfile('//snl/home/pcarlso/src/Python-Rally-Test/run.py', wdir='//snl/home/pcarlso/src/Python-Rally-Test')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "//snl/home/pcarlso/src/Python-Rally-Test/run.py", line 12, in <module>
    rally = Rally(server=server, user=user, password=password)

  File "c:\users\pcarlso\documents\src\rallyresttoolkitforpython\pyral\restapi.py", line 261, in __init__
    self.contextHelper.check(self.server, wksp, proj, self.isolated_workspace)

  File "c:\users\pcarlso\documents\src\rallyresttoolkitforpython\pyral\context.py", line 175, in check
    self._getDefaults(user_response)

  File "c:\users\pcarlso\documents\src\rallyresttoolkitforpython\pyral\context.py", line 429, in _getDefaults
    user = user_response.next()

  File "c:\users\pcarlso\documents\src\rallyresttoolkitforpython\pyral\rallyresp.py", line 290, in next
    return self.__next__()

  File "c:\users\pcarlso\documents\src\rallyresttoolkitforpython\pyral\rallyresp.py", line 304, in __next__
    raise StopIteration

I don't think the suggested code fix was ever included.

@klehman-rally
Copy link
Member

carlsonp can you suggest the essential nature of happy path and sad path test that would establish a high degree of confidence that your PR doesn't break anything? That would greatly expedite accepting the PR

@carlsonp
Copy link
Author

I'm not sure if our LDAP servers are configured in some "custom" way. I'm at a large organization so I wouldn't be able to find out. Perhaps it would be better to document this in the code as well as in the documentation on readthedocs? This way if someone else has trouble they have something to go on or try. I don't want to break this for other folks.

@stumpjumper
Copy link

For the LDAP installation we have, the rally username is [email protected] but the login username is myname. Below is a modification I made to restapi.py to fix it for our installation.

I added the optional variable username_for_login to the function Rally.__init__().
So, in the call to Rally():

[email protected]
username_for_login=myname

Here is a gitdiff of the changes

$ git diff restapi.py
diff --git a/pyral/restapi.py b/pyral/restapi.py
index 0254eda..16d3c5a 100644
--- a/pyral/restapi.py
+++ b/pyral/restapi.py
@@ -181,7 +181,8 @@ class Rally(object):
     FORMATTED_ID_PATTERN = re.compile(r'^[A-Z]{1,2}\d+$') #S|US|DE|DS|TA|TC|TS|PI
     MAX_ATTACHMENT_SIZE = 50000000  # approx 50 MB 
 
-    def __init__(self, server=SERVER, user=None, password=None, apikey=None,
+    def __init__(self, server=SERVER, user=None, username_for_login=None, 
+                       password=None, apikey=None,
                        version=WS_API_VERSION, warn=True, server_ping=None, 
                        isolated_workspace=False, **kwargs):
         self.server       = server 
@@ -239,7 +240,10 @@ class Rally(object):
             self.user     = None
             self.password = None
         else:
-            self.session.auth = requests.auth.HTTPBasicAuth(self.user, self.password)
+            login_user = self.user
+            if username_for_login:
+                login_user = username_for_login
+            self.session.auth = requests.auth.HTTPBasicAuth(login_user, self.password)
         self.session.timeout = 10.0
         self.session.proxies = proxy_dict
         self.session.verify  = verify_ssl_cert

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

No branches or pull requests

3 participants