jenkinsci / oic-auth-plugin

A Jenkins plugin which lets you login to Jenkins using your own, self-hosted or public openid connect server.
https://plugins.jenkins.io/oic-auth
MIT License
71 stars 94 forks source link

Redirect to non-existing page (404) after successful login if controller was lauched with `--prefix`. #302

Closed duemir closed 6 months ago

duemir commented 6 months ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.426.3.3 OS: Mac OS X - 14.4.1 Java: 11.0.13 - Azul Systems, Inc. (OpenJDK 64-Bit Server VM) --- JiraTestResultReporter:197.vb6bbe828c308 Office-365-Connector:4.20.2 ace-editor:1.1 analysis-model-api:11.15.0 ansible:307.va_1f3ef06575a_ ansible-tower:0.16.0 ansicolor:1.0.4 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 artifactory:4.0.5 async-http-client:1.7.24.3 audit-trail:361.v82cde86c784e authentication-tokens:1.53.v1c90fd9191a_b_ aws-credentials:218.v1b_e9466ec5da_ aws-java-sdk:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-cloudformation:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-codebuild:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-ec2:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-ecr:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-ecs:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-efs:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-elasticbeanstalk:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-iam:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-kinesis:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-logs:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-minimal:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-secretsmanager:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-sns:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-sqs:1.12.606-418.vce5b_4cd017c6 aws-java-sdk-ssm:1.12.606-418.vce5b_4cd017c6 azure-commons:1.1.3 badge:1.9.1 basic-branch-build-strategies:81.v05e333931c7d bitbucket:241.v6d24a_57f9359 bitbucket-oauth:0.13 bitbucket-pullrequest-builder:1.5.0 blueocean:1.27.9 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.27.9 blueocean-commons:1.27.9 blueocean-config:1.27.9 blueocean-core-js:1.27.9 blueocean-dashboard:1.27.9 blueocean-display-url:2.4.2 blueocean-events:1.27.9 blueocean-git-pipeline:1.27.9 blueocean-github-pipeline:1.27.9 blueocean-i18n:1.27.9 blueocean-jira:1.27.9 blueocean-jwt:1.27.9 blueocean-personalization:1.27.9 blueocean-pipeline-api-impl:1.27.9 blueocean-pipeline-editor:1.27.9 blueocean-pipeline-scm-api:1.27.9 blueocean-rest:1.27.9 blueocean-rest-impl:1.27.9 blueocean-web:1.27.9 bootstrap4-api:4.6.0-6 bootstrap5-api:5.3.2-3 bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9 branch-api:2.1135.v8de8e7899051 btc-embeddedplatform:23.3.1 build-blocker-plugin:1.7.9 build-monitor-plugin:1.14-826.vb_a_c11536174d build-name-setter:2.4.0 build-pipeline-plugin:2.0.1 build-timeout:1.32 build-timestamp:1.0.3 build-user-vars-plugin:1.9 build-view-column:0.3 build-with-parameters:76.v9382db_f78962 built-on-column:1.4 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.0.2 chucknorris:159.vdfe649cb_9c37 cloudbees-administrative-monitors:1.0.13 cloudbees-analytics:1.59 cloudbees-assurance:2.276.0.31 cloudbees-aws-cli:1.5.21 cloudbees-bitbucket-branch-source:848.850.v6a_a_2a_234a_c81 cloudbees-blueocean-default-theme:0.8 cloudbees-casc-client:2.38 cloudbees-casc-items-api:2.50 cloudbees-casc-items-commons:2.50 cloudbees-casc-items-controller:2.50 cloudbees-consolidated-build-view:1.7 cloudbees-disk-usage-simple:203.v3f46a_7462b_1a_ cloudbees-even-scheduler:3.14 cloudbees-folder:6.879.934.cb-v98a_156fcdd04 cloudbees-folders-plus:3.31 cloudbees-groovy-view:1.14 cloudbees-ha:4.44 cloudbees-inactive-items:0.11 cloudbees-jenkins-advisor:358.v58972d19b_1f0 cloudbees-jsync-archiver:5.25 cloudbees-label-throttling-plugin:3.9 cloudbees-license:9.79 cloudbees-long-running-build:1.21 cloudbees-monitoring:2.16 cloudbees-msteams:0.16 cloudbees-nodes-plus:1.25 cloudbees-pipeline-explorer:1.10.1 cloudbees-platform-common:1.26 cloudbees-platform-data:1.39 cloudbees-plugin-usage:2.20 cloudbees-quiet-start:1.9 cloudbees-request-filter:1.9 cloudbees-ssh-slaves:2.25 cloudbees-support:3.31 cloudbees-template:4.63 cloudbees-uc-data-api:4.57 cloudbees-unified-ui:1.30 cloudbees-view-creation-filter:1.9 cloudbees-workflow-template:3.24 cloudbees-workflow-ui:2.12 clover:4.14.2.596.vb_4d6475e990b_ cmakebuilder:4.1.1 cobertura:1.17 code-coverage-api:4.99.0 command-launcher:107.v773860566e2e commons-httpclient3-api:3.1-3 commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.11.0-95.v22a_d30ee5d36 conditional-buildstep:1.4.3 config-file-provider:959.vcff671a_4518b_ configuration-as-code:1737.v652ee9b_a_e0d9 copyartifact:722.v0662a_9b_e22a_c coverage:1.10.0 cppcheck:1.26 credentials:1311.vcf0a_900b_37c2 credentials-binding:642.v737c34dea_6c2 crowd2:4.1.0 cvs:2.19.1 dashboard-view:2.495.v07e81500c3f2 data-tables-api:1.13.8-2 declarative-pipeline-migration-assistant:1.6.2 declarative-pipeline-migration-assistant-api:1.6.2 deploy:1.16 deployed-on-column:1.9 deployer-framework:88.ve78a_92f39e8e display-url-api:2.200.vb_9327d658781 docker-build-publish:1.4.0 docker-commons:439.va_3cb_0a_6a_fb_29 docker-custom-build-environment:1.7.3 docker-workflow:572.v950f58993843 dockerhub-notification:2.7.1 dtkit-api:3.0.2 durable-task:543.v262f6a_803410 echarts-api:5.4.3-2 email-ext:2.103 embeddable-build-status:467.v4a_954796e45d envinject:2.908.v66a_774b_31d93 envinject-api:1.199.v3ce31253ed13 environment-dashboard:1.1.10 extended-choice-parameter:381.v360a_25ea_017c extended-read-permission:53.v6499940139e5 extensible-choice-parameter:1.8.1 favorite:2.4.3 font-awesome-api:6.5.1-1 forensics-api:2.3.0 gatling:1.3.0 generic-webhook-trigger:2.0.1 gerrit-trigger:2.39.3 git:5.2.1 git-changelog:3.38 git-client:4.6.0 git-forensics:2.0.0 git-parameter:0.9.19 git-server:99.101.v720e86326c09 git-validated-merge:3.36 gitbucket:0.8 github:1.37.3.1 github-api:1.318-461.v7a_c09c9fa_d63 github-branch-source:1758.v048414714f5d github-pull-request-build:1.16 google-oauth-plugin:1.330.vf5e86021cb_ec gradle:2.9 groovy:457.v99900cb_85593 groovy-postbuild:228.vcdb_cf7265066 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 hidden-parameter:237.v4b_df26c7a_f0e htmlpublisher:1.32.1 http_request:1.18 image-tag-parameter:2.0 infradna-backup:3.38.72 instance-identity:185.v303dc7c645f9 ionicons-api:56.v1b_1c8c49374e ivy:2.5 jackson2-api:2.16.1-373.ve709c6871598 jacoco:3.3.5 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 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.9 jenkins-multijob-plugin:625.v3a_1ef0311fe7 jersey2-api:2.41-133.va_03323b_a_1396 jira:3.13 jira-ext:114.v7b_8b_1d4274c6 jira-steps:2.0.165.v8846cf59f3db jira-trigger:1.0.3 jjwt-api:0.11.5-77.v646c772fddb_0 job-dsl:1.87 job-import-plugin:3.6 jobConfigHistory:1229.v3039470161a_d jobgenerator:1.22 joda-time-api:2.12.7-29.v5a_b_e3a_82269a_ jquery:1.12.4-1 jquery-detached:1.2.1 jquery3-api:3.7.1-1 jsch:0.2.16-86.v42e010d9484b_ junit:1252.vfc2e5efa_294f kubernetes:4151.v6fa_f0fb_0b_4c9 kubernetes-cd:2.3.1 kubernetes-ci:1.3 kubernetes-cli:1.12.1 kubernetes-client-api:6.8.1-224.vd388fca_4db_3b_ kubernetes-credentials:0.11 kubernetes-pipeline-aggregator:1.3 kubernetes-pipeline-devops-steps:1.6 kubernetes-pipeline-steps:1.3 ldap:711.vb_d1a_491714dc list-git-branches-parameter:0.0.13 lockable-resources:1245.vb_05f8a_4e28db_ log-parser:2.3.3 logstash:2.5.0218.v0a_ff8fefc12b_ m2release:0.16.4 mailer:463.vedf8358e006b_ mapdb-api:1.0.9-28.vf251ce40855d matlab:2.12.0 matrix-auth:3.2.1 matrix-project:822.824.v14451b_c0fd42 maven-plugin:3.23 mercurial:1260.vdfb_723cdcc81 metrics:4.2.18-442.v02e107157925 mina-sshd-api-common:2.11.0-86.v836f585d47fa_ mina-sshd-api-core:2.11.0-86.v836f585d47fa_ mina-sshd-api-scp:2.11.0-86.v836f585d47fa_ mina-sshd-api-sftp:2.11.0-86.v836f585d47fa_ mission-control-view:0.9.16 mock-security-realm:1.4 momentjs:1.1.1 naginator:1.436.vb_e769dcb_cdf6 nectar-license:8.42 nectar-rbac:5.88 nectar-vmware:4.3.9 node-iterator-api:55.v3b_77d4032326 nodelabelparameter:1.12.0 notification:1.17 nunit:465.v0324954b_2990 oauth-credentials:0.646.v02b_66dc03d2e oic-auth:4.223.v503b_9a_75a_8a_f okhttp-api:4.11.0-157.v6852a_a_fa_ec11 openid:2.4 openid4java:0.9.8.0 operations-center-agent:3.0.68 operations-center-analytics-config:2.222.0.1 operations-center-analytics-reporter:2.222.0.1 operations-center-client:3.0.68 operations-center-cloud:3.0.68 operations-center-context:3.0.68 pam-auth:1.10 parameter-separator:166.vd0120849b_386 parameterized-scheduler:262.v00f3d90585cc parameterized-trigger:787.v665fcf2a_830b_ parasoft-findings:10.7.1 persona:2.4 piketec-tpt:9.3 pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-github-lib:42.v0739460cda_c4 pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-groovy-lib:689.veec561a_dee13 pipeline-input-step:477.v339683a_8d55e pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2168.vf921b_4e72c73 pipeline-model-definition:2.2168.vf921b_4e72c73 pipeline-model-extensions:2.2168.vf921b_4e72c73 pipeline-multibranch-defaults:2.1 pipeline-rest-api:2.34 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2168.vf921b_4e72c73 pipeline-stage-view:2.34 pipeline-utility-steps:2.16.1 plain-credentials:143.v1b_df8b_d3b_e48 plot:2.1.12 plugin-util-api:3.8.0 popper-api:1.16.1-3 popper2-api:2.11.6-4 postbuild-task:1.9 powershell:2.1 preSCMbuildstep:71.v1f2990a_37e27 prism-api:1.29.0-8 prometheus:2.5.1 promoted-builds:945.v597f5c6a_d3fd prqa-plugin:3.3.5 pubsub-light:1.18 rebuild:330.v645b_7df10e2a_ repository-connector:2.2.1 resource-disposer:0.23 robot:3.5.1 role-strategy:689.v731678c3e0eb_ ruby-runtime:0.12 run-condition:1.7 saml:4.429.v9a_781a_61f1da_ schedule-build:550.v8eb_e2fcf7b_1c scm-api:683.vb_16722fb_b_80b_ script-security:1305.v487433146192 simple-theme-plugin:176.v39740c03a_a_f5 skip-plugin:4.17 snakeyaml-api:2.2-111.vc6598e30cc65 soapui-pro-functional-testing:1.10 sonar:2.17.2 sse-gateway:1.26 ssh-agent:346.vda_a_c4f2c8e50 ssh-credentials:308.ve4497b_ccd8f4 ssh-slaves:2.947.v64ee6b_f87b_c1 ssh-steps:2.0.68.va_d21a_12a_6476 sshd:3.312.v1c601b_c83b_0e stashNotifier:1.464.va_9203f84a_417 structs:325.vcb_307d2a_2782 subversion:2.17.3 support-core:1366.v9d076592655d test-results-analyzer:0.4.1 testng-plugin:835.v51ed3da_fcc35 throttle-concurrents:2.14 timestamper:1.26 token-macro:384.vf35b_f26814ec trilead-api:2.84.86.vf9c960e9b_458 unique-id:2.101.v21a_b_6390a_b_04 uno-choice:2.8.1 user-activity-monitoring:1.18 variant:60.v7290fc0eb_b_cd warnings:5.0.2 warnings-ng:10.7.0 windows-slaves:1.8.1 workflow-aggregator:596.v8c21c963d92d workflow-api:1283.v99c10937efcb_ workflow-basic-steps:1042.ve7b_140c4a_e0c workflow-cps:3837.v305192405b_c0 workflow-cps-checkpoint:2.17 workflow-cps-global-lib:612.v55f2f80781ef workflow-durable-task-step:1313.vcb_970b_d2a_fb_3 workflow-job:1385.vb_58b_86ea_fff1 workflow-multibranch:770.v1a_d0708dd1f6 workflow-scm-step:415.v434365564324 workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:865.v43e78cc44e0d ws-cleanup:0.45 xcode-plugin:2.0.17-565.v1c48051d46ef xunit:3.1.3 xvnc:1.28 ```

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

Reproduced on macOS using CloudBees CI, but cannot imagine it being any different on Jenkins LTS

Reproduction steps

Setup 1

  1. Start a controller without --prefix argument
  2. Follow https://github.com/jenkinsci/oic-auth-plugin/blob/master/docs/configuration/GOOGLE.md
  3. Test authentication

Setup 2

  1. Start a controller with --prefix="/jenkins" argument
  2. Setup the same Google Auth, or if re-using above setup, update the Jenkins Location and Google's "Authorised redirect URIs" before restarting
  3. Test authentication

Expected Results

Both in setup 1 and 2, after successful authentication user lands on the Dashboard

Actual Results

In setup 2, after successful authentication, the user gets 404. The redirect leads them to the page /jenkins/jenkins, which doesn't exist.

Anything else?

https://github.com/jenkinsci/oic-auth-plugin/blob/4.239.v325750a_96f3b_/src/main/java/org/jenkinsci/plugins/oic/OicSecurityRealm.java#L830C5-L844C6 seem to be the cause.

Are you interested in contributing a fix?

Interested but do not have time for it.

michael-doubez commented 6 months ago

This is known issue of 4.229.vf736b_fec02f4

Please upgrade your plugin.

michael-doubez commented 6 months ago

Oups, wrong known issue

michael-doubez commented 6 months ago

This is a knwon issue of v4.223.v503b_9a_75a_8a_f. Please upgrade the plugin to at least v4.227.