User.CanonicalIdResolver extension point "context"

20 views
Skip to first unread message

Cristian Morales Vega

unread,
Dec 30, 2022, 8:17:53 AM12/30/22
to jenkin...@googlegroups.com
I am looking at https://issues.jenkins.io/browse/JENKINS-70342, but
I'm not sure how the "context" in CanonicalIdResolver is supposed to
be used. The only thing I have seen in the docs is "Can be used (for
example) to distinguish ambiguous committer ID using the SCM URL".

DefaultUserCanonicalIdResolver, User.FullNameIdResolver,
User.UserIDCanonicalIdResolver ignore it; and I have not seen it used
anywhere else, neither giving nor receiving a context. But I'm new
here, there is no easy way to see all the implementations of
CanonicalIdResolver in all the plugins, there is?

The use of "idOrFullName" in resolveCanonicalId() also feels a bit
overspecific? While you could call an email an "id", you could argue
the same about a full name. I may be missing something here.
Should the git plugin ask to resolve
- "Full Name <m...@email.com>"
- "Full Name" (this already works via User.FullNameIdResolver)
- "m...@email.com"
- Multiple of them, one after the other
?
Should it use any "context" to say "this is an email"? And if so,
there is any convention between different SCM plugins to say "email"?

Jesse Glick

unread,
Jan 3, 2023, 7:49:32 AM1/3/23
to jenkin...@googlegroups.com
On Fri, Dec 30, 2022 at 8:17 AM Cristian Morales Vega <cris...@samknows.com> wrote:
I am looking at https://issues.jenkins.io/browse/JENKINS-70342, but
I'm not sure how the "context" in CanonicalIdResolver is supposed to
be used. The only thing I have seen in the docs is "Can be used (for
example) to distinguish ambiguous committer ID using the SCM URL".

DefaultUserCanonicalIdResolver, User.FullNameIdResolver,
User.UserIDCanonicalIdResolver ignore it; and I have not seen it used
anywhere else, neither giving nor receiving a context. But I'm new
here, there is no easy way to see all the implementations of
CanonicalIdResolver in all the plugins, there is?

 
The use of "idOrFullName" in resolveCanonicalId() also feels a bit
overspecific? While you could call an email an "id", you could argue
the same about a full name.

Full name would be something like “First M. Last”. It is possible to pass this to `User.get` to look up a user by either id or full name. In practice we try to always use `getById`. The id might be something like `flast` or like `fl...@github.com` or something else, depending on the `SecurityRealm`.

The entire system of associating “ids”, full names, and email addresses with both `SecurityRealm` authentications and SCM commit “authors” in Jenkins is a complicated mess I am afraid.

Cristian Morales Vega

unread,
Jan 5, 2023, 9:17:07 AM1/5/23
to jenkin...@googlegroups.com
On Tue, 3 Jan 2023 at 12:49, 'Jesse Glick' via Jenkins Developers
<jenkin...@googlegroups.com> wrote:
>
> On Fri, Dec 30, 2022 at 8:17 AM Cristian Morales Vega <cris...@samknows.com> wrote:
>>
>> I am looking at https://issues.jenkins.io/browse/JENKINS-70342, but
>> I'm not sure how the "context" in CanonicalIdResolver is supposed to
>> be used. The only thing I have seen in the docs is "Can be used (for
>> example) to distinguish ambiguous committer ID using the SCM URL".
>>
>> DefaultUserCanonicalIdResolver, User.FullNameIdResolver,
>> User.UserIDCanonicalIdResolver ignore it; and I have not seen it used
>> anywhere else, neither giving nor receiving a context. But I'm new
>> here, there is no easy way to see all the implementations of
>> CanonicalIdResolver in all the plugins, there is?
>
>
> https://github.com/jenkinsci/additional-identities-plugin/blob/f98f43fc8a2b1831779e48cb5355bf1295ce347f/src/main/java/com/cloudbees/jenkins/plugins/AdditionalIdentityResolver.java#L51-L62 seems to look for it. But it could only come from https://github.com/jenkinsci/jenkins/blob/9d961dcce5f9e6094d2b9bf38ae4a112a27df4d8/core/src/main/java/hudson/model/User.java#L509-L510 and I do not recall any code ever passing this argument to `User.get`. I suspect this aspect of the API was never really developed.

For my simple needs, the additional-identities-plugin actually solves
all my issues!


>> The use of "idOrFullName" in resolveCanonicalId() also feels a bit
>> overspecific? While you could call an email an "id", you could argue
>> the same about a full name.
>
>
> Full name would be something like “First M. Last”. It is possible to pass this to `User.get` to look up a user by either id or full name. In practice we try to always use `getById`. The id might be something like `flast` or like `fl...@github.com` or something else, depending on the `SecurityRealm`.
>
> The entire system of associating “ids”, full names, and email addresses with both `SecurityRealm` authentications and SCM commit “authors” in Jenkins is a complicated mess I am afraid.

FWIW I have created https://issues.jenkins.io/browse/JENKINS-70382
Reply all
Reply to author
Forward
0 new messages