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

Admin Password in Docker Compose #1169

Closed
Chacsam opened this issue May 22, 2023 · 8 comments · Fixed by #1183
Closed

Admin Password in Docker Compose #1169

Chacsam opened this issue May 22, 2023 · 8 comments · Fixed by #1183

Comments

@Chacsam
Copy link

Chacsam commented May 22, 2023

Hello,

I am trying to install ihatemoney through a Portainer Stack (docker-compose file), but I cannot get the Admin password to work..
Using a https reverse proxy I avoid the invalid CRSF with secure cookies, but I always get "Admin password: This admin password is not the right one. Only x attempts left." on the admin page.

My code to generate the hash: docker run -it --rm --entrypoint ihatemoney ihatemoney/ihatemoney generate_password_hash

My Docker-compose

version: "3.0"
services:
  ihatemoney:
    image: ihatemoney/ihatemoney:latest
    container_name: I_Hate_Money
    network_mode: "bridge"
    environment:
      - BABEL_DEFAULT_TIMEZONE=xxx
      - ACTIVATE_ADMIN_DASHBOARD=True
      - ACTIVATE_DEMO_PROJECT=False
      - ALLOW_PUBLIC_PROJECT_CREATION=True
      - SHOW_ADMIN_EMAIL=True
      - ADMIN_PASSWORD=pbkdf2:sha256:260000$bvN2imsPpC323VGJ$xxxxxx
      - MAIL_SERVER=xxx
      - MAIL_PORT=587
      - MAIL_DEFAULT_SENDER=Expense Split <xxxxx@xxxxx.xx>
      - MAIL_USERNAME=xxxx@xxx.xx
      - MAIL_PASSWORD=xxxx
      - MAIL_USE_SSL=False
      - MAIL_USE_TLS=True
    volumes:
      - /home/my_map/apps/ihatemoney/db:/database
    ports:
      - 41008:8000
    restart: unless-stopped

Docker 24.0 on a Ubuntu 22.04 container in Proxmox.

Am I doing something wrong?

@AkshayRao27
Copy link

AkshayRao27 commented Jun 23, 2023

I have the same issue.

I am on Ubuntu 22.04.1 LTS and using Portainer CE 2.17.0 Docker 23.0.1.

I tried generating the hash using just ihatemoney generate_password_hash via the Portainer Console within the container, as well as generating it via the console using the same command you did.

Here's my compose file:

version: "3.9"

services:
  ihatemoney:
    image: ihatemoney/ihatemoney:latest
    environment:
      - DEBUG=False
      - ACTIVATE_ADMIN_DASHBOARD=True
      - ACTIVATE_DEMO_PROJECT=False
      - ADMIN_PASSWORD=<hash-generated-as-described-above>
      - ALLOW_PUBLIC_PROJECT_CREATION=True
      - BABEL_DEFAULT_TIMEZONE=Europe/Vienna
      - GREENLET_TEST_CPP=no
      - MAIL_DEFAULT_SENDER=Budget Manager <admin@example.com>
      - MAIL_PASSWORD=
      - MAIL_PORT=25
      - MAIL_SERVER=localhost
      - MAIL_USE_SSL=False
      - MAIL_USE_TLS=False
      - MAIL_USERNAME=
      - SECRET_KEY=<is-a-secret>
      - SESSION_COOKIE_SECURE=False
      - SHOW_ADMIN_EMAIL=True
      - SQLALCHEMY_DATABASE_URI=sqlite:////database/ihatemoney.db
      - SQLALCHEMY_TRACK_MODIFICATIONS=False
      - ENABLE_CAPTCHA=True
      - LEGAL_LINK=
      - PORT=8000
      - PUID=0
      - PGID=0
    ports:
      - 32660:8000

@LilPeen
Copy link

LilPeen commented Jun 26, 2023

I too tried installing this recently and also can't access.. even though I got the proper hash or atleast the one generated by the command.

I tried multiple times, but no change. FWIW here's my Settings and the error I'm getting.

version: "3.9"

