Hey All,
I’ll try to be as descriptive as possible without being able to post the full code snippet. Thank you for your patience in advance.
I’m trying to use the Python 3 requests-kerberos module to login to Foreman, to then scrape the content views. I managed to figure out the CSRF part including the authenticity_token by running requests.get() on the url and retrieving it from the resultant HTML. I can then pass the authenticity_token to the payload correctly. However, that’s where my success stops. It fails to login after that due to issues, I’m thinking, in the payload itself.
I’ve tried requets.post ( ...., data = payload, ... auth=HTTPKerberosAuth() )
where the payload is:
payload = {
"username":"sam",
"password":"passw0rd",
"authenticity_token": mytoken
}
But this gives me:
Action failed
NoMethodError: undefined method `[]' for nil:NilClass
Resulting in an HTML error 500. I’ve also tried the following payload:
payload = {
"login": { "login":"sam", "password":"passw0rd",
"authenticity_token": mytoken
}
with both requests.post (... json = payload, .... )
and requests.post ( ....., data = payload, ... )
but only get a Parameters string that includes either:
{ ... "login"=>{"login"=>"sam", "password"=>"[FILTERED]", ......, "user"=>{"login"=>{"login"=>"sam", "password"=>"[FILTERED]"}}}
resulting in an “Invalid user” being returned for the former. Or for the latter, the Parameters shown in the foreman logs shows:
{ ...., "login"=>"passwor", ..... }
again resulting in an ‘Invalid user’ being printed. HTML error 302.
What is the correct way to perform AD / Kerberos user authentication in Kerberos enabled Foreman though Python 3?
Thx,