elad-bar / ha-edgeos

Integration with EdgeOS (Ubiquiti)
134 stars 24 forks source link

Invalid credentials to EdgeOS Router #25

Closed wilfredsmit closed 4 years ago

wilfredsmit commented 4 years ago

I noticed that my EdgeOS integration didn't work after a couple of updates of the component. So I decided to reinstall the integration.

First I removed the integration and after that I deinstalled it from HACS. Next I rebooted home assistant core.

After that I installed EdgeOS again in HACS. Next I went to the integration and filled in all information. Name, IP-address of the router, the special made user with operator rights, the password of this user.

Still I cannot configure EdgeOS. Everytime I get the message: 'Invalid credentials to EdgeOS Router'. Although on the web admin panel of the router I see the number of active sessions for this user increasing.

Any idea what I'm doing wrong?

elad-bar commented 4 years ago

Can you please create another admin user and test it with the new admin user?

wilfredsmit commented 4 years ago

Doesn't matter. Exactly the same happens with a new created user. Even if it is an administrator.

neilsb commented 4 years ago

FWIW, I've just installed this integration for the first time, and am getting the same problem. User can log in fine directly via the EdgeOS login page, but getting "Invalid credentials" message via HA.

elad-bar commented 4 years ago

I can't reproduce the issue with the same flow in my HA, can you please post the log?

thanks

elad-bar commented 4 years ago

What is your EdgeOS version?

neilsb commented 4 years ago

Version: EdgeOSv2.0.8-hotfix.1

2020-04-28 12:22:22 INFO (SyncWorker_4) [homeassistant.loader] Loaded edgeos from custom_components.edgeos
2020-04-28 12:22:23 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for edgeos which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-04-28 12:22:38 INFO (MainThread) [custom_components.edgeos.managers.password_manager] Key generated and stored at /config/edgeos.key
2020-04-28 12:25:42 ERROR (MainThread) [custom_components.edgeos.clients.web_api] Failed to login, Invalid credentials
2020-04-28 12:25:42 WARNING (MainThread) [custom_components.edgeos.managers.config_flow_manager] Failed to login EdgeOS (Edge Router) due to HTTP Status Code: 403
2020-04-28 12:26:21 ERROR (MainThread) [custom_components.edgeos.clients.web_api] Failed to login, Invalid credentials
2020-04-28 12:26:21 WARNING (MainThread) [custom_components.edgeos.managers.config_flow_manager] Failed to login EdgeOS (Edgerouter) due to HTTP Status Code: 403
2020-04-28 12:28:05 ERROR (MainThread) [custom_components.edgeos.clients.web_api] Failed to login, Invalid credentials
2020-04-28 12:28:05 WARNING (MainThread) [custom_components.edgeos.managers.config_flow_manager] Failed to login EdgeOS (Edge Router) due to HTTP Status Code: 403

And as mentioned by @wilfredsmit, the Active Session count in the User List on EdgeOS increases with each attempt:

image

elad-bar commented 4 years ago

can you run it again with debug level of logs for the component?


logger:
  default: warning
  logs:
    custom_components.edgeos: debug
neilsb commented 4 years ago

I'm afraid it doesn't seem to have given much more info:


2020-04-28 16:20:28 DEBUG (MainThread) [custom_components.edgeos.config_flow] Starting async_step_user of EdgeOS
2020-04-28 16:20:39 DEBUG (MainThread) [custom_components.edgeos.config_flow] Starting async_step_user of EdgeOS
2020-04-28 16:20:42 ERROR (MainThread) [custom_components.edgeos.clients.web_api] Failed to login, Invalid credentials

2020-04-28 16:20:42 WARNING (MainThread) [custom_components.edgeos.managers.config_flow_manager] Failed to login EdgeOS (ha) due to HTTP Status Code: 403
elad-bar commented 4 years ago

since I cannot reproduce the issue, can you try running the login request same the component doing from Postman and post the cookie response?

Request Url: https://IP_OF_EDGE_OS Method: POST Body parameters:

image

neilsb commented 4 years ago

Response seems to contain same cookies as yours:

image

(Same result when body to x-www-form-urlencoded BTW)

elad-bar commented 4 years ago

seems that PHPSESSID and beaker.session.id values are match, which makes it more weird. the only difference is that you are using IP and i'm using full domain name.

Checked and managed to reproduce the issue with IP, will try to solve it.

thanks for the information.

neilsb commented 4 years ago

I guess one thing that might be worth mentioning is that a standard https:// connection to the EdgeRouter management page does produce a browser warning, as there is not a valid SSL certificate. Since it was only ever going to be accessed internally I did not think that was required...

elad-bar commented 4 years ago

for faster solution so it will work for you, you can set the hostname of the router instead of the IP, it doesn't matter if the certificate is valid or not, component is skipping that check

elad-bar commented 4 years ago

Release new version with the support of IP, please let me know if it works for you

thanks

wilfredsmit commented 4 years ago

Yes! The new release is working again with an IP address. Thanks.

neilsb commented 4 years ago

Working for me too. Thanks very much.