\section{\module{HttpAuthenticate} --- Basic HTTP authentication.}
\declaremodule{standard}{HttpAuthenticate}

\subsection{Module}
This module allows you to protect a part of your website with a login and a password, using a basic
HTTP authentication scheme.

All you have to do is declare a CherryClass that inherits from \var{HttpAuthenticate}, and all your masks
and views will be automatically protected.

To perform this magic, \var{HttpAuthenticate} uses AOP (aspect oriented programming). This basically means
that it will add some extra code at the beginning of each of your masks and views.

You may override the following methods:

\begin{funcdesc}{function: getPasswordListForLogin}{login}
This is where you specify what the valid login/password combinations are. The input value is the login that the
user entered. The method should return a list of all valid passwords for this login. If the login is incorrect, just
return an empty list.

Note: Being able to return several matching passwords for a login allows you to keep a "master key" password that works 
with all logins.
\end{funcdesc}

\begin{funcdesc}{mask or view: unauthorized}{}
This is the page that is displayed when the user entered an incorrect login/password 3 times in a row.
\end{funcdesc}

\begin{memberdesc}{variable: login}
String containing the login of the user that is logged in. The string is empty if no-one is logged in.
\end{memberdesc}

Note: There is no "logout" method. Users are automatically logged out when they close their browser window.

\begin{seealso}
  \seemodule{CookieAuthenticate}{Cookie-based authentication.}
  \seemodule{CookieSessionAuthenticate}{Cookie/session-based authentication.}
\end{seealso}

\subsection{Example}
The following code is an exemple that uses the HttpAuthenticate module:

\begin{verbatim}
use HttpAuthenticate
CherryClass Root(HttpAuthenticate):
function:
    def getPasswordListForLogin(login):
        if login=='mySecretLogin': return ['mySecretPassword']
        return []
mask:
    def index(self):
        <html><body>
            Hello <py-eval="self.login">, I see you know the secret login and password ...
        </body></html>
    def unauthorized(self):
        <html><body>
            Hey dude, get out ! You're not allowed here if you don't know the login/password
        </body></html>
\end{verbatim}


