Bubka / 2FAuth

A Web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
https://docs.2fauth.app/
GNU Affero General Public License v3.0
2.26k stars 150 forks source link

Docker container cannot output log types and cannot enable the email sending function #383

Open fengluo2 opened 1 month ago

fengluo2 commented 1 month ago

Version

5.2.0

Details & Steps to reproduce

The image is from dockerhub, and there is no log of sending emails. Click test to send, and you can see from the log that the time is obviously slower than other requests, and it is being processed. The log level debug is specified, but the output log is still info. Docker env config:

APP_DEBUG="true"
APP_ENV="local"
APP_KEY="----"
APP_NAME="2FAuth"
APP_URL="----"
AUTHENTICATION_GUARD="web-guard"
AUTHENTICATION_LOG_RETENTION=365
AUTH_PROXY_HEADER_FOR_EMAIL=""
AUTH_PROXY_HEADER_FOR_USER=""
BROADCAST_DRIVER="log"
CACHE_DRIVER="file"
DB_DATABASE="/srv/database/database.sqlite"
GITHUB_CLIENT_ID=""
GITHUB_CLIENT_SECRET=""
HOST_IP="127.0.0.1"
IS_DEMO_APP="false"
LOGIN_THROTTLE=5
LOG_CHANNEL="daily"
LOG_LEVEL="debug"
MAIL_ENCRYPTION="ssl"
MAIL_FROM_ADDRESS="----@163.com"
MAIL_FROM_NAME="----"
MAIL_HOST="smtp.163.com"
MAIL_MAILER="smtp"
MAIL_PASSWORD="----"
MAIL_PORT=465
MAIL_USERNAME="----@163.com"
MAIL_VERIFY_SSL_PEER="true"
MEMORY_LIMIT=0
MIX_ENV="local"
OPENID_AUTHORIZE_URL=""
OPENID_CLIENT_ID=""
OPENID_CLIENT_SECRET=""
OPENID_TOKEN_URL=""
OPENID_USERINFO_URL=""
PROXY_FOR_OUTGOING_REQUESTS=""
PROXY_LOGOUT_URL=""
PUSHER_APP_CLUSTER="mt1"
PUSHER_APP_ID=""
PUSHER_APP_KEY=""
PUSHER_APP_SECRET=""
QUEUE_DRIVER="sync"
REDIS_HOST="redis"
REDIS_PORT=6379
SESSION_DRIVER="file"
SESSION_LIFETIME=120
SITE_OWNER="admin@localhost.com"
THROTTLE_API=60
TRUSTED_PROXIES=""
WEBAUTHN_ID=""
WEBAUTHN_NAME="2FAuth"
WEBAUTHN_USER_VERIFICATION="preferred"

Is it a problem with my configuration?

Expectation

I can specify the log level and send emails

Error & Logs

Running version 5.2.0 commit a707ad3 built on 2024-05-29T14:27:28Z
supervisord version: v0.6.8
PHP 8.2.19 (fpm-fcgi) (built: May  9 2024 19:31:11)
nginx version: nginx/1.24.0
DB_DATABASE sets with default path, we will use a symlink
Actual db file will be /2fauth/database.sqlite
/srv/database/database.sqlite is now a symlink to /2fauth/database.sqlite

   INFO  Clearing cached bootstrap files.  

  events ............................................................ 1ms DONE
  views ............................................................. 4ms DONE
  cache ............................................................. 2ms DONE
  route ............................................................. 0ms DONE
  config ............................................................ 0ms DONE
  compiled .......................................................... 0ms DONE

   INFO  Configuration cached successfully.  

   INFO  Routes cached successfully.  

   INFO  Blade templates cached successfully.  

time="2024-09-15T16:56:37Z" level=info msg="load configuration from file" file=/etc/supervisor/supervisord.conf
172.18.0.1 - - [15/Sep/2024:16:58:35 +0000] "GET /admin/app HTTP/1.1" 200 2848 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:38 +0000] "GET /admin/app HTTP/1.1" 200 2848 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:43 +0000] "GET /build/assets/app-BsP-5XS6.js HTTP/1.1" 200 292995 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:48 +0000] "GET /build/assets/app-DENUQqjX.css HTTP/1.1" 200 274743 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:50 +0000] "GET /api/v1/user HTTP/1.1" 200 714 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:51 +0000] "GET /manifest.json HTTP/1.1" 200 711 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:52 +0000] "GET /api/v1/twofaccounts HTTP/1.1" 200 12 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:53 +0000] "GET /build/assets/php_zh-DmpimvBD.js HTTP/1.1" 200 49617 "https://-----/build/assets/app-BsP-5XS6.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:55 +0000] "GET /api/v1/groups HTTP/1.1" 200 66 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:55 +0000] "GET /api/v1/settings HTTP/1.1" 200 334 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:56 +0000] "GET /favicon.png HTTP/1.1" 200 443 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:58:57 +0000] "GET /system/infos HTTP/1.1" 200 554 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:16:59:14 +0000] "POST /system/test-email HTTP/1.1" 200 27 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:04 +0000] "GET /admin/app HTTP/1.1" 200 2848 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:05 +0000] "GET /api/v1/user HTTP/1.1" 200 714 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:05 +0000] "GET /api/v1/twofaccounts HTTP/1.1" 200 12 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:06 +0000] "GET /api/v1/groups HTTP/1.1" 200 66 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:09 +0000] "GET /manifest.json HTTP/1.1" 200 711 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:11 +0000] "GET /api/v1/settings HTTP/1.1" 200 334 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:18 +0000] "GET /system/infos HTTP/1.1" 200 554 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
172.18.0.1 - - [15/Sep/2024:17:00:31 +0000] "POST /system/test-email HTTP/1.1" 200 27 "https://-----/admin/app" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"

Execution environment

Date: Mon, 16 Sep 2024 01:00:18 +0800 userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Version: 5.2.0 Environment: local Install path: / Debug: true Cache driver: file Log channel: daily Log level: DB driver: sqlite PHP version: 8.2.19 Operating system: Linux interface: fpm-fcgi Auth guard: web-guard webauthn user verification: preferred Trusted proxies: none lastRadarScan: 1970-01-01 00:00:00

Containerization

Additional information

No response

Bubka commented 1 month ago

Hi, What's the pb exactly? Email sending is not working at all? Or it's the log level that does not behave as expected?

FYI, a successful test email sending only logs one line: Notification of type TestEmailSettingNotification sent via channel [channelName] to user ID #[userid] (with log level info)

The log level debug is specified, but the output log is still info

I'm afraid you've misunderstood how the log system works. The LOG_LEVEL specified in your .env configuration determines which log lines are written to the logs: Each log line is defined with a log level in the application codebase. The LOG_LEVEL env var tells the app the minimum level to log.

For example, if you set LOG_LEVEL=debug, all possible log lines will be written to the log channel as debug is the lower level. In short, it tells the app "Hey, log everything, from debug lines to emergency lines" But if you set LOG_LEVEL=info, only informational log lines and higher will be written to the log channel.

You can find all log levels with the severity order here: https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1

fengluo2 commented 1 month ago

yes,so setting LOG_LEVEL=debug,but not having email notification log. @Bubka

Bubka commented 1 month ago

hum, I don't think ssl is a valid value for MAIL_ENCRYPTION. Try tls instead.

fengluo2 commented 1 month ago

Nothing happened...I'll try Google Mail