I have to enable OpenID for our command line application (Django Application) For Ex: whenever the users try to access our APIs, I have to make sure that the user is Authenticated using OpenID (Microsoft/Google). I am trying to write a Shell script to access OpenID website and then store the cookie on the user's machine and whenever he tries to access second application he should be given access based on the cookie that I store on his machine.
I am trying to use the approach mentioned here and whenever I try to access the second url, I am getting an error "Your browser is currently set to block cookies. You need to allow cookies to use this service."
My websites are not on a single domain, They use OpenID to authenticate.
- I logged into the first website and the site redirected me to OpenID website (Azure AD)
- I accessed the redirected url using curl with username and password successfully and stored the cookie.
- When I am trying to login to the second website using the below line, I see this error. (Since I have the cookies stored it should be able to read them and open the second website page)
curl --cookie ./somefile https://secondwebsite.com/b
Here is my complete script
#Setting redirect url in IP variable
set IP=`curl -w "%{url_effective}\n" -I -L -s -S http://mysite1.com -o /dev/null`
echo "Trying to Authenticate.."
curl -L -s -S -I -k -v -i --user "username@microsoft.com" -D ./temp/cookie $IP
echo "Authentication successful"
#I need to check if the cookie is set or not, If it is set Authentication is successful
echo "Trying to access the second url"
#The below line is failing, When I wrote the whole content to html file, I see the error mentioned above (Your browser is currently set to block cookies. You need to allow cookies to use this service)
curl --cookie ./temp/cookie https://secondwebsite.com/
To Summarize, I am stuck with 2 questions
- Authenticating the user to second site without needing to logging in again
- Sometimes the Authentication url asks for Password from the user, which will be sent to users Mobile (2 Factor Authentication). Any pointers on how to handle this case if it arises?