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

Fixes #37925 - translate local time properly for tokens #44

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

ianballou
Copy link
Member

Without setting the Sequel default_timezone, the time on tokens from Foreman do not get translated to the local time on the system. This means that the postgres CURRENT_TIMESTAMP uses a different timezone from the saved expiry times on tokens.

This PR sets default_timezone to :local so that the postgres CURRENT_TIMESTAMP and the times fetched from the DB have an agreeing timezone.

To test:

  1. On the smart proxy DB, change the timezone to GMT-2:
container_gateway=# alter database postgres set TIMEZONE TO 'Etc/GMT-2';
container_gateway=# alter database container_gateway set TIMEZONE TO 'Etc/GMT-2';
container_gateway=# set timezone to 'Etc/GMT-2';
  1. Also change the system time for good measure:
$ timedatectl set-timezone Etc/GMT-2
  1. Ensure you're logged out of the smart proxy container registry

  2. Log in to the smart proxy container registry

  3. See a login error about invalid username/password

  4. Patch in my PR, restart foreman-proxy, see that the issue is fixed

Copy link

@vsedmik vsedmik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the patch manually with GMT-2, GMT-12, GMT+12 and worked well in all cases:

[vsedmik@fedora broker]$ podman login --tls-verify=false -u admin -p changeme capsule.redhat.com
Login Succeeded!
[vsedmik@fedora broker]$ podman logout capsule.redhat.com
Removed login credentials for capsule.redhat.com

Without this patch I saw:

[vsedmik@fedora broker]$ podman login --tls-verify=false -u admin -p changeme capsule.redhat.com
Error: logging into "capsule.redhat.com": invalid username/password

Copy link
Member

@chris1984 chris1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine and Vlad tested

@ianballou ianballou merged commit a18d3c1 into Katello:main Dec 5, 2024
12 checks passed
@ianballou ianballou deleted the 37925-timezone-issue branch December 5, 2024 17:06
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 this pull request may close these issues.

3 participants