hoauth 0.1.0 → 0.1.1
raw patch · 4 files changed
+30/−32 lines, 4 files
Files
- hoauth.cabal +1/−1
- src/main/haskell/Network/Protocol/OAuth/Consumer.hs +11/−11
- src/main/haskell/Network/Protocol/OAuth/Request.hs +1/−1
- src/main/haskell/Network/Protocol/OAuth/Signature.hs +17/−19
hoauth.cabal view
@@ -1,5 +1,5 @@ name: hoauth-version: 0.1.0+version: 0.1.1 category: Network,Protocol,OAuth license: BSD3 license-file: LICENSE
src/main/haskell/Network/Protocol/OAuth/Consumer.hs view
@@ -63,9 +63,9 @@ -- -- The request you provide /must/ contain /oauth_nonce/ and /oauth_timestamp/ parameters properly defined. request :: (S.Signer s,Show s) => Consumer -> s -> R.Request -> R.Request-request (Unauthenticated ckey csec) s r = _oauth ckey csec Nothing s r-request (Authenticated ckey csec tk) s r = let req = r >>+ ("oauth_token", (Just . oauth_token) tk) - in _oauth ckey csec ((Just . oauth_token_secret) tk) s req+request (Unauthenticated ckey _) s r = _oauth ckey s r+request (Authenticated ckey _ tk) s r = let req = r >>+ ("oauth_token", (Just . oauth_token) tk) + in _oauth ckey s req -- | Process the response of the service provider. The response should be an urlencoded string. response :: Consumer -> B.ByteString -> Maybe Consumer@@ -82,13 +82,13 @@ of (Unauthenticated ckey csec) -> Just $ Authenticated ckey csec (Token otken otkensec otkextra) (Authenticated ckey csec _) -> Just $ Authenticated ckey csec (Token otken otkensec otkextra) -_oauth :: (S.Signer s,Show s) => String -> String -> Maybe String -> s -> R.Request -> R.Request-_oauth ckey csec tsec met req = req >>+ ("oauth_consumer_key",Just ckey)- >>+ ("oauth_version",Just "1.0")- >>+ ("oauth_signature_method",(Just . show) met)- >>| _sign csec tsec met+_oauth :: (S.Signer s,Show s) => String -> s -> R.Request -> R.Request+_oauth ckey met req = req >>+ ("oauth_consumer_key",Just ckey)+ >>+ ("oauth_version",Just "1.0")+ >>+ ("oauth_signature_method",(Just . show) met)+ >>| _sign met -_sign :: (S.Signer s,Show s) => String -> Maybe String -> s -> R.Request -> R.Request-_sign csec tsec met req = let sig = S.sign met req- in req >>+ ("oauth_signature",Just sig)+_sign :: (S.Signer s,Show s) => s -> R.Request -> R.Request+_sign met req = let sig = S.sign met req+ in req >>+ ("oauth_signature",Just sig)
src/main/haskell/Network/Protocol/OAuth/Request.hs view
@@ -24,7 +24,7 @@ -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -module Network.Protocol.OAuth.Request (Request(..),HTTPMethod(..),Parameter,PercentEncoding,encode,encodes,decode,decodes,append_param,apply,show_url,show_oauthurl,show_oauthheader,show_urlencoded,read_urlencoded,(>>+),(>>|)) where+module Network.Protocol.OAuth.Request (Request(..),HTTPMethod(..),Parameter,PercentEncoding(encode,encodes,decode,decodes),append_param,apply,show_url,show_oauthurl,show_oauthheader,show_urlencoded,read_urlencoded,(>>+),(>>|)) where import Data.Bits as B import qualified Data.ByteString.Lazy as B1
src/main/haskell/Network/Protocol/OAuth/Signature.hs view
@@ -25,7 +25,7 @@ -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- | Implements PLAINTEXT and HMAC-SHA1 signatures of oauth spec <http://oauth.net/core/1.0a#signing_process>-module Network.Protocol.OAuth.Signature (Method(..),Signer,sign) where+module Network.Protocol.OAuth.Signature (Method(..),Signer(sign)) where import qualified Network.Protocol.OAuth.Request as R import qualified Data.Digest.Pure.SHA as S@@ -37,26 +37,24 @@ -- | The signature method which will be used to sign requests. data Method = - {-| The 'PLAINTEXT' method does not provide any security protection and- SHOULD only be used over a secure channel such as /HTTPS/. It does- not use the Signature Base String.+ {-| The 'PLAINTEXT' /consumer_key/ /token_secret/ method does not provide+ any security protection and SHOULD only be used over a secure channel+ such as /HTTPS/. It does not use the Signature Base String. -}- PLAINTEXT String -- ^ The consumer secret- (Maybe String) -- ^ The token secret- {-| The 'HMAC_SHA1' signature method uses the /HMAC-SHA1/ signature- algorithm as defined in <http://tools.ietf.org/html/rfc2104> where- the Signature Base String is the text and the key is the- concatenated values (each first encoded per Parameter Encoding) of- the Consumer Secret and Token Secret, separated by an /&/ character- (ASCII code 38) even if empty.+ PLAINTEXT String (Maybe String)+ {-| The 'HMAC_SHA1' /consumer_key/ /token_secret/ signature method uses the+ /HMAC-SHA1/ signature algorithm as defined in+ <http://tools.ietf.org/html/rfc2104> where the Signature Base String is+ the text and the key is the concatenated values (each first encoded per+ Parameter Encoding) of the Consumer Secret and Token Secret, separated+ by an /&/ character (ASCII code 38) even if empty. -}- | HMAC_SHA1 String -- ^ The consumer secret- (Maybe String) -- ^ The token secret- {-| The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature- algorithm as defined in [RFC3447] section 8.2 (more simply known as- PKCS#1), using SHA-1 as the hash function for EMSA-PKCS1-v1_5. It is- assumed that the Consumer has provided its RSA public key in a verified- way to the Service Provider.+ | HMAC_SHA1 String (Maybe String) + {-| The 'RSA_SHA1' /rsa_privkey/ signature method uses the+ RSASSA-PKCS1-v1_5 signature algorithm as defined in [RFC3447] section+ 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for+ EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA+ public key in a verified way to the Service Provider. -} | RSA_SHA1 R1.PrivateKey