BrowserID: Switch from GET to POST

This commit is contained in:
Michael Snoyman 2011-07-24 07:13:12 +03:00
parent a25be7d884
commit 925c2df506
2 changed files with 7 additions and 8 deletions

View File

@ -5,11 +5,12 @@ module Web.Authenticate.BrowserId
) where
import Data.Text (Text)
import Network.HTTP.Enumerator (parseUrl, responseBody, httpLbs, queryString, withManager)
import Network.HTTP.Enumerator (parseUrl, responseBody, httpLbs, withManager, method, urlEncodedBody)
import Network.HTTP.Types (queryTextToQuery)
import Data.Aeson (json, Value (Object, String))
import Data.Attoparsec.Lazy (parse, maybeResult)
import qualified Data.Map as Map
import Data.Text.Encoding (encodeUtf8)
-- | Location of the Javascript file hosted by browserid.org
browserIdJs :: Text
@ -20,12 +21,10 @@ checkAssertion :: Text -- ^ audience
-> IO (Maybe Text)
checkAssertion audience assertion = do
req' <- parseUrl "https://browserid.org/verify"
let req = req'
{ queryString = queryTextToQuery
[ ("audience", Just audience)
, ("assertion", Just assertion)
]
}
let req = urlEncodedBody
[ ("audience", encodeUtf8 audience)
, ("assertion", encodeUtf8 assertion)
] req' { method = "POST" }
res <- withManager $ httpLbs req
let lbs = responseBody res
return $ maybeResult (parse json lbs) >>= getEmail

View File

@ -1,5 +1,5 @@
name: authenticate
version: 0.9.2
version: 0.9.2.1
license: BSD3
license-file: LICENSE
author: Michael Snoyman, Hiromi Ishii