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

feat: Rotate token with JWT token validation #17

Merged
merged 4 commits into from
Nov 29, 2022

Conversation

TJM
Copy link
Contributor

@TJM TJM commented Jun 13, 2022

Rotate Artifactory admin token so that only vault knows the token.

Supersedes #16
Closes #14

@TJM TJM changed the title Draft: rotate token with JWT token validation feat: Rotate token with JWT token validation Jun 14, 2022
This was referenced Jun 15, 2022

// Create admin role for the new token
role := &artifactoryRole{
Username: "admin",
Copy link
Contributor

Choose a reason for hiding this comment

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

what if configured user is not called admin?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @EvertonSA. We should be able to parse the sub from the claims and re-use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, Maybe it was only certain version of Artifactory that were sensitive to this, but I am pretty sure we had problems when we used anything but "admin" ... I would love to see something like vault or whatever here. Lets test this a few different ways hard-coded before changing the code to use the sub. I vaguely recall removing all that stuff and putting it back to "admin" ... but that was 5 months ago :)

Copy link
Member

@alexhung alexhung Nov 23, 2022

Choose a reason for hiding this comment

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

For access token, username needs to be a valid user account in the system. admin is a built-in user account so it will always work. For other value, it needs to match an existing user account. So if your system doesn't have 'vault' user account then it will fail.

Copy link
Contributor Author

@TJM TJM Nov 28, 2022

Choose a reason for hiding this comment

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

Has anyone had time to test this? (US has been in holiday)

EDIT: According to this project's own README.md, you have to use "admin" as the username. Has this changed?

Copy link
Member

Choose a reason for hiding this comment

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

No change. So I think we are good for now. In future, we should accommodate any username .

Copy link
Member

@alexhung alexhung left a comment

Choose a reason for hiding this comment

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

See comments.

I have not verify this in a local dev environment. I may do that once the PR is in the state ready to be merged.

I also notice this PR is still in 'Draft' state. Is this intentional?

artifactory.go Show resolved Hide resolved
artifactory.go Outdated Show resolved Hide resolved
artifactory.go Show resolved Hide resolved
path_config_rotate.go Show resolved Hide resolved
path_config_rotate.go Show resolved Hide resolved
artifactory.go Show resolved Hide resolved

// Create admin role for the new token
role := &artifactoryRole{
Username: "admin",
Copy link
Member

Choose a reason for hiding this comment

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

I agree with @EvertonSA. We should be able to parse the sub from the claims and re-use it?

artifactory_test.go Show resolved Hide resolved
@TJM
Copy link
Contributor Author

TJM commented Nov 23, 2022

See comments.

I have not verify this in a local dev environment. I may do that once the PR is in the state ready to be merged.

I also notice this PR is still in 'Draft' state. Is this intentional?

I wrote this code like 5 months ago, and was hoping for some feedback ;) That is why it is in draft state :)

- added more detail to the 7.21.1 comment
- uncommented error log incase of failed rootCert retreival
@TJM TJM marked this pull request as ready for review November 23, 2022 19:16
Copy link
Member

@alexhung alexhung left a comment

Choose a reason for hiding this comment

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

Also fixed a few formatting issues
@TJM
Copy link
Contributor Author

TJM commented Nov 28, 2022

Should this section in README.md be removed? https://github.com/jfrog/artifactory-secrets-plugin/blob/master/README.md?plain=1#L22

Updated README.md to remove that section, add a new part to show the /artifactory/config/rotate, and a few minor formatting things that VSCode (Markdown Lint) deemed necessary :)

Copy link
Member

@alexhung alexhung left a comment

Choose a reason for hiding this comment

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

I feel this looks good now.

@shrajfr12 and @mritunjaykumar Please review as well.

Copy link

@shrajfr12 shrajfr12 left a comment

Choose a reason for hiding this comment

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

LGTM

@EvertonSA
Copy link
Contributor

thanks for merging colleagues, I will test and also provide feedbacks

@EvertonSA
Copy link
Contributor

tested exactly like described and it works fine!

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.

Rotate Admin Token
4 participants