Safe Haskell | None |
---|
Implements HTTP Basic Authentication.
This module may add digest authentication in the future.
- basicAuth :: CheckCreds -> AuthSettings -> Middleware
- type CheckCreds = ByteString -> ByteString -> IO Bool
- data AuthSettings
- authRealm :: AuthSettings -> ByteString
- authOnNoAuth :: AuthSettings -> ByteString -> Application
- authIsProtected :: AuthSettings -> Request -> IO Bool
Documentation
basicAuth :: CheckCreds -> AuthSettings -> MiddlewareSource
Perform basic authentication.
basicAuth (\u p -> return $ u == "michael" && p == "mypass") "My Realm"
Since 1.3.4
type CheckCreds = ByteString -> ByteString -> IO BoolSource
Check if a given username and password is valid.
data AuthSettings Source
Authentication settings. This value is an instance of IsString
, so the
recommended approach to create a value is to provide a string literal (which
will be the realm) and then overriding individual fields.
"My Realm" { authIsProtected = someFunc } :: AuthSettings
Since 1.3.4
authRealm :: AuthSettings -> ByteStringSource
Since 1.3.4
authOnNoAuth :: AuthSettings -> ByteString -> ApplicationSource
Takes the realm and returns an appropriate 401 response when authentication is not provided.
Since 1.3.4
authIsProtected :: AuthSettings -> Request -> IO BoolSource
Determine if access to the requested resource is restricted.
Default: always returns True
.
Since 1.3.4