Problem: User cannot renew ‘Personal Access Tokens’
Expected outcome: Login and pull Docker images
Foreman and Proxy versions: Foreman 3.17.0 / Katello 4.19.0.1
Foreman and Proxy plugin versions:
Plugins:
- Name: foreman-tasks
Version: 11.0.6 - Name: foreman_ansible
Version: 17.0.2 - Name: foreman_puppet
Version: 9.1.0 - Name: foreman_remote_execution
Version: 16.3.1 - Name: foreman_webhooks
Version: 4.0.2 - Name: katello
Version: 4.19.0.1
Smart Proxies:
Features:
- Name: dynflow
Version: 0.9.4 - Name: ansible
Version: 3.6.1 - Name: pulpcore
Version: 3.4.0 - Name: script
Version: 0.11.7 - Name: shellhooks
Version: 0.9.3 - Name: tftp
Version: 3.17.0 - Name: dhcp
Version: 3.17.0 - Name: puppetca
Version: 3.17.0 - Name: puppet
Version: 3.17.0
10)Name: logs
Version: 3.17.0
Distribution and version: AlmaLinux release 9.7 (Moss Jungle Cat)
Podman binary and Podman Ansible collection version: podman version 5.6.0 / containers.podman 1.17.0
Other relevant data:
Hello everyone,
I am experiencing an intermittent issue with authentication against the Foreman/Katello container registry and I would like to know whether this is expected behaviour, a known issue, or a bug.
Use case
I have created a dedicated local Foreman user that is used exclusively by Ansible to authenticate against the container registry.
The Ansible playbook uses the following modules:
containers.podman.podman_login
containers.podman.podman_image
The user authenticates with a standard username and password (not with a Personal Access Token).
The assigned role only contains the following permissions:
| Resource | Permissions | Search |
|---|---|---|
| Content Views | view_content_views | N/A |
| Image | view_images | N/A |
| Personal access token | create_personal_access_tokens | N/A |
The authentication works correctly for some time. However, after a period of time (I have not been able to determine the exact interval), the following error starts occurring during podman login:
Unable to gather info for foreman.example.com:
Error: logging into “foreman.example.com”: invalid username/password
As a consequence, containers.podman.podman_image is also unable to pull images from the registry.
The username and password have not changed.
Initial workaround
Initially, the only workaround I found was:
Delete the Foreman user.
Recreate the user with the same username, password and role.
After recreating the user, authentication immediately starts working again.
Investigation
I inspected the user from the Rails console.
The user is authenticated using the internal authentication source:
u.auth_source
=> AuthSourceInternal
The user also has an automatically created Personal Access Token named registry:
u.personal_access_tokens
#<PersonalAccessToken
name: "registry"
expires_at: ...
revoked: false
>
This registry PAT was not created manually.
Additional information
Ansible tasks are run by a user without root privileges, as follows:
- name: "Create temporary authfile"
set_fact:
tmp_authfile: "/tmp/<%= rand_name %>-<%= deployment_name %>_auth.json"
- name: "Login to servidor:8443"
containers.podman.podman_login:
username: username
password: "{{ username_password }}"
registry: foreman.example.com
authfile: "{{ tmp_authfile }}"
I mention this in case it is relevant to the observed behaviour.
Any guidance or suggestions would be greatly appreciated.
Thank you in advance.