cvs: peardoc /en/packages/authentication auth.xml

From: Date: Sun, 03 Nov 2002 17:06:01 +0000
Subject: cvs: peardoc /en/packages/authentication auth.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7276@lists.php.net to get a copy of this message
mj Sun Nov 3 12:06:01 2002 EDT Modified files: /peardoc/en/packages/authentication auth.xml Log: * Fix indentation.

Index: peardoc/en/packages/authentication/auth.xml diff -u peardoc/en/packages/authentication/auth.xml:1.10 peardoc/en/packages/authentication/auth.xml:1.11 --- peardoc/en/packages/authentication/auth.xml:1.10 Sun Oct 13 06:16:15 2002 +++ peardoc/en/packages/authentication/auth.xml Sun Nov 3 12:06:01 2002 @@ -1,28 +1,28 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.10 $ --> - <refentry id="packages.Auth.Auth"> - <refnamediv> - <refname><classname>Auth</classname></refname> - <refpurpose> - PHP based authentication systems. - </refpurpose> - </refnamediv> - - <refsect1 id="packages.Auth.Auth.tutorial"> - <title>Usage example</title> - - <simpara> - Our goal during this "mini tutorial" is to set up a system that - secures your site with an easy to use authentication mechanism. - </simpara> - <para> - At the top of the site to secured, place the - following code snippet: - </para> - <example> - <title>Typical usage example for <classname>PEAR::Auth</classname></title> - <programlisting role="php"> - <![CDATA[ +<!-- $Revision: 1.11 $ --> +<refentry id="packages.Auth.Auth"> + <refnamediv> + <refname><classname>Auth</classname></refname> + <refpurpose> + PHP based authentication systems. + </refpurpose> + </refnamediv> + + <refsect1 id="packages.Auth.Auth.tutorial"> + <title>Usage example</title> + + <simpara> + Our goal during this "mini tutorial" is to set up a system that + secures your site with an easy to use authentication mechanism. + </simpara> + <para> + At the top of the site to secured, place the + following code snippet: + </para> + <example> + <title>Typical usage example for <classname>PEAR::Auth</classname></title> + <programlisting role="php"> + <![CDATA[ require_once "Auth/Auth.php"; function loginFunction() @@ -52,63 +52,63 @@ */ } ]]> - </programlisting> - </example> - <para> - This few lines of code instantiate the authentication system. - </para> - <para> - The first line in the above script includes the file from your - PEAR directory. It contains all the necessary code to run - PEAR::Auth. Next, we define a function to display the login form - which the visitor of your page has to use to enter his login - data. You can change all the HTML formating in this function. - </para> - <warning> - <simpara> - You can change all the HTML formatting in the function, but you - cannot change the names of the input boxes in the form. They have - to be "username" and "password". + </programlisting> + </example> + <para> + This few lines of code instantiate the authentication system. + </para> + <para> + The first line in the above script includes the file from your + PEAR directory. It contains all the necessary code to run + PEAR::Auth. Next, we define a function to display the login form + which the visitor of your page has to use to enter his login + data. You can change all the HTML formating in this function. + </para> + <warning> + <simpara> + You can change all the HTML formatting in the function, but you + cannot change the names of the input boxes in the form. They have + to be "username" and "password". </simpara> - </warning> - <para> - Since we want to use a database to verify the login data, we now - create the variable $dsn, it contains a valid DSN string that will - be used to connect to the database via PEAR::DB. For the default - database table schema or to use a different storage container, - please see below for more information. - </para> - <para> - After that we create the authentication object. The first - parameter defines the name of the storage container. Because we - want to use a database driven storage container, we pass "DB" - here. The second parameter is the connection parameter for the - container driver. We use the previously defined DSN string. The - third parameter is the name of our function that we defined at the - beginning of the script. It prints the login form. - </para> + </warning> + <para> + Since we want to use a database to verify the login data, we now + create the variable $dsn, it contains a valid DSN string that will + be used to connect to the database via PEAR::DB. For the default + database table schema or to use a different storage container, + please see below for more information. + </para> + <para> + After that we create the authentication object. The first + parameter defines the name of the storage container. Because we + want to use a database driven storage container, we pass "DB" + here. The second parameter is the connection parameter for the + container driver. We use the previously defined DSN string. The + third parameter is the name of our function that we defined at the + beginning of the script. It prints the login form. + </para> + <para> + Now our authentication object is initialized and we need to check + if the user is logged in. This is done via the function + <function>getAuth</function>. If it returns true, we can pass the + content of our page to the user. + </para> + <warning> <para> - Now our authentication object is initialized and we need to check - if the user is logged in. This is done via the function - <function>getAuth</function>. If it returns true, we can pass the - content of our page to the user. - </para> - <warning> - <para> - For now one cannot use - <programlisting role="php"> - <![CDATA[ + For now one cannot use + <programlisting role="php"> + <![CDATA[ $auth = new Auth(...); - ]]> - </programlisting> - with register_globals=on, because $auth is also the name of - the session variable, that is used by PEAR::Auth. - </para> - </warning> - <para> - <example> - <title>Using optional authentication</title> - <programlisting role="php"> + ]]> + </programlisting> + with register_globals=on, because $auth is also the name of + the session variable, that is used by PEAR::Auth. + </para> + </warning> + <para> + <example> + <title>Using optional authentication</title> + <programlisting role="php"> <![CDATA[ require_once "Auth/Auth.php"; @@ -147,81 +147,81 @@ echo "One can only see this if he is logged in!"; } ]]> - </programlisting> - </example> - </para> - <para> - This is a pretty nice example for the optional login feature: The - last parameter <parameter>$optional</parameter> can be either true - or false. If it is false, the login form is not shown and the user - only sees the text "Everybody can see this text!". If he clicks on - the link above this text, he gets the same page but with the GET - parameter "login=1". Now he can enter his login information in the - login form. If he successfully logs in, he can then see the text - "Everybody can see this text!" and the text "One can only see this - if he is logged in!". - </para> - <para> - In the following passages we cover more detailed information about - the functions of PEAR::Auth. - </para> - <para> - This SQL statement creates a table usable under the default - database authentication scheme using MySQL: - </para> - <example> - <title>Authentication table DDL statement</title> + </programlisting> + </example> + </para> + <para> + This is a pretty nice example for the optional login feature: The + last parameter <parameter>$optional</parameter> can be either true + or false. If it is false, the login form is not shown and the user + only sees the text "Everybody can see this text!". If he clicks on + the link above this text, he gets the same page but with the GET + parameter "login=1". Now he can enter his login information in the + login form. If he successfully logs in, he can then see the text + "Everybody can see this text!" and the text "One can only see this + if he is logged in!". + </para> + <para> + In the following passages we cover more detailed information about + the functions of PEAR::Auth. + </para> + <para> + This SQL statement creates a table usable under the default + database authentication scheme using MySQL: + </para> + <example> + <title>Authentication table DDL statement</title> <programlisting role="sql"> - <![CDATA[ + <![CDATA[ CREATE TABLE auth ( username VARCHAR(50) default '' NOT NULL, password VARCHAR(32) default '' NOT NULL, PRIMARY KEY (username), KEY (password) ); - ]]> - </programlisting> - </example> - <para> - These are the table and field names necessary for working - authentication. The password column must be at least 32 characters - long because we store passwords encrypted using md5() and that is - the length of the values returned by md5(). - </para> - <para> - This next feature is useful for sites which provide some services - to all users that visit the sites and some services only to users - that are logged in, such as portals. - </para> - </refsect1> - - <refsect1 id="packages.Auth.Auth.Auth"> - <title>Auth::Auth</title> - - <funcsynopsis> - <funcprototype> - <funcdef><function>Auth::Auth</function></funcdef> - <paramdef>string <parameter>storageDriver</parameter></paramdef> - <paramdef>mixed <parameter>options</parameter></paramdef> - <paramdef>string <parameter>loginFunction</parameter></paramdef> - <paramdef>bool <parameter><optional>showLogin</optional></parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Constructor for the authentication system. The first parameter is - the name of the storage driver that should be used. The second - parameter can either be a string containing some login information - or an array containing a bunch of options for the storage driver. - </para> - <para> - The third parameter is the name of user-defined function that - prints the login screen. The last parameter can be either true - or false and defines if the login is optional or not. - </para> - - <example> - <title>Using different DB parameters</title> - <programlisting role="php"> + ]]> + </programlisting> + </example> + <para> + These are the table and field names necessary for working + authentication. The password column must be at least 32 characters + long because we store passwords encrypted using md5() and that is + the length of the values returned by md5(). + </para> + <para> + This next feature is useful for sites which provide some services + to all users that visit the sites and some services only to users + that are logged in, such as portals. + </para> + </refsect1> + + <refsect1 id="packages.Auth.Auth.Auth"> + <title>Auth::Auth</title> + + <funcsynopsis> + <funcprototype> + <funcdef><function>Auth::Auth</function></funcdef> + <paramdef>string <parameter>storageDriver</parameter></paramdef> + <paramdef>mixed <parameter>options</parameter></paramdef> + <paramdef>string <parameter>loginFunction</parameter></paramdef> + <paramdef>bool <parameter><optional>showLogin</optional></parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Constructor for the authentication system. The first parameter is + the name of the storage driver that should be used. The second + parameter can either be a string containing some login information + or an array containing a bunch of options for the storage driver. + </para> + <para> + The third parameter is the name of user-defined function that + prints the login screen. The last parameter can be either true + or false and defines if the login is optional or not. + </para> + + <example> + <title>Using different DB parameters</title> + <programlisting role="php"> require_once "Auth/Auth.php"; function myOutput($username, $status) @@ -243,121 +243,121 @@ if ($a->getAuth()) { echo "You have been authenticated successfully."; } - </programlisting> - </example> - - <para> - This example shows you, how you can specify alternative - names for the database table and the column names. In our - example, we use the table myAuth, select the username from - the field myUserColumn and the password from the field - myPasswordColumn. The Default values for this fields are - auth, username and password. - </para> - <para> - This feature is necessary if you want to use PEAR::Auth - with a database layout that is different from the one, - PEAR::Auth uses by default. - </para> - </refsect1> - - <refsect1 id="packages.Auth.Auth.start"> - <title>Auth::start</title> - <funcsynopsis> - <funcprototype> - <funcdef><function>Auth::start</function></funcdef> - <paramdef></paramdef> - </funcprototype> - </funcsynopsis> - - <para> - Start the authentication process. - </para> - </refsect1> - - <refsect1 id="packages.Auth.Auth.getAuth"> - <title>Auth::getAuth</title> - - <funcsynopsis> - <funcprototype> - <funcdef>boolean <function>Auth::getAuth</function></funcdef> - <paramdef></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Check if the user has been authenticated. - </para> - <para> - If the user has already been authenticated, the function returns - true. Otherwise it returns false. - </para> - <para> - For usage example, see <function>Auth::Auth</function>. - </para> - </refsect1> + </programlisting> + </example> - <refsect1 id="packages.Auth.Auth.setSessionname"> - <title>Auth::setSessionname</title> - - <funcsynopsis> - <funcprototype> - <funcdef>void <function>setSessionname</function></funcdef> - <paramdef>string <parameter>name</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - This function can set a customized name for the session that is - created during the login process. The default for this session - name is "PHPSESSID". You have to use <function>setSessionname</function>, - if you are running two or more different applications with Auth - on the same domain. If you don't use this function, a user who has - once logged in at one of the applications can also use the other - applications without logging in again! - </simpara> - </refsect1> - - <refsect1 id="packages.Auth.Auth.setExpire"> - <title>Auth::setExpire</title> - <funcsynopsis> - <funcprototype> - <funcdef>void <function>setExpire</function></funcdef> - <paramdef>int <parameter>time</parameter></paramdef> - <paramdef>bool <parameter><optional>add</optional></parameter></paramdef> - </funcprototype> - </funcsynopsis> - - <simpara> - With this function you can set the maximum expire time that is - used by auth to a new value. The first parameter <parameter>$time - </parameter> defines the number of seconds. If the second - parameter <parameter>$add</parameter> is true, the first parameter - is added on the existing expire time. If it is false (which is - also the default value), the first parameter replaces the existing - time. - </simpara> - </refsect1> - - <refsect1 id="packages.Auth.Auth.getStatus"> - <title>Auth::getStatus</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>getStatus</function></funcdef> + <para> + This example shows you, how you can specify alternative + names for the database table and the column names. In our + example, we use the table myAuth, select the username from + the field myUserColumn and the password from the field + myPasswordColumn. The Default values for this fields are + auth, username and password. + </para> + <para> + This feature is necessary if you want to use PEAR::Auth + with a database layout that is different from the one, + PEAR::Auth uses by default. + </para> + </refsect1> + + <refsect1 id="packages.Auth.Auth.start"> + <title>Auth::start</title> + <funcsynopsis> + <funcprototype> + <funcdef><function>Auth::start</function></funcdef> <paramdef></paramdef> - </funcprototype> - </funcsynopsis> + </funcprototype> + </funcsynopsis> - <simpara> - This function returns the current status of PEAR::Auth. The return - values are constants that are defined by PEAR Auth. <constant> + <para> + Start the authentication process. + </para> + </refsect1> + + <refsect1 id="packages.Auth.Auth.getAuth"> + <title>Auth::getAuth</title> + + <funcsynopsis> + <funcprototype> + <funcdef>boolean <function>Auth::getAuth</function></funcdef> + <paramdef></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Check if the user has been authenticated. + </para> + <para> + If the user has already been authenticated, the function returns + true. Otherwise it returns false. + </para> + <para> + For usage example, see <function>Auth::Auth</function>. + </para> + </refsect1> + + <refsect1 id="packages.Auth.Auth.setSessionname"> + <title>Auth::setSessionname</title> + + <funcsynopsis> + <funcprototype> + <funcdef>void <function>setSessionname</function></funcdef> + <paramdef>string <parameter>name</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + This function can set a customized name for the session that is + created during the login process. The default for this session + name is "PHPSESSID". You have to use <function>setSessionname</function>, + if you are running two or more different applications with Auth + on the same domain. If you don't use this function, a user who has + once logged in at one of the applications can also use the other + applications without logging in again! + </simpara> + </refsect1> + + <refsect1 id="packages.Auth.Auth.setExpire"> + <title>Auth::setExpire</title> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>setExpire</function></funcdef> + <paramdef>int <parameter>time</parameter></paramdef> + <paramdef>bool <parameter><optional>add</optional></parameter></paramdef> + </funcprototype> + </funcsynopsis> + + <simpara> + With this function you can set the maximum expire time that is + used by auth to a new value. The first parameter <parameter>$time + </parameter> defines the number of seconds. If the second + parameter <parameter>$add</parameter> is true, the first parameter + is added on the existing expire time. If it is false (which is + also the default value), the first parameter replaces the existing + time. + </simpara> + </refsect1> + + <refsect1 id="packages.Auth.Auth.getStatus"> + <title>Auth::getStatus</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>getStatus</function></funcdef> + <paramdef></paramdef> + </funcprototype> + </funcsynopsis> + + <simpara> + This function returns the current status of PEAR::Auth. The return + values are constants that are defined by PEAR Auth. <constant> AUTH_IDLED</constant> means that the maximum idle time has been - reached. <constant>AUTH_EXPIRED</constant> means that the maximum - expire time has been reached and <constant>AUTH_WRONG_LOGIN - </constant> means that the user has entered wrong login data in - the login form. - </simpara> - </refsect1> + reached. <constant>AUTH_EXPIRED</constant> means that the maximum + expire time has been reached and <constant>AUTH_WRONG_LOGIN + </constant> means that the user has entered wrong login data in + the login form. + </simpara> + </refsect1> - </refentry> +</refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml
« previous php.pear.cvs (#7276) next »