services:
  ihatemoney:
    image: ihatemoney/ihatemoney:latest
    container_name: ihatemoney
    environment:
      - DEBUG=False
      - ACTIVATE_ADMIN_DASHBOARD=True
      - ACTIVATE_DEMO_PROJECT=False
      - ADMIN_PASSWORD=pbkdf2:sha256:260000$jk0qpL7E8i35MrNM$f2ac9f48fa356c44fef95639c3cac588df0eaf455d29753a827f8df74814a709
      - ALLOW_PUBLIC_PROJECT_CREATION=False
      - BABEL_DEFAULT_TIMEZONE=america/new_york
      - GREENLET_TEST_CPP=no
      - MAIL_DEFAULT_SENDER=
      - MAIL_PASSWORD=
      - MAIL_PORT=
      - MAIL_SERVER=
      - MAIL_USE_SSL=True
      - MAIL_USE_TLS=False
      - MAIL_USERNAME=
      - SECRET_KEY=pingadulce
      - SESSION_COOKIE_SECURE=True
      - SHOW_ADMIN_EMAIL=True
      - SQLALCHEMY_DATABASE_URI=sqlite:////database/ihatemoney.db
      - SQLALCHEMY_TRACK_MODIFICATIONS=False
      - ENABLE_CAPTCHA=False
      - LEGAL_LINK=
      - PORT=8000
      - PUID=0
      - PGID=0
    networks:
      - nginx_default
    ports:
      - "8003:8000"
networks:
  nginx_default:
    external: true

and getting this:

WARN[0000] The "jk0qpL7E8i35MrNM" variable is not set. Defaulting to a blank string. 
WARN[0000] The "f2ac9f48fa356c44fef95639c3cac588df0eaf455d29753a827f8df74814a709" variable is not set. Defaulting to a blank string.

Which makes it seem like it's just ignoring everything after "$"

If any of this helps :D

@LilPeen
Copy link

LilPeen commented Jun 26, 2023

#334 (comment)

This fixed it... Might be worth adding this in documentation.. but sharing here for @AkshayRao27 @Chacsam

Made a separate post so if someone runs into my previous example. But I am now operational! Thanks!

@AkshayRao27
Copy link

I tried the fixes listed in #334

  • I removed all dollar signs from the Secret Key
  • I used the no-dollared secret key to generate a new hash
  • I double-dollared all of the dollar signs in the hash and redeployed

It still doesn't work for me. What might I be doing wrong?

@jonathan8devs
Copy link

The trick is to put the hash in '':
- ADMIN_PASSWORD='pbkdf2:sha256:260000$randomhash'

@Chacsam
Copy link
Author

Chacsam commented Jul 10, 2023

When putting the hash in '', the application crashes:

File "/etc/ihatemoney/ihatemoney.cfg", line 4

    ADMIN_PASSWORD = ''pbkdf2:sha256:260000$aK5qSyAdIa762UNO$xxxx''

SyntaxError: invalid decimal literal

[2023-07-10 14:35:54 +0000] [8] [INFO] Worker exiting (pid: 8)

[2023-07-10 14:35:54 +0000] [1] [INFO] Shutting down: Master

[2023-07-10 14:35:54 +0000] [1] [INFO] Reason: Worker failed to boot.```

@besendorf
Copy link

When putting the hash in '', the application crashes:

File "/etc/ihatemoney/ihatemoney.cfg", line 4

    ADMIN_PASSWORD = ''pbkdf2:sha256:260000$aK5qSyAdIa762UNO$xxxx''

SyntaxError: invalid decimal literal

[2023-07-10 14:35:54 +0000] [8] [INFO] Worker exiting (pid: 8)

[2023-07-10 14:35:54 +0000] [1] [INFO] Shutting down: Master

[2023-07-10 14:35:54 +0000] [1] [INFO] Reason: Worker failed to boot.```

Single ' not double

@zorun
Copy link
Collaborator

zorun commented Jul 13, 2023

So, quoting doesn't work, because it gets quoted again in Python.

But double dollars work fine, I have added some "documentation" about it here: #1183

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

Successfully merging a pull request may close this issue.

6 participants