latenighttales / alcali

Featureful Saltstack GUI
https://alcali.dev
MIT License
356 stars 61 forks source link

superuser cannot login #282

Closed VietTPham closed 3 years ago

VietTPham commented 3 years ago

Describe the bug I had my server working with alcali a few week back, and decided to rebuild it from my own saltstack config. This was install using source. ran alcali migrate then alcali createsuperuser to create my user, but I cannot login with new user.

Tested that the salt-api with https works using pam auth. Tested that alcali has access to salt database.

alcali check pass both db and env To Reproduce my /etc/salt/master config

pki_dir: /etc/salt/pki/master
autosign_grains_dir: /etc/salt/autosign_grains
file_roots:
  base:
    - /srv/salt
hash_type: sha512
pillar_roots:
  base:
    - /srv/pillar
rest_cherrypy:
  port: 8080
  host: 0.0.0.0
  debug: True
  ssl_crt: /etc/pki/tls/certs/localhost.crt
  ssl_key: /etc/pki/tls/certs/localhost.key
external_auth:
  pam:
    my_username:
    - .*
  rest:
    ^url: http://127.0.0.1:8000/api/token/verify/
    my_username:
      - .*
      - '@runner'
      - '@wheel'
event_return: mysql
master_job_cache: mysql
mysql.host: 'localhost'
mysql.user: 'salt'
mysql.pass: 'salt'
mysql.db: 'salt'
mysql.port: 3306

/opt/alcali/.env

DB_NAME=salt
DB_USER=alcali
DB_PASS=alcali
DB_HOST=127.0.0.1
DB_PORT=3306
SECRET_KEY=changeme
ALLOWED_HOSTS=*
MASTER_MINION_ID={{grains['id']}}
SALT_URL=https://127.0.0.1:8080
SALT_AUTH=rest

Expected behavior User should be able to login

Desktop (please complete the following information):

Additional context I am on ubuntu 18.04 with salt 3002.2

VietTPham commented 3 years ago

I tested the alcali docker image and it works, so I know my salt-api and mysql are working properly. Tested with installing in virtualenv and using pypi to install, and still same error

got to test it with the alcali-formula, and got the same "Invalid Login / Password". My defaults.yaml from alcali-formula

---
alcali:
  deploy:
    repository: https://github.com/latenighttales/alcali.git
    branch: 3000.1
    user: alcali
    group: alcali
    directory: /opt/alcali
    service: alcali
    runtime: python3
  gunicorn:
    name: 'config.wsgi:application'
    host: '0.0.0.0'
    port: 8000
    workers: {{ grains['num_cpus'] }}
  # All the items under this section will be converted into an environment file.
  config:
    db_backend: mysql
    db_name: salt
    db_user: alcali
    db_pass: alcali
    db_host: 127.0.0.1
    db_port: 3306
    master_minion_id: salt-master
    secret_key: 'thisisnotagoodsecret.orisit?'
    allowed_hosts: '*'
    salt_url: 'https://127.0.0.1:8080'
    salt_auth: rest

my steps to create the superuser. I got the same warning on the mariadb when I ran in docker, so I assume it is ok.

alcali@salt-master:~/code$ ENV_PATH=/opt/alcali /opt/alcali/.venv/bin/python3 manage.py check
db:     ok
env:    ok
alcali@salt-master:~/code$ ENV_PATH=/opt/alcali /opt/alcali/.venv/bin/python3 manage.py migrate
System check identified some issues:

WARNINGS:
?: (mysql.W002) MariaDB Strict Mode is not set for database connection 'default'
        HINT: MariaDB's Strict Mode fixes many data integrity problems in MariaDB, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/3.1/ref/databases/#mysql-sql-mode
Operations to perform:
  Apply all migrations: admin, api, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying api.0001_initial... OK
  Applying api.0002_jobtemplate... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK
alcali@salt-master:~/code$ ENV_PATH=/opt/alcali /opt/alcali/.venv/bin/python3 manage.py createsuperuser
Username (leave blank to use 'alcali'): admin
Email address: p^H
Error: Enter a valid email address.
Email address:
Password:
Password (again):
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.
mattLLVW commented 3 years ago

probably related to #294 It's fixed on develop and i'll release a new version this weekend.

mattLLVW commented 3 years ago

new version published.