unifi-client icon indicating copy to clipboard operation
unifi-client copied to clipboard

UniFi v9

Open patrickclover opened this issue 11 months ago • 9 comments

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [*] I am running the latest version
  • [*] I checked the documentation and found no answer
  • [*] I checked to make sure that this issue has not already been filed

Current Behavior

When running on > 9.0 authentication/login method fails

Failure Information

The error returned from the, working under the assumption that the cookie keys have changed

ClientError { app-1 | toString: [Function (anonymous)], app-1 | name: 'Error', app-1 | errorCode: 2, app-1 | code: 2, app-1 | _message: 'fail to get CSRF token from cookies', app-1 | message: 'fail to get CSRF token from cookies', app-1 | exception: undefined, app-1 | stack: 'Error : fail to get CSRF token from cookies\n' + app-1 | 'Error: \n' + app-1 | ' at generateStack (/app/node_modules/unifi-client/lib/Errors/__Error.js:35:28)\n' + app-1 | ' at ClientError.__Error (/app/node_modules/unifi-client/lib/Errors/__Error.js:49:22)\n' + app-1 | ' at new ClientError (/app/node_modules/unifi-client/lib/Errors/ClientError.js:25:23)\n' + app-1 | ' at UnifiAuth. (/app/node_modules/unifi-client/lib/UnifiAuth.js:284:39)\n' + app-1 | ' at step (/app/node_modules/unifi-client/lib/UnifiAuth.js:59:23)\n' + app-1 | ' at Object.next (/app/node_modules/unifi-client/lib/UnifiAuth.js:40:53)\n' + app-1 | ' at fulfilled (/app/node_modules/unifi-client/lib/UnifiAuth.js:31:58)\n' + app-1 | ' at processTicksAndRejections (node:internal/process/task_queues:96:5)' app-1 | }

Steps to Reproduce

Call the login function against a controller running v9

patrickclover avatar Jan 13 '25 12:01 patrickclover

Hi @patrickclover . I will need more informations to help you ...

Can you try to check with debug logs if you can get more informations ?

Actually, my unifiOS is running network 9.0.108 . And authentication works .

thib3113 avatar Jan 13 '25 22:01 thib3113

I am having similar issues when try to connect, running v0.11.0 of the package, and unifi is running 9.0.108.

I am getting HTTP response code 400 when executing the controller.login() method.

Happy to do some debugging for you let me know how I can get some files across, I caught the TTY output when it dies but log file is 2.5MB text file and 686000 lines just form trying to make the login call. Not sure you want all of that.

davey-g-uk avatar Jan 16 '25 21:01 davey-g-uk

hum ...

You can search for the log : unifi-client:UnifiAuth:login os found : to check if it correctly detect if you use unifiOS or not ?

Searching this log, it only happen when you are using unifi software, without unifiOS, is it the case ?

( I just tried to update my test setup of network app, but the docker image is deprecated and not updated with V9 .... and not really the time to do the upgrade now ... )

If you want, you can send me the log to thib3113[at]gmail[dot]com . I can try to check if I can get the informations .

thib3113 avatar Jan 16 '25 22:01 thib3113

The issue is the error throwing in the UnifiAuth function. The check for unifiOs is now void as UniFiOS and v9 self hosted respond in the same way.

throw new ClientError(
 'fail to get CSRF token from cookies',
 EErrorsCodes.FAIL_GET_CSRF_COOKIE
)

patrickclover avatar Jan 16 '25 23:01 patrickclover

Hi @patrickclover and @davey-g-uk .

I finaly got the time to migrate my test environment to v9, and in fact, I correctly receive the csrf token from headers .

I didn't have lot of time to try, but, it seems to not be the same thing on all v9 .

On my side I'm using unifi network through docker : https://github.com/linuxserver/docker-unifi-network-application / and unifiOS on an UDM pro

What are you using on your side ? UnifiOs or running on other os ? user is admin ? 2FA ? local ? other ideas ?


Ok, I got it ... UI add a strict = true on login request ... and so it return the csrf token

thib3113 avatar Feb 09 '25 10:02 thib3113

Can you confirm if V0.11.1 fix your problem please ?

thib3113 avatar Feb 09 '25 17:02 thib3113

Hi,

I tried v0.11.1 and still get the same: 

For your reference, I am running the unifi controller in a container (http://lscr.io/linuxserver/unifi-network-application) on an UNRAID NAS.

Container updated today and is now running controller version 9.0.114

I run the web interface for the controller through a nginx reverse proxy but I have tried bypassing this and get the same error.

Thanks

David

---- On Sun, 09 Feb 2025 17:22:27 +0000 Thibaut SEVERAC @.***> wrote ---

Can you confirm if https://github.com/thib3113/unifi-client/releases/tag/v0.11.1 fix your problem please ?

— Reply to this email directly, https://github.com/thib3113/unifi-client/issues/711#issuecomment-2646424581, or https://github.com/notifications/unsubscribe-auth/AC3QPDYZ2NVKU36NRFDVFDL2O6FFHAVCNFSM6AAAAABVCRKLYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNBWGQZDINJYGE. You are receiving this because you were mentioned.

davey-g-uk avatar Feb 13 '25 20:02 davey-g-uk

@davey-g-uk always the same error ? O_o

thib3113 avatar Feb 13 '25 21:02 thib3113

Hello,

I am using 0.11.1 in homebridge-UniFi-firewall and do not see an authentication issue with 9.0.114. I have SSL certificate checking turned off in that homebridge plugin (all local testing at present).

Dream Machine Special Edition

Just wanted to chime in and say that auth piece works for me, yet the getRules() does not as per discussion thread from yesterday.

Thanks team, have a great day, Nick

nmuldoon avatar Mar 03 '25 09:03 nmuldoon