openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

[loxone] Token not clearing out, once expired. #6048

Closed jatin-28 closed 3 years ago

jatin-28 commented 5 years ago

Expected Behavior

After a certain period of time the token expires and needs to be refreshed. If this fails, a new handshake agreement needs to occur

Current Behavior

After x months or so, I've noticed that loxone tends to fail. Haven't pin pointed the exact scenario but loxone is offline. (could be after a loxone config change on the server) Restarting openhab doesn't work. Instead clearing the cached token in the openhab loxone binding config, allows reauthentication.

Environment:using latest version of github loxone addon.

possible solution

If token retry fails, evict token and try reauthentication from scratch.

ppieczul commented 5 years ago

Hi @jatin-28. Probably some problem with token refresh. The re-submission you suggest is not possible unless we decide to store the password. Currently after successful token gain, the password is cleared in the configuration, so nobody can steal it. This is kind of the way it should work. Could you see if you have any traces in the log from around it failed? Thanks Pawel

jatin-28 commented 4 years ago

That's true! (thought it was stored but it was my browser). Sounds to me though this is a bigger issue and requires a notification to an email or something to say hey login again. Will have a think.

ppieczul commented 4 years ago

@jatin-28 the token has an expiration date and there is a mechanism in the API to refresh the validity of the token. I suppose either there is a bug in the binding or in the Miniserver. The refresh is scheduled for several weeks or months in the future, so it is not often that it is needed and the problem might have not surfaced yet, because the Loxone applications do not maintain the connection for that long. I will try to write a unit test for that with a shortened expiration. Anyway, if you have any logs, they could help a lot. Thanks

jatin-28 commented 4 years ago

With loxone it allows you to perform a refresh with the older token. However, I think rebooting the server causes the tokens to be cleared. Either that or the refresh call isn't being made at the right time.

jatin-28 commented 4 years ago

I'll try and find logs for this, or try and recreate the issue at some point as well.

ppieczul commented 4 years ago

Thanks. I am sure I had multiple server reboots also due to power outage, but I have not re-entered the password for months now, so it must have logged in with a token. I have not yet had time to look into it.

śr., 18 wrz 2019 o 09:11 jatin-28 notifications@github.com napisał(a):

I'll try and find logs for this, or try and recreate the issue at some point as well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/openhab/openhab2-addons/issues/6048?email_source=notifications&email_token=ACOHS7SPRUNULXWPHKCR66LQKHIDBA5CNFSM4IUXEWD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD67BVPI#issuecomment-532552381, or mute the thread https://github.com/notifications/unsubscribe-auth/ACOHS7T4YJCHNPOEFFOTABLQKHIDBANCNFSM4IUXEWDQ .

ppieczul commented 4 years ago

@jatin-28 did anything like that happen again? I checked logs of my installation and found a correctly performed token refresh. It happens once per 54 days, so it is hard to reproduce on the real installation.

jatin-28 commented 4 years ago

@ppieczul Sorry - have been very tied up at the moment. It happens quite regularly. Just havent had the chance to analyse the logs - takes a while due to the amount of data to try and figure out at what point it stopped as it could be over a few days.

hmerk commented 3 years ago

closed due to inactivity