jenkinsci / azure-ad-plugin

Authentication and Authorization with Azure AD
https://plugins.jenkins.io/azure-ad/
MIT License
30 stars 59 forks source link

Jenkins node's offline message shows user_id instead of username #575

Closed TaerELahooti closed 4 days ago

TaerELahooti commented 5 months ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.440.3 OS: Linux - 3.10.0-514.el7.x86_64 Java: 17.0.10 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- Exclusion:0.15 JiraTestResultReporter:213.vccc8cf83e157 Matrix-sorter-plugin:1.3 Parameterized-Remote-Trigger:3.2.0 PrioritySorter:5.1.0 ace-editor:1.1 all-changes:1.5 analysis-model-api:12.3.3 ansicolor:1.0.4 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 apache-httpcomponents-client-5-api:5.3.1-1.0 artifactdeployer:1.3 asm-api:9.7-33.v4d23ef79fcc8 audit-trail:361.v82cde86c784e authentication-tokens:1.53.v1c90fd9191a_b_ aws-credentials:231.v08a_59f17d742 aws-java-sdk-ec2:1.12.671-445.ve02f9b_558f2e aws-java-sdk-minimal:1.12.671-445.ve02f9b_558f2e azure-ad:484.v5fd019a_39b_18 azure-commons:1.1.3 azure-sdk:157.v855da_0b_eb_dc2 badge:1.12 blueocean:1.27.12 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.27.12 blueocean-commons:1.27.12 blueocean-config:1.27.12 blueocean-core-js:1.27.12 blueocean-dashboard:1.27.12 blueocean-display-url:2.4.2 blueocean-events:1.27.12 blueocean-git-pipeline:1.27.12 blueocean-github-pipeline:1.27.12 blueocean-i18n:1.27.12 blueocean-jira:1.27.12 blueocean-jwt:1.27.12 blueocean-personalization:1.27.12 blueocean-pipeline-api-impl:1.27.12 blueocean-pipeline-editor:1.27.12 blueocean-pipeline-scm-api:1.27.12 blueocean-rest:1.27.12 blueocean-rest-impl:1.27.12 blueocean-web:1.27.12 bootstrap5-api:5.3.3-1 bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9 branch-api:2.1163.va_f1064e4a_a_f3 build-alias-setter:44.vb_f626d6f2734 build-keeper-plugin:19.va_df8a_2c65123 build-metrics:1.3 build-monitor-plugin:1.14-876.v2162064db_a_93 build-name-setter:2.4.2 build-pipeline-plugin:2.0.1 build-timeout:1.32 build-view-column:0.3 buildgraph-view:1.8 buildresult-trigger:0.18 built-on-column:1.4 bulk-builder:1.5 caffeine-api:3.1.8-133.v17b_1ff2e0599 categorized-view:1.13 checks-api:2.2.0 claim:543.v0061de6b_dcb_d cloudbees-bitbucket-branch-source:883.v041fa_695e9c2 cloudbees-disk-usage-simple:203.v3f46a_7462b_1a_ cloudbees-folder:6.901.vb_4c7a_da_75da_3 cmakebuilder:4.1.1 collapsing-console-sections:1.9.0 command-launcher:107.v773860566e2e commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.11.0-109.vfe16c66636eb_ compact-columns:1.185.vf3851b_4d31fe compress-buildlog:1.2 conditional-buildstep:1.4.3 configure-job-column-plugin:84.v792c9269f95a console-column-plugin:252.v0b_8fa_0e33b_72 copy-project-link:106.veb_028794a_844 copyartifact:722.v0662a_9b_e22a_c cppcheck:1.26 credentials:1337.v60b_d7b_c7b_c9f credentials-binding:677.vdc9d38cb_254d custom-job-icon:0.2 cvs:2.19.1 dashboard-view:2.508.va_74654f026d1 data-tables-api:2.0.5-1 description-column-plugin:1.3 display-url-api:2.204.vf6fddd8a_8b_e9 docker-commons:439.va_3cb_0a_6a_fb_29 docker-workflow:572.v950f58993843 downstream-buildview:69.v16da_b_2c36f6c downstream-ext:73.vdda_16e6eb_0da doxygen:178.v6ea_ef5f7dfdb dtkit-api:3.0.2 durable-task:555.v6802fe0f0b_82 echarts-api:5.5.0-1 email-ext:1814.v404722f34263 envinject:2.908.v66a_774b_31d93 envinject-api:1.199.v3ce31253ed13 exclusive-execution:0.8 extended-read-permission:53.v6499940139e5 external-monitor-job:215.v2e88e894db_f8 extra-columns:1.26 favorite:2.208.v91d65b_7792a_c file-leak-detector:1.13 flexible-publish:0.16.1 font-awesome-api:6.5.1-3 forensics-api:2.4.0 ftppublisher:1.2 git:5.2.2 git-client:4.7.0 github:1.39.0 github-api:1.318-461.v7a_c09c9fa_d63 github-branch-source:1789.v5b_0c0cea_18c3 global-build-stats:293.vd7b_d6e361475 greenballs:1.15.1 groovy:457.v99900cb_85593 groovy-label-assignment:1.2.0 groovy-postbuild:228.vcdb_cf7265066 groovyaxis:0.3 gson-api:2.10.1-15.v0d99f670e0a_7 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-30.v7e777411b_148 heavy-job:1.1 housekeeper:1.1 htmlpublisher:1.33 http_request:1.18 instance-identity:185.v303dc7c645f9 ionicons-api:74.v93d5eb_813d5f jackson2-api:2.17.0-379.v02de8ec9f64c jakarta-activation-api:2.1.3-1 jakarta-mail-api:2.1.3-1 javadoc:243.vb_b_503b_b_45537 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:73.vddf737284550 jenkins-design-language:1.27.12 jenkins-jira-issue-updater:1.18 jersey2-api:2.42-147.va_28a_44603b_d5 jira:3.13 jjwt-api:0.11.5-112.ve82dfb_224b_a_d jnr-posix-api:3.1.19-2 job-dsl:1.87 job-exporter:0.4 job-import-plugin:3.6 job-poll-action-plugin:1.0 joda-time-api:2.12.7-29.v5a_b_e3a_82269a_ jquery:1.12.4-1 jquery-detached:1.2.1 jquery-ui:1.0.2 jquery3-api:3.7.1-2 jsch:0.2.16-86.v42e010d9484b_ json-api:20240303-41.v94e11e6de726 json-path-api:2.9.0-58.v62e3e85b_a_655 junit:1265.v65b_14fa_f12f0 junit-attachments:205.vc0677977deb_0 ldap:725.v3cb_b_711b_1a_ef lockable-resources:1255.vf48745da_35d0 log-parser:2.3.3 logfilesizechecker:1.5 mailer:472.vf7c289a_4b_420 mapdb-api:1.0.9-40.v58107308b_7a_7 matrix-auth:3.2.2 matrix-combinations-parameter:1.3.3 matrix-project:822.824.v14451b_c0fd42 maven-plugin:3.23 measurement-plots:0.1 metadata:1.1.0b metrics:4.2.21-449.v6960d7c54c69 mina-sshd-api-common:2.12.1-101.v85b_e08b_780dd mina-sshd-api-core:2.12.1-101.v85b_e08b_780dd mixing-security-realm:1.3 momentjs:1.1.1 monitoring:1.98.0 msbuild:1.32 mstest:1.0.5 multi-slave-config-plugin:1.2.0 naginator:1.449.ve19751d70eb_0 nodelabelparameter:1.12.0 nodenamecolumn:1.2 nunit:485.ve8a_85357320d okhttp-api:4.11.0-172.vda_da_1feeb_c6e p4:1.15.1 pam-auth:1.10 parameterized-trigger:806.vf6fff3e28c3e periodicbackup:2.0 pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-graph-analysis:216.vfd8b_ece330ca_ pipeline-graph-view:243.vc9e11fec486a_ pipeline-groovy-lib:710.v4b_94b_077a_808 pipeline-input-step:495.ve9c153f6067b_ pipeline-milestone-step:119.vdfdc43fc3b_9a_ pipeline-model-api:2.2198.v41dd8ef6dd56 pipeline-model-definition:2.2198.v41dd8ef6dd56 pipeline-model-extensions:2.2198.v41dd8ef6dd56 pipeline-rest-api:2.34 pipeline-stage-step:312.v8cd10304c27a_ pipeline-stage-tags-metadata:2.2198.v41dd8ef6dd56 pipeline-stage-view:2.34 pipeline-utility-steps:2.16.2 plain-credentials:182.v468b_97b_9dcb_8 plot:2.1.12 plugin-util-api:4.1.0 popper-api:1.16.1-3 popper2-api:2.11.6-4 postbuild-task:1.9 postbuildscript:3.2.0-550.v88192b_d3e922 preSCMbuildstep:71.v1f2990a_37e27 prereq-buildstep:1.1 prism-api:1.29.0-13 progress-bar-column-plugin:11.vdef198c2d6c1 project-stats-plugin:23.v47fee1f77b_84 promoted-builds:945.v597f5c6a_d3fd publish-over:0.22 publish-over-cifs:0.16 publish-over-ftp:1.17 publish-over-ssh:1.25 pubsub-light:1.18 pwauth:0.4 rebuild:332.va_1ee476d8f6d remote-terminal-access:1.6 role-strategy:727.vd344b_eec783d run-condition:1.7 run-condition-extras:0.3 saferestart:0.7 scm-api:690.vfc8b_54395023 scoring-load-balancer:87.v921a_1235db_51 script-security:1336.vf33a_a_9863911 snakeyaml-api:2.2-111.vc6598e30cc65 sse-gateway:1.26 ssh:2.6.1 ssh-credentials:337.v395d2403ccd4 ssh-slaves:2.948.vb_8050d697fec sshd:3.322.v159e91f6a_550 strict-crumb-issuer:2.1.1 structs:337.v1b_04ea_4df7c8 subversion:1256.vee91953217b_6 template-project:1.5.2 template-workflows:41.v32d86a_313b_4a terminal:1.4 test-results-analyzer:0.4.1 test-stability:2.3 testlink:3.16 thinBackup:1.19 throttle-concurrents:2.14 timestamper:1.27 token-macro:400.v35420b_922dcb_ translation:1.16 trilead-api:2.142.v748523a_76693 valgrind:0.28 variant:60.v7290fc0eb_b_cd versioncolumn:243.vda_c20eea_a_8a_f versionnumber:1.11 view-job-filters:369.ve0513a_a_f5524 warnings-ng:11.3.0 windows-slaves:1.8.1 workflow-aggregator:596.v8c21c963d92d workflow-api:1311.v4250456a_e552 workflow-basic-steps:1058.vcb_fc1e3a_21a_9 workflow-cps:3894.3896.vca_2c931e7935 workflow-durable-task-step:1353.v1891a_b_01da_18 workflow-job:1400.v7fd111b_ec82f workflow-multibranch:773.vc4fe1378f1d5 workflow-remote-loader:1.6 workflow-scm-step:427.v4ca_6512e7df1 workflow-step-api:657.v03b_e8115821b_ workflow-support:907.v6713a_ed8a_573 xunit:3.1.4 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Windows 10, Windows 11

