Skip to content

Conversation

@kporter101
Copy link
Collaborator

@kporter101 kporter101 commented Jul 30, 2025

How to read this pull request

VAULT-38191
Jfrog is no longer going to support username/ API key auth for Artifactory. Instead, an identity token (no username) will be used. Previous work has been done to support identity token auth in this repo (#31 & #22). This PR updates tests to use the identity token when there is no Artifactory user provided.

Note: The Artifactory identity token was added as ARTIFACTORY_BEARER_TOKEN in GH Actions secrets

Checklist

  • The commit message includes an explanation of the changes
  • Manual validation of the changes have been performed (if possible)
  • New or modified code has requisite test coverage (if possible)
  • I have performed a self-review of the changes
  • I have made necessary changes and/or pull requests for documentation
  • I have written useful comments in the code
  • Version file/release label updated, if release needed

@kporter101 kporter101 marked this pull request as ready for review July 31, 2025 18:29
@kporter101 kporter101 requested a review from ryancragun July 31, 2025 18:30
Copy link
Collaborator

@ryancragun ryancragun left a comment

Choose a reason for hiding this comment

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

Looking good so far!

WithUsername(vars["username"]),
WithToken(vars["token"]),
)
if vars["username"] == "" {
Copy link
Collaborator

@ryancragun ryancragun Aug 1, 2025

Choose a reason for hiding this comment

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

You can probably simplify this a bit by creating a slice with the shared options, e.g.

opts := []Opt{
  WithHost("https://artifactory.hashicorp.engineering/artifactory"),
  WithToken(vars["token"]),
}
if vars["username"] != "" {
  opts = append(opts, WithUsername(vars["username"]))
}
client = NewClient(opts...)

@kporter101 kporter101 force-pushed the VAULT-38191/use-artifactory-token branch 2 times, most recently from 398aeaf to 3e45f5f Compare August 1, 2025 20:58
@kporter101 kporter101 force-pushed the VAULT-38191/use-artifactory-token branch 2 times, most recently from 62131fa to 6ce34cf Compare August 5, 2025 21:09
@kporter101 kporter101 force-pushed the VAULT-38191/use-artifactory-token branch 4 times, most recently from 70ec99d to 9ec16e9 Compare August 6, 2025 20:37
Copy link
Collaborator

@ryancragun ryancragun left a comment

Choose a reason for hiding this comment

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

Lets clean up the docs and perhaps bump VERSION and this is g2g!


- `artifactory` (Object, Sensitive) - `artifactory.username` (String) The Artifactory API username. This will likely be your hashicorp email address
- `artifactory.token` (String) The Artifactory API token. You can sign into Artifactory and generate one
- `artifactory.bearer_token` (String) The Artifactory Identity token - use instead of username/ API token. You can get a token by joining the
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is right? We reuse token here and don't have an attribute named bearer_token in the schema.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll want to remove to remove this change in resource_bundle_install and re-run the doc generator

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I dropped the commit that had these changes

// criteria.
//
//nolint:paralleltest// because our resource handles it
func TestAccDataSourceArtifacotoryItemProperties(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey now, fixing typos that are like 4 years old.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😎 🧹


cfg := template.Must(template.New("enos_data_artifactory_item").Parse(`data "enos_artifactory_item" "vault" {
{{if .Username.Value -}}
username = "{{ .Username.Value }}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorta surprised that this works. I would have expected us to require setting username to null when the value doesn't exist.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Description: docCaretToBacktick(`
- ^artifactory.username^ (String) The Artifactory API username. This will likely be your hashicorp email address
- ^artifactory.token^ (String) The Artifactory API token. You can sign into Artifactory and generate one
- ^artifactory.bearer_token^ (String) The Artifactory Identity token - use instead of username/ API token. You can get a token by joining the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we should yank this. We ended up reusing token to be either the API key or the bearer token and didn't add a new attribute.

@kporter101 kporter101 force-pushed the VAULT-38191/use-artifactory-token branch from 9ec16e9 to 7d21d06 Compare August 6, 2025 21:15
@kporter101 kporter101 force-pushed the VAULT-38191/use-artifactory-token branch from 7d21d06 to c89fb3e Compare August 6, 2025 21:21
- run: make test-acc
env:
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

are we using this anymore? or are we using both this and the bearer token?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right now we're supporting both auth options: username/token and just bearer token

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we remove the user and token and just use the bearer token before merge? That way we can delete the secrets and move on with our life?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! I removed them

@kporter101 kporter101 requested a review from ryancragun August 7, 2025 15:24
@kporter101 kporter101 merged commit c20c48e into main Aug 7, 2025
19 checks passed
@kporter101 kporter101 deleted the VAULT-38191/use-artifactory-token branch August 7, 2025 16:33
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.

4 participants