X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FAuthentication.hs;h=753af6ecbe72153ab3394a76ba1e1b0da2e79c81;hb=b1fac0a2cb1cafa008c0efa8ae4e14afbee0927f;hp=74791881d68a7bd8449ca1495be7ba108d52cc34;hpb=0aa4f6d758fc12fba468f7cd399bbcc48f693d1e;p=Lucu.git diff --git a/Network/HTTP/Lucu/Authentication.hs b/Network/HTTP/Lucu/Authentication.hs index 7479188..753af6e 100644 --- a/Network/HTTP/Lucu/Authentication.hs +++ b/Network/HTTP/Lucu/Authentication.hs @@ -2,7 +2,7 @@ OverloadedStrings , UnicodeSyntax #-} --- |Manipulation of WWW authentication. +-- |HTTP Authentication module Network.HTTP.Lucu.Authentication ( AuthChallenge(..) , AuthCredential(..) @@ -11,9 +11,10 @@ module Network.HTTP.Lucu.Authentication , Password , printAuthChallenge - , authCredentialP + , authCredential ) where +import Control.Monad import Data.Ascii (Ascii) import qualified Data.Ascii as A import Data.Attoparsec.Char8 @@ -24,14 +25,14 @@ import Network.HTTP.Lucu.Parser.Http import Network.HTTP.Lucu.Utils import Prelude.Unicode --- |Authorization challenge to be sent to client with --- \"WWW-Authenticate\" header. See +-- |Authentication challenge to be sent to clients with +-- \"WWW-Authenticate\" header field. See -- 'Network.HTTP.Lucu.Resource.setWWWAuthenticate'. data AuthChallenge = BasicAuthChallenge !Realm deriving (Eq) --- |'Realm' is just a string which must not contain any non-ASCII letters. +-- |'Realm' is just an 'Ascii' string. type Realm = Ascii -- |Authorization credential to be sent by client with @@ -41,12 +42,10 @@ data AuthCredential = BasicAuthCredential !UserID !Password deriving (Show, Eq) --- |'UserID' is just a string which must not contain colon and any --- non-ASCII letters. -type UserID = Ascii +-- |'UserID' is just an 'Ascii' string containing no colons (\':\'). +type UserID = Ascii --- |'Password' is just a string which must not contain any non-ASCII --- letters. +-- |'Password' is just an 'Ascii' string. type Password = Ascii -- |Convert an 'AuthChallenge' to 'Ascii'. @@ -55,9 +54,10 @@ printAuthChallenge (BasicAuthChallenge realm) = A.fromAsciiBuilder $ A.toAsciiBuilder "Basic realm=" ⊕ quoteStr realm -authCredentialP ∷ Parser AuthCredential -authCredentialP - = do _ ← string "Basic" +-- |'Parser' for an 'AuthCredential'. +authCredential ∷ Parser AuthCredential +authCredential + = do void $ string "Basic" skipMany1 lws b64 ← takeWhile1 base64 case C8.break (≡ ':') (B64.decodeLenient b64) of