Reproduction steps

Step 1: On any node's page, click on "Mark this node temporarily offline" Step 2: Add optional message

Expected Results

Jun 8, 2024, 3:08:47 PM Disconnected by first_name.last_name@company.com : Test

Actual Results

Jun 8, 2024, 3:08:47 PM Disconnected by : Test

Anything else?

No response

Are you interested in contributing a fix?

No response

timja commented 5 months ago

Doesn't really look like there's anything that can be done in the Azure AD plugin.

Jenkins core should be changed to use either the display name or to load the user from the security realm and link to it.

TaerELahooti commented 5 months ago

Hi Tim,

Could you please share some reference/guide for steps required to do this? It will be really helpful.

Regards

timja commented 5 months ago

The code is here: https://github.com/jenkinsci/jenkins/blob/40663588eea4ac953209bd8845b6b880792f92cc/core/src/main/java/hudson/slaves/OfflineCause.java#L147

User has a getDisplayName method: https://github.com/jenkinsci/jenkins/blob/3c042d12b836e21c8e566294f168faa29d9d8d95/core/src/main/java/hudson/model/User.java#L689

Contribution guide for Jenkins core: https://github.com/jenkinsci/jenkins/blob/40663588eea4ac953209bd8845b6b880792f92cc/CONTRIBUTING.md

