You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<1> There are different credential types that can be used to authenticate with the load balancer, this is the common base class.
300
-
<2> This is an immediate action performed by the user.
301
-
<3> In this case there may be multiple credentials available to the user, we only want the ones with `"lb.switch".equals(credential.getPermission())`.
302
-
Any credentials that do not have a `getPermission()` method will be excluded as well as any that do not have the corresponding return value.
303
-
304
284
* We want to let the user specify the credentials used to update the post commit receive hooks of a source control system for any corresponding jobs configured in Jenkins.
305
285
+
306
286
[NOTE]
@@ -379,24 +359,21 @@ If we have a job, "foobar", and we configure a credentials parameter on that job
379
359
380
360
If you are working outside the context of a `Run` then you will not have to deal with the complexities of credentials expressions.
381
361
382
-
In most cases the retrieval will just be a call to one of the `CredentialsProvider.lookupCredentialsInItem(...)`/`CredentialsProvider.lookupCredentialsInItemGroup(...)` wrapped within `CredentialsMatchers.firstOrNull(..., CredentialsMatchers.withId(...))`, for example:
362
+
In most cases the retrieval will just be a call to `CredentialsProvider.findCredentialByIdInItemGroup` or `CredentialsProvider.findCredentialByIdInItem`:
383
363
384
364
[source,java]
385
365
----
386
-
StandardCredentials c = CredentialsMatchers.firstOrNull(
387
-
CredentialsProvider.lookupCredentialsInItem(
366
+
StandardCredentials c = CredentialsProvider.findCredentialByIdInItem(
367
+
credentialsId,
388
368
StandardCredentials.class, // <1>
389
369
job, // <1>
390
370
job instanceof Queue.Task // <1>
391
371
? Tasks.getAuthenticationOf((Queue.Task)job))
392
372
: ACL.SYSTEM2,
393
373
URIRequirementBuilder.fromUri(...) // <1>
394
-
),
395
-
CredentialsMatchers.withId(credentialsId) // <2>
396
-
);
374
+
);
397
375
----
398
376
<1> These should be the same as your call to `CredentialsProvider.listCredentialsInItem(...)`/`CredentialsProvider.listCredentialsInItemGroup(...)`/`StandardListBoxModel.includeMatchingAs(...)` in order to ensure that we get the same credential instance back.
399
-
<2> If you had additional `CredentialsMatcher` expressions in your call to `CredentialsProvider.listCredentialsInItem(...)`/`CredentialsProvider.listCredentialsInItemGroup(...)`/`StandardListBoxModel.includeMatchingAs(...)` then you should merge them here with a `CredentialsMatchers.allOf(...)`
400
377
401
378
Once you have retrieved a non-null credentials instance, all non-secret properties can be assumed as eager-fetch immutable.
402
379
@@ -412,20 +389,18 @@ The recommended way to use a credential is through the https://plugins.jenkins.i
412
389
413
390
[source,java]
414
391
----
415
-
StandardCredentials c = CredentialsMatchers.firstOrNull( // <1>
416
-
CredentialsProvider.listCredentialsInItem(
392
+
StandardCredentials c = CredentialsProvider.findCredentialByIdInItem( // <1>
Copy file name to clipboardExpand all lines: docs/implementation.adoc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -576,7 +576,6 @@ The `CredentialsProvider` extension point is perhaps one of the more complicated
576
576
* Where the backing store is remote from Jenkins then:
577
577
578
578
** potentially has to be able to either instantiate `java.lang.reflect.Proxy` implementations for credentials, or create on-demand implementation classes using http://asm.ow2.org/[ASM] (or similar).
579
-
** potentially has to deal with parsing the `CredentialsMatcher` query language in order to minimize transfer of information over the network.
580
579
** may need to store Jenkins specific state in Jenkins in order to provide credentials domain support.
581
580
582
581
* Where the backing store is local to Jenkins but contextual to a specific Jenkins model object and not covered by the three existing credentials providers: System, User and Folder, then replication of that code will likely be required.
@@ -597,7 +596,6 @@ These existing examples are probably not good as reference examples as they have
597
596
+
598
597
A good reference implementation would be clean of such distractions.
599
598
* [ ] Provide links to some other implementations of credentials providers for other use cases.
600
-
* [ ] Provide some details on how the Credentials Query Language can be used to limit querying credentials from the remote service
601
599
602
600
====
603
601
@@ -698,6 +696,8 @@ Listing credentials operations are normally restricted to the population of cred
698
696
Such requests are AJAX requests, so we have the option to block without affecting the rest of the Jenkins UI.
699
697
700
698
Blocking for more than between 5 and 10 seconds, however, will cause user frustration, thus for this type of request we try to serve the response live and fall-back to the cache if the live response takes too long.
699
+
700
+
Runtime lookups of credentials is normally limited to loading a specific credential by id, so consider overriding the methods which take an id argument.
701
701
====
702
702
703
703
These different caching concerns are addresses at different points in the credentials API:
0 commit comments