Search code examples
pythonflaskjenkinskerberos

Flask webapp deployed with jenkins in an edge node. Request to another http web failed because of kerberos authentication


I have flask webapp, deployed with a jenkins pipeline in an edge node, and running with a nohup process. The script launched by the jenkins pipeline starts with an kinit call.

kinit 'user'@'domain' -kt /home/'user'@'domain'/access/'user'.keytab

Inside this app, there is a function that make a request into another http web. Using the kerberos HTTP authentication.

url = '' x = requests.get(url, verify=False, auth=HTTPKerberosAuth())

After the deploying, everything runs correctly. But, some time after (i don't know exactly how much, but the next day and less than 24 hours) that function stops working and return a 401 error.

Do anyone know why it is this happening?

Thank you all in advance!

The only way i found to correct that error is to deploy everything again, than it works correctly for some time and the error repeats itself exactly like before.

There is also a crontab job that refresh the kerberos ticket everyday at 7 AM (i have to check if the error starts before or after that refreshing, after the refreshing is there but i couldn't check if the error already is there before that refreshing). I also try to do a kinit by myself (without redeploy the app), running

kinit 'user'@'domain' -kt /home/'user'@'domain'/access/'user'.keytab

in the terminal, but it didn't repair anything, the error persists till i redeploy the app.


Solution

  • Solution found: The problem was the the ticket renewed through the jenkins pipeline was a different one than the one renewed through the crontab job. I added a second line to renew the second ticket in the script ran by the crontab job and now everything works.