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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication not working with a valid api_key #79

Open
AshutoshNirkhe opened this issue Jun 10, 2020 · 1 comment
Open

Authentication not working with a valid api_key #79

AshutoshNirkhe opened this issue Jun 10, 2020 · 1 comment

Comments

@AshutoshNirkhe
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

v0.12.24

Affected Resource(s)

Provider authentication using a valid api_key

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
provider "artifactory" {
  url   = "https://my-artifactory.domain.com/artifactory"
  api_key = var.admin_apikey    #valid API Key, because authentication works fine via curl -H 'X-JFrog-Art-Api:${api_key}'
}

Debug Output

Panic Output

Expected Behavior

Authntication through provider using api_key should have ben successful, just the way it works with REST API using header 'X-JFrog-Art-Api'
e.g -
curl -k -H "X-JFrog-Art-Api:${api_key}" https://localhost:443/artifactory/api/system/ping
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2 0 2 0 0 5 0 --:--:-- --:--:-- --:--:-- 5
OK

Actual Behavior

Error: GET https://my-artifactory.domain.com/artifactory/api/system/ping: 401 [{Status:401 Message:Bad credentials}]
on providers.tf line 1, in provider "artifactory":
1: provider "artifactory" {

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@AshutoshNirkhe
Copy link
Contributor Author

Ok so finally I could figure out what's going wrong here.
Actually the issue is not as such in provider schema logic, but because the way we our use case is. We are using (another) existing Artifactory for storing tf state file and have ARTIFACTORY_USERNAME and ARTIFACTORY_PASSWORD set in env of our calling CI code.
So in effect the Artifactory provider gets username and password from above 2 env variables (https://github.com/atlassian/terraform-provider-artifactory/blob/v2.0.0/pkg/artifactory/provider.go#L27 and line 34). And we are passing (a valid) api_key in provider too. Hence the conflict!!

So now I am passing ARTIFACTORY_USERNAME and ARTIFACTORY_PASSWORD explicitly during tf init with artifactory backend. And then making these variables empty before calling say terraform validate/plan/import/apply etc. This way provider gets only api_key and it stays happy without any conflicts.

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

No branches or pull requests

1 participant