Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniFi User management library aiounifi not implemented #771

Open
cinghialino opened this issue Sep 23, 2024 · 5 comments
Open

UniFi User management library aiounifi not implemented #771

cinghialino opened this issue Sep 23, 2024 · 5 comments
Assignees
Labels

Comments

@cinghialino
Copy link

Operating system

doesn't matter

UniFi Tag

latesr

Docker run

irrelevant

Bug description

it appears that the library component responsible for user management aiounifi is oot implemented, as reported in this link. ufozone/ha-unifi-voucher#125 (comment)

I am wondering if it could be implemented in your already great docker image.

Thanks!

Steps to reproduce

No response

Relevant log output

2024-09-20 11:33:02.725 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://10.0.99.133:32770) get, None, False
2024-09-20 11:33:02.796 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://10.0.99.133:32770) 302 application/octet-stream <ClientResponse(https://10.0.99.133:32770) [302 None]>
<CIMultiDictProxy('Location': '/manage', 'Content-Length': '0', 'Date': 'Fri, 20 Sep 2024 11:33:02 GMT')>

2024-09-20 11:33:02.796 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://10.0.99.133:32770) b''
2024-09-20 11:33:02.796 DEBUG (MainThread) [aiounifi.interfaces.connectivity] Talking to UniFi OS device: False
2024-09-20 11:33:02.797 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://10.0.99.133:32770/api/login) post, {'username': 'test', 'password': 'test', 'rememberMe': True}, True
2024-09-20 11:33:03.587 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://10.0.99.133:32770/api/login) 400 application/json <ClientResponse(https://10.0.99.133:32770/api/login) [400 None]>
<CIMultiDictProxy('Vary': 'Origin', 'X-Frame-Options': 'DENY', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '57', 'Date': 'Fri, 20 Sep 2024 11:33:02 GMT', 'Connection': 'close')>

2024-09-20 11:33:03.587 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://10.0.99.133:32770/api/login) b'{"meta":{"rc":"error","msg":"api.err.Invalid"},"data":[]}'
2024-09-20 11:33:03.587 ERROR (MainThread) [aiounifi.interfaces.connectivity] Login failed '{'meta': {'rc': 'error', 'msg': 'api.err.Invalid'}, 'data': []}'
2024-09-20 11:33:03.587 WARNING (MainThread) [custom_components.unifi_voucher] Connected to UniFi Network at 10.0.99.133 but login required:
@jacobalberty
Copy link
Owner

There shouldn't be anything to implement, this image just uses the standalone unifi installation inside of a docker image. I see mentions of UniFi OS though is this something that only works on UniFi OS and not the standalone install?

@cinghialino
Copy link
Author

yeah it appears that the docker image does not contains the aiounifi library - preventing me to use a "hotspot manager" only user when accessing it through this software.
It's not the end of the world, I just wanted to make you aware that something may (or may not) be missing in the image, and for the sake of curiosity, you may want to investigate.
Again, thank you for your work.

@jacobalberty
Copy link
Owner

aiounifi is a python interface for unifi, you wouldnt put it in the docker image you use it to connect to a unifi controller, you use it externally to it, ha-unifi-voucher includes aiounifi itself and is where aiounifi would need to exist for this to work. It looks like you're getting a 400 bad request and aiounifi is intepreting that as unauthorized.

I would check the contents of your /unifi/log folder to see if any of the messages there seem relevant. Try a login with a hotspot user and see if its giving an error message in access.log or server.log there's also a hotspot.log that might be relevant, i'm not sure how relevant the other log messages would be.

@ufozone
Copy link

ufozone commented Oct 11, 2024

You are right. The HA integration ha-unifi-voucher uses the Python library aiounifi to communicate with the UniFi Controller.

The login against the UniFi Controller API endpoint /api/login with an admin user works fine. The login with a user with only Hotspot Manager rights returns the response 400 Bad Request. Logging in with such a user against a UDM or a CK 2 works without any problems.

So it looked to me like the API endpoint /api/login provided in your image was responding differently than in the official UniFi OS.

With more logs you could understand it better. Perhaps @cinghialino will provide something.

@cinghialino
Copy link
Author

Hi there, the only errors in the logs are these:

2024-10-11 08:30:37.830 ERROR (MainThread) [aiounifi.interfaces.connectivity] Login failed '{'meta': {'rc': 'error', 'msg': 'api.err.Invalid'}, 'data': []}' 2024-10-11 08:30:37.830 WARNING (MainThread) [custom_components.unifi_voucher] Connected to UniFi Network at [internal IP address redacted for privacy] but login required:

and

2024-10-11 08:35:00.901 ERROR (MainThread) [aiounifi.interfaces.connectivity] Login failed '{'meta': {'rc': 'error', 'msg': 'api.err.Invalid'}, 'data': []}' 2024-10-11 08:35:00.902 WARNING (MainThread) [custom_components.unifi_voucher] Connected to UniFi Network at [domain redacted for privacy] but login required:

there's nothing else in the logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants