How to pass --ui-jwt-secret argument to supply the secret key used for signing browser cookies?

Hi everyone,
I am totally new in genieacs.
This is my first time to install genieacs.
I have a question about genieacs UI.

From genieacs/README.md at master · genieacs/genieacs · GitHub

genieacs-ui

This serves the web based user interface. It listens on port 3000 by default. You must pass --ui-jwt-secret argument to supply the secret key used for signing browser cookies:

genieacs-ui --ui-jwt-secret secret
The UI has plenty of configuration options. When you open GenieACS’s UI in a browser you’ll be greeted with a database initialization wizard to help you populate some initial configuration.

My question is how to get the secret key?
And how to pass it to browser?
Many thanks!

Hi,
the UI_JWT_SECRET must be passed to the genieacs-ui process as a environment variable, so if you configured the process to run as a systemd service, you must add this line to the environment file configured:

GENIEACS_UI_JWT_SECRET=<insert_random_string_here>

Hi Lavira,
Many many thanks for your answer. :slight_smile:
Now my environment variable in /opt/genieacs/genieacs.env is
GENIEACS_UI_JWT_SECRET=secret

Do you mean I should change it to
GENIEACS_UI_JWT_SECRET=<random_string> ?
Where should I get this random string?

Thanks for your help!
Vincent

Hi Lavira,
Can you help to check my steps:

  1. I try to online create a JWR_SECRET from https://www.javainuse.com/jwtgenerator
  2. Then I get the key as
    eyJhbGciOiJIUzI1NiJ9.eyJVc2VybmFtZSI6IkphdmFJblVzZSJ9.Cak4ou7W9ndNFTc-4JxXQcBw3jbhxa7ve34JHFHh8K0
  3. Then I update /opt/genieacs/genieacs.env as
    GENIEACS_UI_JWT_SECRET=eyJhbGciOiJIUzI1NiJ9.eyJVc2VybmFtZSI6IkphdmFJblVzZSJ9.Cak4ou7W9ndNFTc-4JxXQcBw3jbhxa7ve34JHFHh8K0
  4. Restart genieacs-ui service
  5. From browser, input http://<GENIEACS_UI_INERFACE>:3000
    But still get “This site can’t be reached”

Thanks!

In order for the UI to work, you also need the other UI related config in that genieacs.env file:

GENIEACS_UI_INTERFACE=0.0.0.0
GENIEACS_UI_PORT=3000

do you have these? If yes, what’s the output of the following command?

systemctl status genieacs-ui.service

Hi Lavira,
Thanks for your feedback.
[root@zch127bld11 genieacs]# systemctl status genieacs-ui
genieacs-ui.service - GenieACS UI
Loaded: loaded (/etc/systemd/system/genieacs-ui.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-06-07 13:38:17 CST; 2s ago
Main PID: 25168 (node)
Tasks: 53
CGroup: /system.slice/genieacs-ui.service
25168 /extra/vwang2/node/node/bin/node /extra/vwang2/genieacs_master/genieacs-master/dist/bin/genieacs-ui
25179 /data/sdc1/vwang2/node/node/bin/node /extra/vwang2/genieacs_master/genieacs-master/dist/bin/genieacs-ui
25183 /data/sdc1/vwang2/node/node/bin/node /extra/vwang2/genieacs_master/genieacs-master/dist/bin/genieacs-ui
25193 /data/sdc1/vwang2/node/node/bin/node /extra/vwang2/genieacs_master/genieacs-master/dist/bin/genieacs-ui
25221 /data/sdc1/vwang2/node/node/bin/node /extra/vwang2/genieacs_master/genieacs-master/dist/bin/genieacs-ui
25234 /data/sdc1/vwang2/node/node/bin/node /extra/vwang2/genieacs_master/genieacs-master/dist/bin/genieacs-ui
25248 /data/sdc1/vwang2/node/node/bin/node /extra/vwang2/genieacs_master/genieacs-master/dist/bin/genieacs-ui

Jun 07 13:38:18 zch127bld11 node[25168]: 2021-06-07T05:38:18.905Z [ERROR] Uncaught exception; pid=25241 exceptionName=“MongoNetworkError” exceptionMessage="connection 2 to 127.0.0.1:27017 closed…-master/node_m
Jun 07 13:38:18 zch127bld11 node[25168]: 2021-06-07T05:38:18.917Z [ERROR] Worker died; pid=25241 exitCode=0
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.196Z [ERROR] Uncaught exception; pid=25273 exceptionName=“MongoNetworkError” exceptionMessage="connection 2 to 127.0.0.1:27017 closed…-master/node_m
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.206Z [ERROR] Worker died; pid=25273 exitCode=0
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.367Z [ERROR] Uncaught exception; pid=25187 exceptionName=“MongoNetworkError” exceptionMessage="connection 2 to 127.0.0.1:27017 closed…-master/node_m
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.381Z [ERROR] Worker died; pid=25187 exitCode=0
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.386Z [ERROR] Uncaught exception; pid=25212 exceptionName=“MongoNetworkError” exceptionMessage="connection 2 to 127.0.0.1:27017 closed…-master/node_m
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.400Z [ERROR] Worker died; pid=25212 exitCode=0
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.428Z [ERROR] Uncaught exception; pid=25227 exceptionName=“MongoNetworkError” exceptionMessage="connection 2 to 127.0.0.1:27017 closed…-master/node_m
Jun 07 13:38:19 zch127bld11 node[25168]: 2021-06-07T05:38:19.442Z [ERROR] Worker died; pid=25227 exitCode=0
Hint: Some lines were ellipsized, use -l to show in full.

genieacs.env
GENIEACS_CWMP_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-cwmp-access.log
GENIEACS_NBI_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-nbi-access.log
GENIEACS_FS_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-fs-access.log
GENIEACS_UI_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-ui-access.log
GENIEACS_DEBUG_FILE=/var/log/genieacs/genieacs-debug.yaml
NODE_OPTIONS=–enable-source-maps
GENIEACS_EXT_DIR=/opt/genieacs/ext
GENIEACS_UI_JWT_SECRET=eyJhbGciOiJIUzI1NiJ9
GENIEACS_UI_INTERFACE=10.213.0.11
GENIEACS_UI_PORT=3000
GENIEACS_NBI_INTERFACE=10.213.0.11
GENIEACS_CWMP_INTERFACE=10.213.0.11
GENIEACS_FS_INTERFACE=10.213.0.11

Hi, The logs indicate clearly that the service can’t connect to the mongo database. It seems you are missing a line, in the genieacs.env file, like:

GENIEACS_MONGODB_CONNECTION_URL=mongodb://user:password@127.0.0.1/genieacs

Since you don’t mention this, the default connction url is mongodb://127.0.0.1/genieacs and I think you don’t have mongodb running (systemctl start mongodb) or you don’t allow the connection. If you forgot to install it, here you can find install instructions.

1 Like

Thank you very much Lavira!
It is very helpful.
I have installed mongodb, I am configuring it now.

Vincent

Many thanks Lavira!
After configuring mongodb, genieacs-ui works well.
I use genieacs-sim to do some basic test.
From “Devices”, I can find the simulator. :slight_smile: