Acosix / alfresco-python-client

WIP / prototyping project for a Python 3.x client using Alfresco Public Rest API
6 stars 5 forks source link

Ticket timeout #2

Open mrichez-saluc opened 4 years ago

mrichez-saluc commented 4 years ago

Hi Axel,

I'm using your client to develop an alfresco gui search. I do the login on Alfresco when launching the program then i'm using the Client object returned by the connect method. But seems after some inactivity (1hour), ticket is invalid... So wondering how to refresh authentication... ticket is a private attribute in the Client object.

So wondering if this line should be outside the if block to check if ticket is still valid: https://github.com/Acosix/alfresco-python-client/blob/c701416fd827ba06cc811c394cdcf40c5dd5b3eb/common/connections.py#L53

Thanks for help!

mrichez-saluc commented 4 years ago

Don't see any change when putting line outside the block (so bad idea). Maybe adding a public method on Client to refresh ticket ? In connect method, ticket is a parameter, but Client model doesn't give a method or attribute to get ticket to use it later.

AFaust commented 4 years ago

I had not considered the use of the library for long running, idle processes that may run into such an issue. What I could see is a config option to specify a ticketRefreshIfIdle timeout. Since the client is a central component to execute requests, it can track when the last request was performed, and proactively try to obtain a new ticket if it was too far in the past. It would only require that the user/password details are kept alive after connect() to support the refresh handling - and it would not work if the initial connect was performed with a pre-established ticket.

mrichez-saluc commented 4 years ago

Thanks for your answer, we solve this problem by extending duration of authentication ticket in global properties of Alfresco.