YunoHost-Apps / jenkins_ynh

Jenkins package for YunoHost
https://jenkins.io/
Apache License 2.0
5 stars 10 forks source link

Yunohost 401 when trying to access webhooks #141

Open Pikari0 opened 2 months ago

Pikari0 commented 2 months ago

Hello!

Important: I am not using LDAP for Jenkins, but instead "Jenkins' own user database" as I want to manage myself the users.

I'm trying to trigger a build from Gitlab using Jenkins webhooks. I have created a token for my admin user and I gave to Gitlab a URL like this : https://user:token@myserver/jenkins/job/jobname/build Then I got a banner saying:

Hook executed successfully but returned HTTP 401 <html> <head><title>401 Authorization Required</title><script type="text/javascript" src="/ynh_portal.js"></script><link type="text/css" rel="stylesheet" href="/ynh_overlay.css"><script type="text/javascript" src="/ynhtheme/custom_portal.js"></script><link type="text/css" rel="stylesheet" href="/ynhtheme/custom_overlay.css"></head> <body> <center><h1>401 Authorization Required</h1></center> <hr><center>nginx</center> </body> </html>

So I tried with cURL: curl -X POST https://myserver/jenkins/job/jobname/build --user username:token and I obtain the same 401 error.

But if I gave my yunohost credential instead --user ynh_user:ynh_pass I obtain this, which seems to be the real 401 from Jenkins:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 401 Unauthorized</title>
<script type="text/javascript" src="/ynh_portal.js"></script><link type="text/css" rel="stylesheet" href="/ynh_overlay.css"><script type="text/javascript" src="/ynhtheme/custom_portal.js"></script><link type="text/css" rel="stylesheet" href="/ynhtheme/custom_overlay.css"></head>
<body><h2>HTTP ERROR 401 Unauthorized</h2>
<table>
<tr><th>URI:</th><td>/jenkins/job/UNM_Compilation/</td></tr>
<tr><th>STATUS:</th><td>401</td></tr>
<tr><th>MESSAGE:</th><td>Unauthorized</td></tr>
<tr><th>SERVLET:</th><td>Stapler</td></tr>
</table>
<hr/><a href="https://eclipse.org/jetty">Powered by Jetty:// 10.0.18</a><hr/>

</body>
</html>

My guess is that Yunohost is preventing my webhooks calls to get to jenkins, although "visitors" are authorized to access the app. I think it's a nginx configuration to change ? Maybe it's not a bug and using Jenkins without LDAP is not supported by YuNoHost?

Context

Steps to reproduce

Expected behavior

The webhook trigger the build.

Logs

The request doesn't create access log inside jenkins, inferring that the request is not reaching it.