我必須爲我們的命令行應用程序(Django應用程序)啓用OpenID For Ex:無論何時用戶嘗試訪問我們的API,我必須確保用戶使用OpenID進行身份驗證(Microsoft /谷歌)。我正在嘗試編寫一個Shell腳本來訪問OpenID網站,然後將Cookie存儲在用戶的計算機上,並且每當他嘗試訪問第二個應用程序時,都應該根據我存儲在他的計算機上的Cookie進行訪問。CURL驗證到網站
我試圖使用here提到的方法,每當我嘗試訪問第二個網址時,出現錯誤「您的瀏覽器當前設置爲阻止Cookie,您需要允許Cookie使用此服務。
我的網站不在一個域中,他們使用OpenID進行身份驗證。
- 我登錄到第一個網站,該網站重定向我到OpenID的網站 (Azure的AD)
- 我訪問使用curl用戶名和密碼 成功並存儲在cookie中的重定向的URL。
- 當我嘗試使用以下 行登錄到第二個網站時,我看到此錯誤。 (因爲我有存儲的cookie它應該能夠閱讀並打開第二個網站的頁面)
curl --cookie ./somefile https://secondwebsite.com/b
這裏是我完整的腳本
#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 "[email protected]" -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/
總之,我附有2個問題
- 將用戶認證爲第二個站點,不帶ne登錄
- 有時身份驗證網址要求用戶的密碼, 將發送給用戶移動(雙因素身份驗證)。任何關於如何處理這種情況的指針,如果它出現?
按照規範,它需要瀏覽器交互,但我正在尋找完全基於命令行的身份驗證。客戶端必須能夠與資源所有者的用戶代理(通常是Web瀏覽器)交互(https://tools.ietf.org/html/rfc6749#section-4.1) –