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

Adding credentials should not require a check on CredentialsStore#isDomainsModifiable #557

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

Dohbedoh
Copy link
Contributor

@Dohbedoh Dohbedoh commented Sep 9, 2024

Fix a regression caused by #481. Since this PR, store implementation that define methods to manage credentials but not to manage domains cannot use the Add button anymore... This is the case for CloudBees implementation for Cyberark / Hashicorp Vault for example.

It fails with a 400 and the "Domain is read-only" error on screen. Before this PR, the method was adding credentials properly and send return 400. Since this PR, it is returning early with the error.

Trying to make sense of this condition, I think it is is wrong. Per the javadoc for CredentialsStore#isDomainsModifiable(), it return if the store supports making changes to the list of domains or whether it only supports a fixed set of domains (which may only be one domain). This is about altering Domains. This method does not update or create a domain in any way, it simply add credentials to a selected domain. If the domain selected does not exist it fails with Store does not have selected domain. Also if the domain is not modifiable, you would not be able to select it in the dropdown:\

credentials-domain-add-credentials-broken

So per my understanding, this condition should be removed.

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@Dohbedoh Dohbedoh requested a review from a team as a code owner September 9, 2024 00:39
@Dohbedoh Dohbedoh changed the title Adding credentials should not require not require a check on CredentaalsStore#isDomainsModifiable Adding credentials should not require a check on CredentialsStore#isDomainsModifiable Sep 9, 2024
@Dohbedoh Dohbedoh force-pushed the bugfix/addCredentials branch from 1ed70d3 to 8dc8ff6 Compare September 9, 2024 01:51
@rsandell
Copy link
Member

rsandell commented Sep 9, 2024

Well this check has been there since before version 2.0 (2016) so what has changed now to cause problems? The check looks very explicit to me.

@rsandell
Copy link
Member

rsandell commented Sep 9, 2024

And it looks kinda correct to me that if a domain isn't modifiable you shouldn't be able to add any credentials to it. For example you can't add an object to an unmodifiable list.

@dwnusbaum
Copy link
Member

@rsandell FWIW, separately (BEE-51772), Allan claimed that while present, the check in the old code was not functional, and #481 changed that behavior:

Before that change, the 400 was already happening but silent. Now the credentials is not created anymore..

@Dohbedoh
Copy link
Contributor Author

Well this check has been there since before version 2.0 (2016) so what has changed now to cause problems? The check looks very explicit to me.

Since the change from , we return early within the condition:

Before that change, the HTTP 400 response was generated but we did not return so the rest of the method got executed as well:

And it looks kinda correct to me that if a domain isn't modifiable you shouldn't be able to add any credentials to it.

Seems to me that this condition was not effective all along..

And it looks kinda correct to me that if a domain isn't modifiable you shouldn't be able to add any credentials to it. For example you can't add an object to an unmodifiable list.

My understanding of the javadoc from this method and the usage of that method is that when a CredentialsStore is "domain-unmodifiable", you simply cannot create/delete/modify domains. But you can manage credentials within the read only domain(s). The workaround for that regression for example, is to add credentials from Manage Jenkins > Credentials for root credentials or Folder's Credentials page for folder credentials.

@car-roll
Copy link
Contributor

I've been going back and forth on this. At first my "feeling" was that if a domain is used to categorize credentials, and we are setting that domain to unmodifiable, my expectation is that I should not be adding additional credentials to that domain. But like Alan said, the javadoc says something entirely different:
Identifies whether this CredentialsStore supports making changes to the **list of domains** or whether it only supports **a fixed set of domains** (which may only be one domain).

It may have been misapplication of this particular check? I see there is a check if you can add a credential to a store, but really nothing else for domain.

@jeromepochat
Copy link
Contributor

This PR is currently empty of change. Is that expected? The initial changes 8dc8ff6 are reverted by merge commit b933fee

@Dohbedoh Dohbedoh force-pushed the bugfix/addCredentials branch from b933fee to 19a767e Compare October 11, 2024 06:57
@Dohbedoh Dohbedoh force-pushed the bugfix/addCredentials branch from 19a767e to 86ddfc9 Compare October 11, 2024 06:58
@olamy olamy added the bug label Oct 11, 2024
@jeromepochat jeromepochat merged commit d7abf5f into jenkinsci:master Oct 11, 2024
18 checks passed
@Dohbedoh Dohbedoh deleted the bugfix/addCredentials branch October 22, 2024 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants