netmaker icon indicating copy to clipboard operation
netmaker copied to clipboard

[Bug]: createadmin 404

Open 3nprob opened this issue 7 months ago • 2 comments

Contact Details

No response

What happened?

On a fresh compose installation, the first visit to https://dashboard.nm.example.com is greeted with a "Create an Admin" page.

Any attempt at creating an admin account fails. We are therefore unable to start using Netmaker.

The UI says "Failed to create Admin. : admin".

Looking in the browser devtools, we see POST request to https://api.nm.example.com/api/users/adm/createadmin which fails with 404 (404 page not found).

We also see request to https://api.nm.example.com/api/extclients fail with 401 ({"Code":401,"Message":"Unauthorized"}), indicating that the requests for api.nm.example.com are proxied to the api backend.

Configuration is at this point as close to defaults as we can.

Tried both with and without setting MASTER_KEY.

Caddyfile:

# Dashboard
https://dashboard.{$NM_DOMAIN} {
        tls /etc/caddy/pki/{$NM_DOMAIN}.crt /etc/caddy/pki/{$NM_DOMAIN}.key {
        }
        # Apply basic security headers
        header {
                # Enable cross origin access to *.{$NM_DOMAIN}
                Access-Control-Allow-Origin *.{$NM_DOMAIN}
                # Enable HTTP Strict Transport Security (HSTS)
                Strict-Transport-Security "max-age=31536000;"
                # Enable cross-site filter (XSS) and tell browser to block detected attacks
                X-XSS-Protection "1; mode=block"
                # Disallow the site to be rendered within a frame on a foreign domain (clickjacking protection)
                X-Frame-Options "SAMEORIGIN"
                # Prevent search engines from indexing
                X-Robots-Tag "none"
                # Remove the server name
                -Server
        }

        reverse_proxy http://netmaker-ui
}

# API
https://api.{$NM_DOMAIN} {
        tls /etc/caddy/pki/{$NM_DOMAIN}.crt /etc/caddy/pki/{$NM_DOMAIN}.key {
        }
        reverse_proxy http://netmaker:8081
}

# MQ
broker.{$NM_DOMAIN} {
        @ws {
                        header Connection *Upgrade*
                        header Upgrade websocket
                }
        reverse_proxy @ws mq:8883
}

Version

v0.90.0 (containers built from source)

What OS are you using?

Linux

Relevant log output

 __   __     ______     ______   __    __     ______     __  __     ______     ______
/\ "-.\ \   /\  ___\   /\__  _\ /\ "-./  \   /\  __ \   /\ \/ /    /\  ___\   /\  == \
\ \ \-.  \  \ \  __\   \/_/\ \/ \ \ \-./\ \  \ \  __ \  \ \  _"-.  \ \  __\   \ \  __<
 \ \_\\"\_\  \ \_____\    \ \_\  \ \_\ \ \_\  \ \_\ \_\  \ \_\ \_\  \ \_____\  \ \_\ \_\
  \/_/ \/_/   \/_____/     \/_/   \/_/  \/_/   \/_/\/_/   \/_/\/_/   \/_____/   \/_/ /_/


[netmaker] 00:51:41 connecting to sqlite
[netmaker] 00:51:41 database successfully connected
[netmaker] 00:51:41 failed to fetch database records for hosts
[netmaker] 00:51:41 start setting up allocated ip map


[netmaker] 00:52:11 REST Server successfully started on port  8081  (REST)
[netmaker] 00:52:41 connecting to mq broker at ws://mq:1883
[netmaker] 00:53:11 Mq Client Connecting with Random ID:  V6TTW7HNVOLCU3YECMZV3IF
[netmaker] 00:53:11 connected to MQ Broker
==================                                                                                                                                                                                                                                                                                                                                                                                                                                                                             WARNING: DATA RACE
Read at 0x0000016cbf90 by goroutine 238:                                                                                                                                                                                                                                                                                                                                                                                                                                                         github.com/gravitl/netmaker/logic.FetchTelemetryRecord()
      /app/logic/telemetry.go:161 +0x56
  github.com/gravitl/netmaker/logic.TimerCheckpoint()                                                                                                                                                                                                                                                                                                                                                                                                                                                /app/logic/timer.go:28 +0x2e
  github.com/gravitl/netmaker/mq.sendPeers()
      /app/mq/publishers.go:238 +0x94
  github.com/gravitl/netmaker/mq.Keepalive()
      /app/mq/mq.go:134 +0x4b
  main.runMessageQueue.gowrap2()
      /app/main.go:184 +0x44

Previous write at 0x0000016cbf90 by main goroutine:
  github.com/gravitl/netmaker/logic.FetchTelemetryRecord()
      /app/logic/telemetry.go:173 +0x14b                                                                                                                                                                                                                                                                                                                                                                                                                                                         github.com/gravitl/netmaker/logic.TimerCheckpoint()
      /app/logic/timer.go:28 +0x2e
  main.startHooks()
      /app/main.go:81 +0x24
  main.main()
      /app/main.go:64 +0x3f2

Goroutine 238 (running) created at:
  main.runMessageQueue()
      /app/main.go:184 +0x2b1
  main.startControllers.gowrap2()
      /app/main.go:158 +0x4f
==================
==================
WARNING: DATA RACE
Read at 0x0000016cbf60 by goroutine 238:
  github.com/gravitl/netmaker/logic.FetchTelemetryRecord()
      /app/logic/telemetry.go:162 +0x411
  github.com/gravitl/netmaker/logic.TimerCheckpoint()
      /app/logic/timer.go:28 +0x2e
  github.com/gravitl/netmaker/mq.sendPeers()
      /app/mq/publishers.go:238 +0x94
  github.com/gravitl/netmaker/mq.Keepalive()
      /app/mq/mq.go:134 +0x4b
  main.runMessageQueue.gowrap2()
      /app/main.go:184 +0x44

Previous write at 0x0000016cbf60 by main goroutine:
  github.com/gravitl/netmaker/logic.FetchTelemetryRecord()
      /app/logic/telemetry.go:173 +0x14b
  github.com/gravitl/netmaker/logic.TimerCheckpoint()
      /app/logic/timer.go:28 +0x2e
  main.startHooks()
      /app/main.go:81 +0x24
  main.main()
      /app/main.go:64 +0x3f2

Goroutine 238 (running) created at:
  main.runMessageQueue()
      /app/main.go:184 +0x2b1
  main.startControllers.gowrap2()                                                                                                                                                                                                                                                                                                                                                                                                                                                                    /app/main.go:158 +0x4f
==================

Contributing guidelines

  • [x] Yes, I did.

3nprob avatar Jun 07 '25 01:06 3nprob

I see that while the UI indeed attempts to call createadmin endpoint, the endpoint has been removed in the backend and replaced with createsuperadmin as of #2547.

So https://github.com/gravitl/netmaker-ui hasn't been updated to handle >2y old API breakage and not compatible with the Netmaker API for v0.90.0. Is there a newer UI repo elsewhere...?

3nprob avatar Jun 07 '25 01:06 3nprob

the ui is closed source. docker images are published under gravitl/netmaker-ui in docker hub

Aceix avatar Jun 07 '25 16:06 Aceix

@3nprob, you are referring to an old api. Currently, the first user created is the superadmin. Make sure your UI is up to date to match the server version /api/users/adm/createsuperadmin

abhishek9686 avatar Aug 14 '25 02:08 abhishek9686