home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.2k stars 30.23k forks source link

Unifi integrations cannot login anymore in Unifi OS 4.0.3 #116420

Closed myMartek closed 5 months ago

myMartek commented 5 months ago

The problem

Today I updated to Unifi OS 4.0.3 and noticed that the integration wanted to re-auth. I tried without success and reinstalled the integration. But even after that I can only see errors and the account I try gets temporarily blocked.

What version of Home Assistant Core has the issue?

core-2024.4.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

UniFi Network

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifi

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-04-29 21:52:02.065 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://10.0.0.1:443/api/auth/login) 200 application/json <ClientResponse(https://10.0.0.1:443/api/auth/login) [200 OK]>
<CIMultiDictProxy('Server': 'nginx', 'Date': 'Mon, 29 Apr 2024 19:52:02 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'Set-Cookie': 'UOS_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI0MTE5YTY0NS02MWEyLTQ0YjAtOTMzOS03ZGIzY2NmMTViZjQiLCJwYXNzd29yZFJldmlzaW9uIjoxNzE0NDE5OTg5LCJpc1JlbWVtYmVyZWQiOmZhbHNlLCJjc3JmVG9rZW4iOiJhODUzOWFjOC1iMzM4LTQ0ZGYtOWUwYy0zZDUyMTNkMDVkOGEiLCJpYXQiOjE3MTQ0MjAzMjEsImV4cCI6MTcxNDQyNzUyMSwianRpIjoiMWQ4YmM1YjItNjYyZS00MjcyLWI4MTgtZjA5N2ZmOGY0YTZlIn0.wH2XtVypCDyw9zl7BVzh_EkwP84GoYSDBiFhBYt9z0A; path=/; expires=Mon, 29 Apr 2024 21:52:01 GMT; samesite=none; secure; httponly; partitioned', 'x-updated-csrf-token': 'a8539ac8-b338-44df-9e0c-3d5213d05d8a', 'x-token-expire-time': '1714427521946', 'X-Response-Time': '240ms', 'Access-Control-Allow-Credentials': 'false', 'Access-Control-Expose-Headers': 'Content-Disposition, Content-Range, Filename, Location, Range, Upload-Length, Upload-Offset, X-Connection-Type, X-Csrf-Token, X-File-Id, X-Token-Expire-Time, X-Updated-Csrf-Token', 'Referrer-Policy': 'no-referrer', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'X-Csrf-Token': 'a8539ac8-b338-44df-9e0c-3d5213d05d8a', 'Content-Encoding': 'gzip')>

2024-04-29 21:52:02.066 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://10.0.0.1:443/api/auth/login) b'{"id":"4119a645-61a2-44b0-9339-7db3ccf15bf4","unique_id":"4119a645-61a2-44b0-9339-7db3ccf15bf4","first_name":"Martek","last_name":"","alias":"","full_name":"Martek","email":"","user_email":"","radius_username":"","email_status":"UNVERIFIED","email_is_null":true,"phone":"","avatar_relative_path":"","avatar_rpath2":"","avatar_encoded":"","status":"ACTIVE","employee_number":"","create_time":1714419989,"extras":{},"username":"Martek","local_account_exist":true,"password_revision":1714419989,"only_ui_account":false,"only_local_account":true,"sso_account":"","sso_uuid":"","sso_username":"","sso_picture":"","uid_sso_id":"","uid_sso_account":"","uid_account_status":"","groups":[{"unique_id":"e72df523-f04d-45e0-b585-235adefb0bef","name":"UDM-SE","up_id":"","up_ids":null,"system_name":"UDM-SE","create_time":"2022-12-01T13:00:50+01:00"}],"roles":[{"unique_id":"4cfd3cbc-4b2d-432b-82b6-6f7c9be67f92","name":"Super Admin","system_role":true,"system_key":"super_administrator","level":2,"create_time":"2022-05-17T13:23:40+02:00","update_time":"2022-05-17T20:23:40+02:00","is_private":false}],"permissions":{"access.management":["admin"],"calculus.management":["admin"],"connect.management":["admin"],"drive.management":["admin"],"innerspace.management":["admin"],"led.management":["admin"],"network.management":["admin"],"olympus.management":["admin"],"protect.management":["admin"],"system.management.location":["admin"],"system.management.user":["admin"],"talk.management":["admin"]},"scopes":["write:protect.viewer","write:protect.user:$","write:protect.user","write:protect.sensor","write:protect.schedule","write:protect.nvr","write:protect.light","write:protect.legacyUFV","write:protect.group","write:protect.doorlock","write:protect.deviceGroup","write:protect.chime","write:protect.camera","write:protect.bridge","view:user_timezone","view:user","view:unifi-os:user","view:systemlog","view:settings","view:role","view:permission:viewer","view:permission:admin","view:permission","view:os-menu:user","view:os-menu:system-log","view:os-menu:storage","view:os-menu:settings","view:os-menu:notify-settings","view:os-menu:map","view:os-menu:devices","view:os-menu:about","view:notification","view:location_policy","view:location_device","view:location_activity","view:location","view:identity:update","view:identity:settings","view:identity:services","view:identity:organization_info","view:holiday_timezone","view:holiday","view:group","view:door_group","view:controller:uid-agent","view:controller:talk","view:controller:protect","view:controller:olympus","view:controller:network","view:controller:led","view:controller:innerspace","view:controller:drive","view:controller:connect","view:controller:calculus","view:controller:access","view:cloud_access","view:app:users","view:app:uid-agent","view:app:settings","view:app:locations","view:access:user","view:access.visitor","view:access.systemlog","view:access.settings","view:access.schedule","view:access.policy","view:access.pin_code","view:access.nfc_card","view:access.face","view:access.device","view:access.dashboard","update:access.device","systemlog:user","systemlog:system","systemlog:network","systemlog:location","systemlog:connect","systemlog:access","send:identity:email","revoke:identity:credential","readmedia:protect.camera","readlive:protect.camera","read:protect.viewer","read:protect.user:$","read:protect.user","read:protect.sensor","read:protect.schedule","read:protect.nvr","read:protect.light","read:protect.legacyUFV","read:protect.group","read:protect.doorlock","read:protect.deviceGroup","read:protect.chime","read:protect.camera","read:protect.bridge","open:door","notify:user","notify:location","notify:access","manage:controller:talk","manage:controller:protect","manage:controller:olympus","manage:controller:network","manage:controller:led","manage:controller:innerspace","manage:controller:drive","manage:controller:connect","manage:controller:calculus","manage:controller:access","edit:user_timezone","edit:user","edit:unifi-os:user_group","edit:unifi-os:user","edit:systemlog","edit:settings","edit:role","edit:permission:viewer","edit:permission:admin","edit:os-settings:update_install","edit:os-settings:update_channel","edit:os-settings:support_file","edit:os-settings:ssh","edit:os-settings:send_diagnostics","edit:os-settings:restart","edit:os-settings:raid","edit:os-settings:poweroff","edit:os-settings:notify","edit:os-settings:hotspare","edit:os-settings:general","edit:os-settings:client_network","edit:os-settings:auto_update","edit:notification","edit:location_policy","edit:location_device","edit:location_activity","edit:location","edit:identity:update","edit:identity:status","edit:identity:settings","edit:identity:services","edit:identity:organization_info","edit:holiday_timezone","edit:holiday","edit:group","edit:feedback","edit:door_group","edit:controller:uid-agent","edit:access:user","edit:access.visitor","edit:access.settings","edit:access.schedule","edit:access.policy","edit:access.pin_code","edit:access.nfc_card","edit:access.face","edit:access.device","deletemedia:protect.camera","delete:protect.viewer","delete:protect.user:$","delete:protect.user","delete:protect.sensor","delete:protect.schedule","delete:protect.nvr","delete:protect.light","delete:protect.legacyUFV","delete:protect.group","delete:protect.doorlock","delete:protect.deviceGroup","delete:protect.chime","delete:protect.camera","delete:protect.bridge","delete:access.device","create:protect.viewer","create:protect.user","create:protect.sensor","create:protect.schedule","create:protect.liveview","create:protect.light","create:protect.group","create:protect.doorlock","create:protect.deviceGroup","create:protect.chime","create:protect.camera","create:protect.bridge","assign:role","assign:identity:wifi","assign:identity:vpn","assign:identity:talk","assign:identity:evstation","assign:identity:camera","adopt:access.device"],"cloud_access_granted":false,"update_time":1714419989,"need_popup_ids_introduce":false,"avatar":null,"nfc_token":"","nfc_display_id":"","nfc_card_type":"","nfc_card_status":"","invalid_wg_ip":false,"invitation":null,"last_activity_time":0,"role":"admin","roleId":"4cfd3cbc-4b2d-432b-82b6-6f7c9be67f92","isOwner":false,"isSuperAdmin":true,"isMember":false,"maskedEmail":"","accessMask":2014,"permissionMask":8028,"ucorePermission":{"hasUpdateAndInstallPermission":true},"deviceToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3YjQxNzE3MS1mZGM3LTQxNGQtYTg5YS05M2Q5MDZkZDFjYTQiLCJpYXQiOjE3MTQ0MjAzMjEsImlzcyI6IlVMUC1HTyIsInVzZXJfaWQiOiI0MTE5YTY0NS02MWEyLTQ0YjAtOTMzOS03ZGIzY2NmMTViZjQifQ.LJxLHpwtlncLxe79Y-7bQM7MLZ4kYy1_icrtKCBqqFY","ssoAuth":{}}'
2024-04-29 21:52:02.066 DEBUG (MainThread) [aiounifi.interfaces.connectivity] Logged in to UniFi https://10.0.0.1:443/api/auth/login
2024-04-29 21:52:02.066 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://10.0.0.1:443/proxy/network/api/self/sites) get, None, {}
2024-04-29 21:52:02.070 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://10.0.0.1:443/proxy/network/api/self/sites) 401 application/json <ClientResponse(https://10.0.0.1:443/proxy/network/api/self/sites) [401 Unauthorized]>
<CIMultiDictProxy('Server': 'nginx', 'Date': 'Mon, 29 Apr 2024 19:52:02 GMT', 'Content-Type': 'application/json', 'Content-Length': '47', 'Connection': 'keep-alive', 'Referrer-Policy': 'no-referrer', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'Set-Cookie': 'UOS_TOKEN=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; samesite=none; secure; httponly; partitioned')>

Additional information

I am also using the UDM Pro Max device that was released recently.

home-assistant[bot] commented 5 months ago

Hey there @kane610, mind taking a look at this issue as it has been labeled with an integration (unifi) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `unifi` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign unifi` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


unifi documentation unifi source (message by IssueLinks)

Kane610 commented 5 months ago

Duplicate https://github.com/home-assistant/core/issues/116411

VitaminTe commented 5 months ago

Same issue. I deleted the integration, restarted, and then readded it. It's working fine now. I had the same issue with Scrypted during a recent UI update. I have no idea what's actually going on but it appears that your previous credentials don't actually clear when you change them. I kept getting invalid password errors and then an error relating to too many attempts. In both cases it resumed working immediately upon reinstalling the integrations/plugins.

I believe this integration works by getting a certificate from you UI device to access it. For whatever the reason when updating the certificate expires and doesn't properly refresh when you renter your password to renew it. I'm pretty sure both integrations use the same underlying code hence why the issues were identical for me be it within HA or the Scrypted plugin.

to4ko commented 5 months ago

Same issue. I deleted the integration, restarted, and then readded it. It's working fine now. I had the same issue with Scrypted during a recent UI update. I have no idea what's actually going on but it appears that your previous credentials don't actually clear when you change them. I kept getting invalid password errors and then an error relating to too many attempts. In both cases it resumed working immediately upon reinstalling the integrations/plugins.

I believe this integration works by getting a certificate from you UI device to access it. For whatever the reason when updating the certificate expires and doesn't properly refresh when you renter your password to renew it. I'm pretty sure both integrations use the same underlying code hence why the issues were identical for me be it within HA or the Scrypted plugin.

You mean Protect or Network?

VitaminTe commented 5 months ago

I'm talking about my experience with Unifi Protect. The issue was triggered when Unifi OS was updated. I don't use the network integration but I would imagine the issue would be the same as Unifi OS handles user authorization.

to4ko commented 5 months ago

There is no issues with protect. But network integration is not working. And this is the isues

PsychoV3 commented 5 months ago

I have issues logging into Protect (and Network) despite removal, rebootre-add.

PsychoV3 commented 5 months ago

I have issues logging into Protect (and Network) despite removal, rebootre-add.

Creating a newly named user has however got this working.

pazzagsi2 commented 5 months ago

Good morning, same problem with unifi UniFi OS 4.0.3 on DMP and HomeAssistant for a few days. From the DMP logs it seems to log in but the ha integration stops and after a while it gives the generic error.

Thanks for your interest

Kane610 commented 5 months ago

This is a duplicate and fix has been merged and should be part of 2024.5.1