BrowserID: Switch from GET to POST
This commit is contained in:
parent
a25be7d884
commit
925c2df506
@ -5,11 +5,12 @@ module Web.Authenticate.BrowserId
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Text (Text)
|
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 Network.HTTP.Types (queryTextToQuery)
|
||||||
import Data.Aeson (json, Value (Object, String))
|
import Data.Aeson (json, Value (Object, String))
|
||||||
import Data.Attoparsec.Lazy (parse, maybeResult)
|
import Data.Attoparsec.Lazy (parse, maybeResult)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
import Data.Text.Encoding (encodeUtf8)
|
||||||
|
|
||||||
-- | Location of the Javascript file hosted by browserid.org
|
-- | Location of the Javascript file hosted by browserid.org
|
||||||
browserIdJs :: Text
|
browserIdJs :: Text
|
||||||
@ -20,12 +21,10 @@ checkAssertion :: Text -- ^ audience
|
|||||||
-> IO (Maybe Text)
|
-> IO (Maybe Text)
|
||||||
checkAssertion audience assertion = do
|
checkAssertion audience assertion = do
|
||||||
req' <- parseUrl "https://browserid.org/verify"
|
req' <- parseUrl "https://browserid.org/verify"
|
||||||
let req = req'
|
let req = urlEncodedBody
|
||||||
{ queryString = queryTextToQuery
|
[ ("audience", encodeUtf8 audience)
|
||||||
[ ("audience", Just audience)
|
, ("assertion", encodeUtf8 assertion)
|
||||||
, ("assertion", Just assertion)
|
] req' { method = "POST" }
|
||||||
]
|
|
||||||
}
|
|
||||||
res <- withManager $ httpLbs req
|
res <- withManager $ httpLbs req
|
||||||
let lbs = responseBody res
|
let lbs = responseBody res
|
||||||
return $ maybeResult (parse json lbs) >>= getEmail
|
return $ maybeResult (parse json lbs) >>= getEmail
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: authenticate
|
name: authenticate
|
||||||
version: 0.9.2
|
version: 0.9.2.1
|
||||||
license: BSD3
|
license: BSD3
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman, Hiromi Ishii
|
author: Michael Snoyman, Hiromi Ishii
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user