Send asynchronous XmlHttpRequest through javascript with authentication

215 views
Skip to first unread message

t4k30ff

unread,
Oct 20, 2021, 8:39:10 AM10/20/21
to Jenkins Developers
Hello,

I was currently experimenting with jelly and javascript and wrote a RootAction that would be accessed by the loaded page every second through a timeout.
The problem i face now is that if i export the hpi from my test server to a "real" one (it's a server on my laptop aswell but with accounts and stuff) i get a 403 forbidden and the response reads "Authentication required".
So i did some research and i found that i have to add the "Authentication" header to my request with the credentials.
But my problem now is how to get these credentials (mostly password/-hash; i can get username through ${user.name} in jelly).

I'd be glad if you could help me.

Thanks in advance

Tim Jacomb

unread,
Oct 20, 2021, 2:59:33 PM10/20/21
to Jenkins Developers
You don't pass the credentials, you pass along the users cookies

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/86abd56d-f99f-4ede-9a1a-435bc6a9a651n%40googlegroups.com.

Gavin Mogan

unread,
Oct 20, 2021, 3:04:19 PM10/20/21
to Jenkins Developers
I'd have to look up how we do it currently but generally you want with credentials to be set to true so cookies and all get passed


The org wide GitHub search is pretty helpful at finding examples.


Though I'm guessing why very little shows up is most people are using the prototypejs (boo) or jquery ajax helpers.

--

t4k30ff

unread,
Oct 21, 2021, 5:10:25 AM10/21/21
to Jenkins Developers
That was it! Thank you very much.
Reply all
Reply to author
Forward
0 new messages