]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Authentication.hs
Haddock overhaul
[Lucu.git] / Network / HTTP / Lucu / Authentication.hs
index 74791881d68a7bd8449ca1495be7ba108d52cc34..3f8d76297169aeaa074c70310d7773af988ddff2 100644 (file)
@@ -2,7 +2,7 @@
     OverloadedStrings
   , UnicodeSyntax
   #-}
--- |Manipulation of WWW authentication.
+-- |HTTP Authentication
 module Network.HTTP.Lucu.Authentication
     ( AuthChallenge(..)
     , AuthCredential(..)
@@ -14,6 +14,7 @@ module Network.HTTP.Lucu.Authentication
     , authCredentialP
     )
     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
 
+-- |'Parser' for an 'AuthCredential'.
 authCredentialP ∷ Parser AuthCredential
 authCredentialP
-    = do _ ← string "Basic"
+    = do void $ string "Basic"
          skipMany1 lws
          b64 ← takeWhile1 base64
          case C8.break (≡ ':') (B64.decodeLenient b64) of