X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FAuthentication.hs;h=29ae0e92bc1b9752850a7ce8dd342df78fa6203a;hb=fffa09842d060c7d738084125dea07783d84aefe;hp=74791881d68a7bd8449ca1495be7ba108d52cc34;hpb=0aa4f6d758fc12fba468f7cd399bbcc48f693d1e;p=Lucu.git diff --git a/Network/HTTP/Lucu/Authentication.hs b/Network/HTTP/Lucu/Authentication.hs index 7479188..29ae0e9 100644 --- a/Network/HTTP/Lucu/Authentication.hs +++ b/Network/HTTP/Lucu/Authentication.hs @@ -2,7 +2,7 @@ OverloadedStrings , UnicodeSyntax #-} --- |Manipulation of WWW authentication. +-- |An internal module for 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,29 +25,26 @@ 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 --- 'Network.HTTP.Lucu.Resource.setWWWAuthenticate'. +-- |Authentication challenge to be sent to clients with +-- \"WWW-Authenticate\" header field. See +-- 'Network.HTTP.Lucu.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 --- \"Authorization\" header. See --- 'Network.HTTP.Lucu.Resource.getAuthorization'. +-- \"Authorization\" header. See 'Network.HTTP.Lucu.getAuthorization'. 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 +53,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