5

I ran

a cURL on my Terminal

Note : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

curl -c session_cookies.txt "https://login.uat.site.be/openid/oauth/authorize?client_id=site&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&response_type=code&claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D" 2>/dev/null| curl -v -b session_cookies.txt -L -H "Content-Type: application/x-www-form-urlencoded" -v -d '[email protected]&j_password=site1' "https://login.uat.site.be/openid/login.do" 2>&1 >/dev/null | grep Location | grep code=

I got this reponse back

< Location: https://testserver.sitenets.com/user/secure/dashboard?code=zvk495dsnq1ycLKZgN8oqfFxQogg2oql&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

Note : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7


PHP

Note : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

$cmd = 'curl -c session_cookies.txt "https://login.uat.site.be/openid/oauth/authorize?client_id=site&state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&response_type=code&claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D" 2>/dev/null| curl -v -b session_cookies.txt -L -H "Content-Type: application/x-www-form-urlencoded" -v -d '[email protected]&j_password=site1' "https://login.uat.site.be/openid/login.do" 2>&1 >/dev/null | grep Location | grep code=';


$result = shell_exec($cmd);

dd($result); 

Note : state != b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7

Note : state = 12345678-256d-425d-808b-1e05d2aa3d72

< Location: https://testserver.sitenets.com/user/secure/dashboard?code=zvk495dsnq1ycLKZgN8oqfFxQogg2oql&state=12345678-256d-425d-808b-1e05d2aa3d72

When I run shell_exec($cmd), my state always come back different the one that I submitted. How is this possible?

Is it caching somewhere on my local machine? Should I clear something?

Why shell_exec() return slightly different result than if I would have do it directly on Terminal? I even tried using exec(), same result.

10
  • for $cmd = 'curl -c session_cookies.txt ... the session_cookies file must be in the program's current working directory. Is that the case also when you execute the php code? Commented Jan 26, 2017 at 15:45
  • I hope those aren't real usernames/password first of all second you may be having an issue with how you are running the script. session_cookies.txt may be different because it appears you are running the command as the php server user not as your terminal user so maybe it is in different locations. Commented Jan 26, 2017 at 15:45
  • Is it just me or are you getting the nonce back? Can't be a coincidence. Commented Jan 26, 2017 at 15:50
  • @fvu : Good observation !!, I run that shell_exec in 1 of my controller, and the session.txt is in my public/ directory. I guess, I should include the absolute path to my session.txt ??? what do you think ? Commented Jan 26, 2017 at 15:53
  • 1
    That's definitely worth a try. Also, don't forget that curl is available as an extension in php, you are not obliged to shell out. Commented Jan 26, 2017 at 15:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.