Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,15 @@ public static <C extends Credentials> List<C> lookupCredentialsInItem(@NonNull C
for (CredentialsProvider provider : all()) {
if (provider.isEnabled(item) && provider.isApplicable(type)) {
try {
for (C c: provider.getCredentialsInItem(type, item, authentication, domainRequirements)) {
List<C> credentials = provider.getCredentialsInItem(type, item, authentication, domainRequirements);
// also lookup credentials as SYSTEM if granted for this item
if (authentication != ACL.SYSTEM2
&& (item.getACL().hasPermission2(authentication, CredentialsProvider.USE_ITEM)
|| item.getACL().hasPermission2(authentication, CredentialsProvider.USE_OWN))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I think I expressed myself incorrectly.
With only the CredentialsProvider.USE_OWN permission, you should not be able to retrieve credentials with the SYSTEM authentication. But it should be needed to retrieve the current user's credentials (with the user's authentication).

Meaning that the previous call on line 563 should check for this permission, similar to what is done in this code.

credentials.addAll(provider.getCredentialsInItem(type, item, ACL.SYSTEM2, domainRequirements));
}

for (C c: credentials) {
if (!(c instanceof IdCredentials) || ids.add(((IdCredentials) c).getId())) {
// if IdCredentials, only add if we haven't added already
// if not IdCredentials, always add
Expand Down Expand Up @@ -633,9 +641,14 @@ public static <C extends IdCredentials> ListBoxModel listCredentialsInItem(@NonN
for (CredentialsProvider provider : all()) {
if (provider.isEnabled(item) && provider.isApplicable(type)) {
try {
for (ListBoxModel.Option option : provider.getCredentialIdsInItem(
type, item, authentication, domainRequirements, matcher == null ? CredentialsMatchers.always() : matcher)
) {
ListBoxModel credentialIds = provider.getCredentialIdsInItem(type, item, authentication, domainRequirements, matcher);
// also lookup credentials with scope SYSTEM when user has grants for this item
if (authentication != ACL.SYSTEM2
&& (item.getACL().hasPermission2(authentication, CredentialsProvider.USE_ITEM)
|| item.getACL().hasPermission2(authentication, CredentialsProvider.USE_OWN))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

credentialIds.addAll(provider.getCredentialIdsInItem(type, item, ACL.SYSTEM2, domainRequirements, matcher));
}
for (ListBoxModel.Option option : credentialIds) {
if (ids.add(option.value)) {
result.add(option);
}
Expand Down