You could have multiple repositories configured in your Yum ".repo" file, or even have multiple .repo files each containing the same baseURL with different credentials.
An example .repo file would look like this:
[user1]
name=My Private Repo
baseurl=https://artifactory.com/artifactory/rpm-local/
enabled=1
gpgcheck=1
username=user1
password=password # Or ID Token #
[user2]
name=My Private Repo
baseurl=https://artifactory.com/artifactory/rpm-local/
enabled=1
gpgcheck=1
username=user2
password=password # Or ID Token #
YUM aggregates all repository configurations in all .repo files under /etc/yum.repos.d/.
All these repository configurations will be available to the YUM client. When you want to install an RPM package using a specific user’s credentials, you need to specify only the one relevant to that user, for example:
yum --disablerepo=”*” --enablerepo=”user2” install ant
Storing your Credentials Securely
If you're looking for a way to avoid saving your password to a global plaintext file, you can use a "netrc" file instead.
1) Create the file and secure its Linux permissions:
touch ~/.netrc
chmod 600 ~/.netrc
2) Add your credentials:
machine artifactory.com
login your-username
password your-password
3) Modify the .repo file to not contain any credentials:
[my-private-repo]
name=My Private Repo
baseurl=https://your.repo.server.com/path/to/repo/
enabled=1
gpgcheck=1
This doesn't work if you plan to swap users on the fly, but it will ensure the yum client uses a local file to use your user's credentials instead of a global root file.