TaerELahooti commented 5 months ago

Many thanks Tim. I'll give this a try. I am not familiar with the issue flow on GitHub. As this is not an Azure AD plugin issue, how do we close this?

timja commented 5 months ago

Best way would be to report it against Jenkins core, see https://www.jenkins.io/participate/report-issue/#reporting-an-issue-on-jira

then click one of

image

on this issue

haresahani commented 4 days ago

Hi @timja,

I hope you're doing well. I'm new here, and I appreciate you providing the code and method to help resolve the issue. However, I noticed that the code you shared is from the Jenkins repository, while the issue I'm facing is related to the azure-ad-plugin repository.

Since these are two different repositories, I find it a bit difficult to fully understand how the provided solution applies to the Azure AD plugin specifically. Could you please clarify how I can integrate or adapt this code to the azure-ad-plugin? Any guidance would be greatly appreciated.

timja commented 4 days ago

The plugin uses extensions from Jenkins core, Jenkins core needs to make the change here so that this bug can be fixed

haresahani commented 4 days ago

Hi @timja Thank you for clarifying that this change needs to happen in Jenkins core. Since the fix involves Jenkins core rather than just the azure-ad-plugin, would it be possible to guide me on where or how to start contributing to Jenkins core to address this?

Also, is there a related issue in Jenkins core that I could track or contribute to, or should I consider opening one specifically for this bug?

Thanks again for your help!

KalleOlaviNiemitalo commented 4 days ago

This has been filed as JENKINS-73286 for the Jenkins core, and could now be closed here.

timja commented 4 days ago

Makes sense, thanks