gravitl / netmaker

Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.
https://netmaker.io
Other
9.52k stars 552 forks source link

[Bug]: netclient: error while attempting to join: `W1R3: ID can't be empty` #1217

Closed jrop closed 2 years ago

jrop commented 2 years ago

Contact Details

No response

What happened?

I cannot join my NetMaker network (after previously successfully joining it and leaving it once). I was hoping that the update released today would fix the issue, but it does not.

❯ uname -a
Linux myhost 5.17.5-76051705-generic #202204271406~1653440576~22.04~6277a18 SMP PREEMPT Wed May 25 01 x86_64 x86_64 x86_64 GNU/Linux
❯ sudo netclient --version
Netclient version v0.14.3
❯ sudo netclient join -t ...
[netclient] 2022-06-16 12:56:47 joining netmaker at api.nm.11-111-111-111.nip.io:443
[netclient] 2022-06-16 12:56:47 unable to authenticate: failed to authenticate 400 Bad Request {"Code":400,"Message":"W1R3: ID can't be empty"}
[netclient] 2022-06-16 12:56:49 removed systemd remnants if any existed
[netclient] 2022-06-16 12:56:49 removed systemd remnants if any existed

Version

v0.14.3

What OS are you using?

Linux

Relevant log output

See above.

Contributing guidelines

mattkasun commented 2 years ago

Has the netmaker server been updated to v0.14.3? Have you deleted all tokens and generated new ones?

byniow commented 2 years ago

Same problem on fresh, today installed netmaker 0.14.3. Linux client (from outside LAN via public IP) connect well, Windows client from LAN with netmaker server cannot connect with error [netclient.exe] 2022-06-19 19:25:45 unable to authenticate: failed to authenticate 400 Bad Request {"Code":400,"Message":"W1R3: ID can't be empty"}

mattkasun commented 2 years ago

could you run the join command with additional verbosity ie. netclient join -vvv -t <token>

jrop commented 2 years ago

I updated the server, and things seem to be working for me now. Thanks for the help!

byniow commented 2 years ago

From GUI error still exist as before, from CMD (as admin) i join once to netmaker server, second time in the same window i get error.

c:\Program Files (x86)\Netclient>netclient join -vvv -t key
2022/06/20 16:40:07 Gravitl Netclient on Windows started
[netclient.exe] 2022-06-20 16:40:07 joining net at api.nm.x.x.x.xnip.io:443
[netclient.exe] 2022-06-20 16:40:08 node created on remote server...updating configs
[netclient.exe] 2022-06-20 16:40:08 starting wireguard
[netclient.exe] 2022-06-20 16:40:08 turn on UDP hole punching (dynamic port setting)? no
[netclient.exe] 2022-06-20 16:40:11 waiting for interface...
[netclient.exe] 2022-06-20 16:40:13 interface ready - netclient.. ENGAGE
[netclient.exe] 2022-06-20 16:40:14 register at https://api.nm.x.x.x.x.nip.io:443/api/server/register
[netclient.exe] 2022-06-20 16:40:14 certificates/key saved
[netclient.exe] 2022-06-20 16:40:14 sent a node update to server for node DESKTOP-QRB ,  3fb0b807-ded9-4518-9591-xxxxxxxxxx
[netclient.exe] 2022-06-20 16:40:15 running stop of Windows Netclient daemon
[netclient.exe] 2022-06-20 16:40:16 successfully ran stop of Windows Netclient daemon
[netclient.exe] 2022-06-20 16:40:16 running start of Windows Netclient daemon
[netclient.exe] 2022-06-20 16:40:17 successfully ran start of Windows Netclient daemon
[netclient.exe] 2022-06-20 16:40:17 joined  xxxx

c:\Program Files (x86)\Netclient>netclient leave -n xxxx
2022/06/20 16:45:33 Gravitl Netclient on Windows started
[netclient.exe] 2022-06-20 16:45:33 unable to authenticate: failed to authenticate 400 Bad Request {"Code":400,"Message":"W1R3: ID can't be empty"}
[netclient.exe] 2022-06-20 16:45:34 running stop of Windows Netclient daemon
[netclient.exe] 2022-06-20 16:45:36 successfully ran stop of Windows Netclient daemon
[netclient.exe] 2022-06-20 16:45:36 success

c:\Program Files (x86)\Netclient>netclient join -vvv -t xxxxxxxx
2022/06/20 16:45:42 Gravitl Netclient on Windows started
[netclient.exe] 2022-06-20 16:45:42 joining xxxx at api.nm.x.x.x.x.nip.io:443
[netclient.exe] 2022-06-20 16:45:42 error installing:  error creating node 401 Unauthorized {"Code":401,"Message":"You are unauthorized to access this endpoint."}
[netclient.exe] 2022-06-20 16:45:42 unable to authenticate: failed to authenticate 400 Bad Request {"Code":400,"Message":"W1R3: ID can't be empty"}
[netclient.exe] 2022-06-20 16:45:42 could not flush peer routes when leaving network,  prywatna-dom
[netclient.exe] 2022-06-20 16:45:42 removed  xxxxxx  network locally
[netclient.exe] 2022-06-20 16:45:43 running stop of Windows Netclient daemon
[netclient.exe] 2022-06-20 16:45:45 successfully ran stop of Windows Netclient daemon
mattkasun commented 2 years ago

How many uses did the token have? It appears that it was a single use token -- so when you join the second time you will get the "you are unauthorized to access this endpoint" error.

byniow commented 2 years ago

Ok, i create new key with 10 uses. I'm not see this before - sorry. And when i enter key in GUI then i get error with "400 bad request", but from cmd (as admin) netclient successfully joined. And in gui connection is visible.

syonfox commented 1 year ago

For me this was caused by not providing a node id in the header

curl --ssl -d  '{"username": "my_user", "password": "the-password-seems-to-not-work", "id":"5990b4d5-d341-4360-859a-7d1f3d676e94"}' -H 'Content-Type: application/json' https://api.netmaker.example.ca/api/nodes/adm/test/authenticate
{"Code":400,"Message":"crypto/bcrypt: hashedPassword is not the hash of the given password"}

By addin the 'id' into the request above to solve the W1R3: ID can't be empty

1217

but it seems not not accept my users.

Does anyone know what may cause this?

I should add that it seams like a problem with the jwt. does anyone know where the documentation(code) is for the json authorization token. .. is it hashed in the ui front end before being sent to the api.

I'm pretty sure the user and password is correct tried multiple times. on and off the vpn.

D3it7i commented 1 year ago

Same with this, two windows NetClient, this problem always happens with the second client that joins. Then ,the AccessKey will be used and dashboard will see the client join, but just not work

This is because my dns record has ipv6 and the configuration is not downloaded correctly (#1807 )