dell / python-powerstore

Python library for Dell PowerStore
Apache License 2.0
17 stars 11 forks source link

auth_token not set properly in client #21

Closed ShawnEsterman closed 4 months ago

ShawnEsterman commented 8 months ago

I am seeing an issue when using this package that it makes a login event for every API call I make using the package. It ends up being a huge performance hit and generates a lot of splunk logs for auditing. Through some troubleshooting and referencing your documentation, it seems that the referenced line below does not properly set an auth_token as defined in the API docs.

https://github.com/dell/python-powerstore/blob/c3abb6dde71ead8d80d44b2eea872cfc0abb9e73/PyPowerStore/client.py#L147

In my troubleshooting, I found that the value of the header set-cookie is not a token value, but a bunch of properties that the API wants to see in the cookie for the requests and this includes auth_token. However, since this client doesn't utilize a requests Session it does not seem to save cookies.

It would be nice to see if this client could be ported to use requests Session so that the cookies are automatically set when you hit the login_session endpoint (Still would have to set the DELL-EMC-TOKEN as a header though). Otherwise, it might be easier to cache the cookies attribute returned by the response object of the login_session endpoint. Then use the cookies param on each rest request method to ensure that the token is properly set and a reauth does not occur with every call. Reference

wrbst commented 8 months ago

Any update on this Bhavneet-Sharma ?

Jennifer-John commented 8 months ago

Hi @ShawnEsterman @wrbst Thanks for reporting the issue. We are working on the issue fix to use cookies over login event for every API call and on releasing an updated SDK version with the fix towards the end of the month.

Thanks, Jennifer

kuttattz commented 7 months ago

Hi @ShawnEsterman @wrbst

The fix for this issue has been released in the PyPowerStore library, which can be found on GitHub (https://github.com/dell/python-powerstore) and PyPI (https://pypi.org/project/PyPowerStore/).

anupamaloke commented 4 months ago

Closed by #27