-
Notifications
You must be signed in to change notification settings - Fork 107
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
Error: UNAUTHORIZED - Invalid token, audience #1135
Comments
@piotrminkina Very odd. The provider uses the same HTTP client for all resources so the authentication should be the same. We have not seen this issue in our acceptance tests. Can you verify this error still occurs when creating a new |
@alexhung No problems with a new resource. The problem is with the currently existing resource.
Above results for the following code and version 10.3.2 of Artifactory provider: resource "artifactory_user" "admin" {
name = "admin"
email = "[email protected]"
admin = true
disable_ui_access = false
}
resource "artifactory_user" "new_admin" {
name = "new_admin"
email = "[email protected]"
admin = true
disable_ui_access = false
} |
Strange problem. It also occurs when trying to create a resource of type
With the following access log entry:
In the previous configuration, I was using resource type
At this point, I decided to manually remove the LDAP configuration from the Artifactory admin panel. I removed the configuration for users and groups. I then ran |
@piotrminkina I think this may be related to the bug in the HTTP client we use. There's a patch out yesterday so I'll see if updating to the latest, patched version will resolve this issue. |
@piotrminkina I've just released v12.5.1. Let me know if you still experiencing this issue. |
@alexhung After updating the provider to version 12.5.1, unfortunately, the problem persists. I do not see any improvement in the results of the I did some digging in the TRACE logs from the Management of users and LDAP settings are done on the $ curl -H "Authorization: Bearer $(cat build/getAccessKey/token.txt)" http://10-0-4-1.artifactory-l.sslip.io/access/api/v2/users/admin
{
"errors" : [ {
"code" : "UNAUTHORIZED",
"message" : "Invalid token, audience"
} ]
}
$ curl -H "Authorization: Bearer $(cat build/getAccessKey/token.txt)" http://10-0-4-1.artifactory-l.sslip.io/artifactory/api/repositories/helm-release-local
{
"key" : "helm-release-local",
"packageType" : "helm",
[...]
} It seems that the problem is not the Artifactory Provider, but the way I get the token from Artifactory. So I changed the script blindly by adding curl -H "Authorization: Bearer $(cat build/getAccessKey/token.txt)" http://10-0-4-1.artifactory-l.sslip.io/access/api/v2/users/admin
{
"username" : "admin",
[...]
} I'll be honest, I didn't expect that when requesting an Artifactory access token, I have to provide two service names. Even the Web UI of Artifactory gives the option to select only one service from the list, that is, no Access service in the list: In any case, after generating the correct token
If a feature is deprecated, it should still be available, but prepared to be extinguished. Here, however, the process ends with an error. Is this behavior intentional? |
@piotrminkina This is not a recommended practice to use UI API. They are not public and thus there is no guarantees to be stable. If you wish to generate an access token using REST API, you should use the Access API: https://jfrog.com/help/r/jfrog-rest-apis/create-token This API allows you to generate access token with varying scopes and audiences. As for From your original message, it looks like you are upgrading from v6.20.2? If so, you may have missed/bypassed the deprecation period between May and September this year. Regardless, you will need to migrate your permission target resources to the new |
@alexhung I apologize for the confusion as it appeared that the problem is in my environment. Thank you for your time and good advice. Regards. |
Describe the bug
For unknown reasons, your provider is querying the API as anonymous. In my case this happens for a resource of type
artifactory_user
. Theterraform plan
command ends with this error for a single resource of typeartifactory_user
:In the artifactory access log, I see that the provider queried these resources as anonymous, which does not happen with other requests to the API.
This is an example configuration:
Above resources are a part of Terraform State previously managed in Artifactory 7.47.10 by Terraform 1.2.9 and Provider 6.20.2.
Expected behavior
Manage
artfactory_user
resources properly :)Additional context
The text was updated successfully, but these errors were encountered: