packages feed

yesod-auth-oauth 0.3 → 0.4

raw patch · 2 files changed

+38/−30 lines, 2 filesdep +authenticatedep +authenticate-oauthdep +bytestringdep −hoauth

Dependencies added: authenticate, authenticate-oauth, bytestring, http-enumerator, utf8-string

Dependencies removed: hoauth

Files

Yesod/Helpers/Auth/OAuth.hs view
@@ -1,18 +1,19 @@-{-# LANGUAGE CPP, QuasiQuotes #-}+{-# LANGUAGE CPP, QuasiQuotes, OverloadedStrings #-} module Yesod.Helpers.Auth.OAuth     ( authOAuth     , oauthUrl     , authTwitter     , twitterUrl     ) where-import Yesod+import Yesod hiding (insert) import Yesod.Helpers.Auth-import Network.OAuth.Consumer-import Network.OAuth.Http.Request hiding (replace)-import qualified Network.OAuth.Http.Request as OA-import Network.OAuth.Http.CurlHttpClient+import Web.Authenticate.OAuth import Data.Maybe import Data.String+import Network.HTTP.Enumerator+import Data.ByteString.Char8 (unpack, pack)+import Control.Arrow ((***))+import Control.Monad  oauthUrl :: String -> AuthRoute oauthUrl name = PluginR name ["forward"]@@ -29,31 +30,29 @@ authOAuth name ident reqUrl accUrl authUrl key sec = AuthPlugin name dispatch login   where     url = PluginR name []+    oauth = OAuth { oauthServerName = name, oauthRequestUri = reqUrl+                  , oauthAccessTokenUri = accUrl, oauthAuthorizeUri = authUrl+                  , oauthSignatureMethod = HMACSHA1+                  , oauthConsumerKey = fromString key, oauthConsumerSecret = fromString sec+                  , oauthCallback = Nothing+                  }     dispatch "GET" ["forward"] = do         render <- getUrlRender         tm <- getRouteToMaster-        let app = Application key sec (URL $ render $ tm url)-        tok <- runOAuthM (fromApplication app) $ do-          signRq2 HMACSHA1 Nothing (fromJust . parseURL $ reqUrl) >>= oauthRequest CurlClient-        let oaUrl = fromString $ concat-                    [ authUrl-                    , "?oauth_token="-                    , findWithDefault ("oauth_token", "ERR") $ oauthParams tok-                    ]-        redirectString RedirectTemporary oaUrl+        let oauth' = oauth { oauthCallback = Just $ fromString $ render $ tm url }+        tok <- liftIO $ getTemporaryCredential oauth'+        redirectString RedirectTemporary (fromString $ authorizeUrl oauth' tok)     dispatch "GET" [] = do         render <- getUrlRender         tm <- getRouteToMaster-        let app = Application key sec (URL $ render $ tm url)+        let callback = render $ tm url         verifier <- runFormGet' $ stringInput "oauth_verifier"         oaTok    <- runFormGet' $ stringInput "oauth_token"-        let appTok = fromApplication app-            params = OA.replace ("oauth_token", oaTok) $ oauthParams appTok-            reqTok = injectOAuthVerifier verifier $ ReqToken app params-        accTok <- runOAuthM reqTok $ do-          signRq2 HMACSHA1 Nothing (fromJust . parseURL $ accUrl) >>= oauthRequest CurlClient-        let crId = findWithDefault (ident, error "oops!") $ oauthParams accTok-            creds = Creds name crId $ toList $ oauthParams accTok+        let reqTok = Credential [ ("oauth_verifier", pack verifier), ("oauth_token", pack oaTok)+                                ] +        accTok <- liftIO $ getTokenCredential oauth reqTok+        let crId = unpack $ fromJust $ lookup (pack ident) $ unCredential accTok+            creds = Creds name crId $ map (unpack *** unpack) $ unCredential accTok         setCreds True creds     dispatch _ _ = notFound     login tm = do@@ -65,7 +64,7 @@ #else           [$hamlet| #endif-             <a>!href=$oaUrl$ Login with $name$+             <a href=#{oaUrl}>Login with #{name}           |]  authTwitter :: YesodAuth m =>
yesod-auth-oauth.cabal view
@@ -7,13 +7,13 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.3+Version:             0.4  -- A short (one-line) description of the package. Synopsis:            OAuth wrapper for yesod-auth  -- A longer description of the package.-Description: General OAuth interface for yesod-auth.+Description:  OAuth client interface for yesod-auth.  -- The license under which the package is released. License:             BSD3@@ -43,16 +43,25 @@ Cabal-version:       >=1.2  +flag oauth-not-supported+  Description: use authenticate-oauth instead of authenticate+  Default: True+ Library   -- Modules exported by the library.   Exposed-modules:     Yesod.Helpers.Auth.OAuth      -- Packages needed in order to build this package.-  Build-depends: base >= 4 && < 5, hoauth >= 0.3 && <0.4, yesod-auth >= 0.3 && < 0.4,-                 yesod >= 0.7 && < 0.8-  +  Build-depends: base >= 4 && < 5, yesod-auth >= 0.3 && < 0.4,+                 yesod >= 0.7 && < 0.8, bytestring >= 0.9 && < 1.0, http-enumerator >= 0.3 && <0.4,+                 utf8-string >= 0.3 && < 0.4+  if flag(oauth-not-supported)+    Build-depends: authenticate-oauth >= 0.1 && < 0.2+  else+    Build-depends: authenticate >= 0.8.1  && < 0.9+   -- Modules not exported by this package.-  -- Other-modules:       +  -- Other-modules:       -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.   -- Build-tools: