|
@@ -8,50 +8,50 @@
|
|
|
<title>Einführung in die Authentifizierung</title>
|
|
<title>Einführung in die Authentifizierung</title>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Sobald eine Web Anwendung
|
|
|
|
|
- Once a web application has been able to distinguish one user from another by
|
|
|
|
|
- establishing a session, web applications typically want to validate the identity
|
|
|
|
|
- of a user. The process of validating a consumer as being authentic is "authentication."
|
|
|
|
|
- Authentication is made up of two distinctive parts: an identity and a set of
|
|
|
|
|
- credentials. It takes some variation of both presented to the application for
|
|
|
|
|
- processing so that it may authenticate a user.
|
|
|
|
|
|
|
+ Sobald eine Web Anwendung in der Lage ist Benutzer von anderen Benutzern zu
|
|
|
|
|
+ unterscheiden, indem eine Session aufgebaut wird, prüfen Web Anwendungen normalerweise
|
|
|
|
|
+ die Identität eines Benutzers. Der Prozess der Prüfung eines Konsumenten als authentisch
|
|
|
|
|
+ wird als "Authentifizierung" bezeichnet. Authentifizierung besteht auf zwei getrennten
|
|
|
|
|
+ Teilen: Einer Identität und einem Set von Zeugnissen. Es muss eine Variation von
|
|
|
|
|
+ beidem in der Anwendung für die Bearbeitung vorhanden sein damit diese einen Benutzer
|
|
|
|
|
+ authentifizieren kann.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- While the most common pattern of authentication revolves around usernames and
|
|
|
|
|
- passwords, it should be stated that this is not always the case. Identities are
|
|
|
|
|
- not limited to usernames. In fact, any public identifier can be used: an assigned
|
|
|
|
|
- number, social security number, or residence address. Likewise, credentials are not
|
|
|
|
|
- limited to passwords. Credentials can come in the form of protected private
|
|
|
|
|
- information: fingerprint, eye retinal scan, passphrase, or any other obscure personal
|
|
|
|
|
- information.
|
|
|
|
|
|
|
+ Wärend die meisten üblichen Pattern der Authentifizierung um Benutzernamen und
|
|
|
|
|
+ Passwörtern dreht, sollte erwähnt werden das dies nicht immer der Fall ist. Identitäten
|
|
|
|
|
+ sind nicht auf Benutzernamen limitiert. Faktisch kann jeder öffentliche Identifikator
|
|
|
|
|
+ verwendet werden: eine zugeordnete Nummer, Sozialversicherungsnummer, oder eine
|
|
|
|
|
+ Wohnanschrift. Genauso sind Zeugnisse nicht auf Passwörter begrenzt. Zeugnisse können
|
|
|
|
|
+ in Form von geschützten privaten Informationen kommen: Fingerabdrücke, Augen Retinascan,
|
|
|
|
|
+ Passphrase, oder jede andere obskure personelle Information.
|
|
|
</para>
|
|
</para>
|
|
|
-
|
|
|
|
|
</sect2>
|
|
</sect2>
|
|
|
|
|
|
|
|
<sect2 id="learning.multiuser.authentication.basic-usage">
|
|
<sect2 id="learning.multiuser.authentication.basic-usage">
|
|
|
- <title>Basic Usage of Zend_Auth</title>
|
|
|
|
|
|
|
+ <title>Grundsätzliche Verwendung von Zend_Auth</title>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- In the following example, we will be using <classname>Zend_Auth</classname> to
|
|
|
|
|
- complete what is probably the most prolific form of authentication: username and
|
|
|
|
|
- password from a database table. This example assumes that you have already setup your
|
|
|
|
|
- application using <classname>Zend_Application</classname>, and that inside that
|
|
|
|
|
- application you have configured a database connection.
|
|
|
|
|
|
|
+ Im folgenden Beispiel verwenden wir <classname>Zend_Auth</classname> um zu komplettieren
|
|
|
|
|
+ was möglicherweise die meist gelebte Form der Authentifizierung ist: Benutzername und
|
|
|
|
|
+ Passwort von einer Datenbank Tabelle. Dieses Beispiel nimmt an dass man die eigene
|
|
|
|
|
+ Anwendung bereits durch Verwendung von <classname>Zend_Application</classname>
|
|
|
|
|
+ eingerichtet hat, und das man in der Anwendung eine Datenbank Verbindung konfiguriert
|
|
|
|
|
+ hat.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- The job of the <classname>Zend_Auth</classname> class is twofold. First, it should
|
|
|
|
|
- be able to accept an authentication adapter to use to authenticate a user. Secondly,
|
|
|
|
|
- after a successful authentication of a user, it should persist throughout each and
|
|
|
|
|
- every request that might need to know if the current user has indeed been
|
|
|
|
|
- authenticated. To persist this data, <classname>Zend_Auth</classname> consumes
|
|
|
|
|
- <classname>Zend_Session_Namespace</classname>, but you will generally never need
|
|
|
|
|
- to interact with this session object.
|
|
|
|
|
|
|
+ Der Job der <classname>Zend_Auth</classname> Klasse ist zweigeteilt. Erstens sollte Sie
|
|
|
|
|
+ in der Lage sein einen Authentifizierungs Adapter zu akzeptieren um einen Benutzer zu
|
|
|
|
|
+ authentifizieren. Zweitens sollte Sie, nach einer erfolgreichen Authentifizierung eines
|
|
|
|
|
+ Benutzers, durch jede und alle Abfragen persistent sein welche wissen müssen ob der
|
|
|
|
|
+ aktuelle Benutzer authentifiziert wurde. Um diese Daten zu persistieren verwendet
|
|
|
|
|
+ <classname>Zend_Auth</classname> <classname>Zend_Session_Namespace</classname>, man muss
|
|
|
|
|
+ aber generell nie mit diesem Session Objekt interagieren.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Lets assume we have the following database table setup:
|
|
|
|
|
|
|
+ Angenommen wir haben die folgende Datenbanktabelle konfiguriert:
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
@@ -65,21 +65,23 @@ CREATE TABLE users (
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- The above demonstrates a user table that includes a username, password, and also a
|
|
|
|
|
- password salt column. This salt column is used as part of a technique called salting
|
|
|
|
|
- that would improve the security of your database of information against brute force
|
|
|
|
|
- attacks targeting the algorithm of your password hashing. <ulink
|
|
|
|
|
- url="http://en.wikipedia.org/wiki/Salting_%28cryptography%29">More
|
|
|
|
|
- information</ulink> on salting.
|
|
|
|
|
|
|
+ Das oben stehende demonstriert eine Benutzertabelle welche einen Benutzernamen, ein
|
|
|
|
|
+ Passwort und auch eine Passwort Salt Spalte enthält. Diese Salt Spalte wird als Teil
|
|
|
|
|
+ einer Technik verwendet welche Salting genannt wird und die Sicherheit der Datenbank
|
|
|
|
|
+ für Informationen gegen Brute Force Attacken erhöht welche auf den Algorithmus des
|
|
|
|
|
+ Hashings vom Passwort abziehlt. <ulink
|
|
|
|
|
+ url="http://en.wikipedia.org/wiki/Salting_%28cryptography%29">Weitere
|
|
|
|
|
+ Informationen</ulink> über Salting.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- For this implementation, we must first make a simple form that we can utilized as
|
|
|
|
|
- the "login form". We will use <classname>Zend_Form</classname> to accomplish this.
|
|
|
|
|
|
|
+ Für diese Implementation müssen wir zuerst ein einfaches Formular erstellen welches
|
|
|
|
|
+ wir als "Login Formular" verwenden können. Wir nehmen <classname>Zend_Form</classname>
|
|
|
|
|
+ um das zu ermöglichen.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
|
-// located at application/forms/Auth/Login.php
|
|
|
|
|
|
|
+// Steht unter application/forms/Auth/Login.php
|
|
|
|
|
|
|
|
class Default_Form_Auth_Login extends Zend_Form
|
|
class Default_Form_Auth_Login extends Zend_Form
|
|
|
{
|
|
{
|
|
@@ -95,7 +97,7 @@ class Default_Form_Auth_Login extends Zend_Form
|
|
|
));
|
|
));
|
|
|
|
|
|
|
|
$this->addElement('password', 'password', array(
|
|
$this->addElement('password', 'password', array(
|
|
|
- 'label' => 'Password:',
|
|
|
|
|
|
|
+ 'label' => 'Passwort:',
|
|
|
'required' => true,
|
|
'required' => true,
|
|
|
));
|
|
));
|
|
|
|
|
|
|
@@ -109,18 +111,18 @@ class Default_Form_Auth_Login extends Zend_Form
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- With the above form, we can now go about creating our login action for
|
|
|
|
|
- our authentication controller. This controller will be called
|
|
|
|
|
- "<classname>AuthController</classname>", and will be located at
|
|
|
|
|
- <filename>application/controllers/AuthController.php</filename>. It will have a
|
|
|
|
|
- single method called "<methodname>loginAction()</methodname>" which will serve as the
|
|
|
|
|
- self-posting action. In other words, regardless of the url was POSTed to or GETed
|
|
|
|
|
- to, this method will handle the logic.
|
|
|
|
|
|
|
+ Mit dem oben stehenden Formular können wir weitermachen und unsere Login Aktion für
|
|
|
|
|
+ unseren Authentifizierungs Controller erstellen. Dieser Controller wird
|
|
|
|
|
+ "<classname>AuthController</classname>" genannt, und wird unter
|
|
|
|
|
+ <filename>application/controllers/AuthController.php</filename> zu finden sein. Er wird
|
|
|
|
|
+ eine einzelne Methode enthalten welche "<methodname>loginAction()</methodname>" heißt
|
|
|
|
|
+ und als selbst-übermittelnde Aktion fungiert. In anderen Worten, unabhängig davon ob
|
|
|
|
|
+ die Url mit POST oder mit GET geschickt wurde, wird diese Methode die Logik behandeln.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- The following code will demonstrate how to construct the proper adapter, integrate it
|
|
|
|
|
- with the form:
|
|
|
|
|
|
|
+ Der folgende Code demonstriert wie die richtigen Adapter erstellt und in das Formular
|
|
|
|
|
+ integriert werden:
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
@@ -149,7 +151,7 @@ class AuthController extends Zend_Controller_Action
|
|
|
$result = $auth->authenticate($adapter);
|
|
$result = $auth->authenticate($adapter);
|
|
|
|
|
|
|
|
if ($result->isValid()) {
|
|
if ($result->isValid()) {
|
|
|
- $this->_helper->FlashMessenger('Successful Login');
|
|
|
|
|
|
|
+ $this->_helper->FlashMessenger('Erfolgreich angemeldet');
|
|
|
$this->redirect('/');
|
|
$this->redirect('/');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -164,9 +166,10 @@ class AuthController extends Zend_Controller_Action
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- The corresponding view script is quite simple for this action. It will set the current
|
|
|
|
|
- url since this form is self processing, and it will display the form. This view script
|
|
|
|
|
- is located at <filename>application/views/scripts/auth/login.phtml</filename>:
|
|
|
|
|
|
|
+ Das entsprechende View Skript ist für diese Aktion recht einfach. Es setzt die aktuelle
|
|
|
|
|
+ Url da dieses Formular selbst bearbeitend ist, und zeigt das Formular an. Dieses View
|
|
|
|
|
+ Skript ist unter <filename>application/views/scripts/auth/login.phtml</filename> zu
|
|
|
|
|
+ finden:
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
@@ -175,11 +178,10 @@ echo $this->form;
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- There you have it. With these basics you can expand the general concepts to include
|
|
|
|
|
- more complex authentication scenarios. For more information on other
|
|
|
|
|
- <classname>Zend_Auth</classname> adapters, have a look in
|
|
|
|
|
- <link linkend="zend.auth">the reference guide</link>.
|
|
|
|
|
|
|
+ Das ist es. Mit diesen Grundsätzen kann man die generellen Konzepte erweitern um
|
|
|
|
|
+ komplexere Authentifizierungs Szenarien zu inkludieren. Für mehr Informationen über
|
|
|
|
|
+ andere <classname>Zend_Auth</classname> Adapter sollte in <link
|
|
|
|
|
+ linkend="zend.auth">das Referenz Handbuch</link> gesehen werden.
|
|
|
</para>
|
|
</para>
|
|
|
</sect2>
|
|
</sect2>
|
|
|
</sect1>
|
|
</sect1>
|
|
|
-
|
|
|