bitwarden / server

Bitwarden infrastructure/backend (API, database, Docker, etc).
https://bitwarden.com
Other
15.59k stars 1.32k forks source link

"New login" mail has wrong timezone #494

Open fbermel opened 5 years ago

fbermel commented 5 years ago

Hi,

Everytime I log into bitwarden (on-premise) from a new device I get an email saying that the new login happened but the timestamp in the email is UTC and not UTC+2 as my timezone.

I have setup the docker containers (adding TZ env variable and an entrypoint wrapper script for mssql container because the ubuntu 16.04 in the container is missing tzdata package) so they all are showing the correct time when I execute docker run -it containername date and I've also checked that mssql's GETDATE() is showing the correct date.

What exactly is handling the time in these emails and needs to be adjusted?

kspearrin commented 5 years ago

This is not currently adjustable. All timestamps will remain in UTC regardless of what you set the local time of the server to. We can look into adding a setting for this, however.

fbermel commented 5 years ago

Thanks for your reply. I think such a setting would be pretty useful.

It would be also very helpful to have a global setting to set the timezone for all containers. Maybe I've just not found where this can be set globally, yet but at the moment I'm providing the TZ environment varaible in docker-compose.override.yml to all the containers.

The container bitwarden-mssql is running on Ubuntu 16.04 and is missing the package tzdata which is needed to set the timezone. So I'm also providing DEBIAN_FRONTEND: "noninteractive" to make the installation of tzdata package non-interactive. I'm then adding a shell script to the container and replace the entrypoint with this script.

mssql:
    volumes:
      - "./timezone.sh:/timezone.sh"
    environment:
      TZ: "Europe/Berlin"
      DEBIAN_FRONTEND: "noninteractive"
    entrypoint: /timezone.sh

timezone.sh

#!/bin/sh

apt-get update && apt-get install -y tzdata
rm /etc/localtime
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
apt-get clean

/entrypoint.sh

Is there a way to do this more easily? Having the correct timezone on all containers would be pretty important to have correct timestamps in the log files.

ghaisasadvait commented 4 years ago

Has this option been added yet?

Mart124 commented 4 years ago

The container bitwarden-mssql is running on Ubuntu 16.04 and is missing the package tzdata

All containers now have tzdata installed (see #606) so that you can set your own timezone thanks to the TZ environment variable.

ghaisasadvait commented 4 years ago

Thank you for replying! I have set the correct timezone on my ubuntu server 18 as well as am running the tzdata package.It is still not working. Can you please guide me as to how to set it?

Mart124 commented 4 years ago

Log into your containers and run the date command, you'll see the effect of setting TZ in bwdata/docker/docker-compose.override.yml. For example :

services:
  mssql:
    environment:
      - TZ=Europe/Berlin

However, as said above, mails will remain in UTC timezone. (you should be able to close #973)

ghaisasadvait commented 4 years ago

Oh so regardless of setting the timezone, the email will still be in UTC?

Mart124 commented 4 years ago

Yes. Proper timezone allows other things such as proper timestamps in logs, proper cron schedules etc...

ghaisasadvait commented 4 years ago

Oh I see. Thank you for your reply!

djsmith85 commented 2 years ago

Closing this as tzdata was added and @Mart124 has provided information on how to configure it.

fbermel commented 2 years ago

@djsmith85 Sure you can close this but the issue is not mainly about tzdata but about "New login mails" not having the correct timestamp and that it's not configurable. Since this seems to be still the case I wouldn't say that this issue is solved.

djsmith85 commented 2 years ago

@KnappeGEIL Thank you for your report. Based on your comment, I just checked the mail in question and indeed it is still not possible to configure/set the timezone. Re-opening..

bitwarden-bot commented 2 years ago

Hi @KnappeGEIL, We're cleaning up our repositories in preparation for a major reorganization. Issues from last year will be marked as stale and closed after two weeks. If you still need help, comment to let us know and we'll look into it. Thanks!

ghaisasadvait commented 2 years ago

The email are still not coming in the local/server timezone

shadowjig commented 2 months ago

Any update on this?

georglauterbach commented 1 month ago

@patrick-bitwarden I am currently facing a related issue: when self-hosting, the "Log In Via Device" functionality does not work because the server works with UTC while the client works with localtime. The result is that the client sees the result as "two hours old", because I am in CEST (UTC+2). Definitely a bug, if you ask me.