Implements openid
authorclebeaupin
Wed, 24 Mar 2010 19:04:36 +0100
changeset 26 4427c90bd892
parent 25 31cc2136a768
child 27 ec2d5a70a75e
child 28 7de8d597588b
Implements openid
web/thdProject/apps/frontend/config/app.yml.tmpl
web/thdProject/apps/frontend/config/routing.yml
web/thdProject/apps/frontend/config/security.yml
web/thdProject/apps/frontend/config/settings.yml
web/thdProject/apps/frontend/lib/myUser.class.php
web/thdProject/apps/frontend/modules/account/actions/loginUserAction.class.php
web/thdProject/apps/frontend/modules/account/actions/logoutUserAction.class.php
web/thdProject/apps/frontend/modules/account/actions/openidLoginAction.class.php
web/thdProject/apps/frontend/modules/account/config/security.yml
web/thdProject/apps/frontend/modules/account/templates/_loginUserForm.php
web/thdProject/apps/frontend/modules/account/templates/_loginUserFormHeader.php
web/thdProject/apps/frontend/modules/account/templates/_registerUserForm.php
web/thdProject/apps/frontend/modules/account/templates/loginUserForm.php
web/thdProject/apps/frontend/modules/editor/templates/_player.php
web/thdProject/apps/frontend/modules/homepage/actions/components.class.php
web/thdProject/apps/frontend/modules/homepage/config/view.yml
web/thdProject/apps/frontend/modules/homepage/templates/_lastTaggedList.php
web/thdProject/apps/frontend/modules/homepage/templates/_leftPanel.php
web/thdProject/apps/frontend/modules/homepage/templates/_randomFilm.php
web/thdProject/apps/frontend/modules/homepage/templates/_sideBar.php
web/thdProject/apps/frontend/modules/homepage/templates/indexSuccess.php
web/thdProject/apps/frontend/modules/partials/actions/components.class.php
web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php
web/thdProject/apps/frontend/templates/layout.php
web/thdProject/lib/actions/openidAction.class.php
web/thdProject/plugins/sfPHPOpenIdPlugin/CHANGELOG
web/thdProject/plugins/sfPHPOpenIdPlugin/LICENSE
web/thdProject/plugins/sfPHPOpenIdPlugin/README
web/thdProject/plugins/sfPHPOpenIdPlugin/lib/BasesfPHPOpenIDAuthActions.class.php
web/thdProject/plugins/sfPHPOpenIdPlugin/lib/sfPHPOpenID.class.php
web/thdProject/plugins/sfPHPOpenIdPlugin/lib/validator/sfPHPOpenIdValidator.class.php
--- a/web/thdProject/apps/frontend/config/app.yml.tmpl	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/config/app.yml.tmpl	Wed Mar 24 19:04:36 2010 +0100
@@ -7,5 +7,9 @@
     
    player:
      videoPath: "http://localhost/thd/web/videos/"
+     
+   openid:
+     service_uri: "http://atalante.ucopenid/index.php"
+     fake: true
 
 #dev:
--- a/web/thdProject/apps/frontend/config/routing.yml	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/config/routing.yml	Wed Mar 24 19:04:36 2010 +0100
@@ -11,11 +11,10 @@
   url: /deconnexion
   param: { module: account, action: logoutUser}
 
-registerUser:
-  url: /inscription
-  param: { module: account, action: registerUser}
- 
- 
+openidLogin:
+  url: /open-id/connexion
+  param: { module: account, action: openidLogin}
+
 ########  
 #SEGMENT EDITOR
 ########  
--- a/web/thdProject/apps/frontend/config/security.yml	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/config/security.yml	Wed Mar 24 19:04:36 2010 +0100
@@ -1,2 +1,2 @@
 default:
-  is_secure: off
+  is_secure: on
--- a/web/thdProject/apps/frontend/config/settings.yml	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/config/settings.yml	Wed Mar 24 19:04:36 2010 +0100
@@ -28,6 +28,12 @@
     escaping_strategy:      false            # Determines how variables are made available to templates. Accepted values: on, off.
     escaping_method:        ESC_SPECIALCHARS # Function or helper used for escaping. Accepted values: ESC_RAW, ESC_ENTITIES, ESC_JS, ESC_JS_NO_ENTITIES, and ESC_SPECIALCHARS.
     standard_helpers:       [Partial, Cache, Form, ThdHtml]
+    
+    login_module:           account
+    login_action:           loginUser
+
+    secure_module:          account   # To be called when a user doesn't have
+    secure_action:          loginUser    # The credentials required for an action
 
 #all:
 #  .actions:
--- a/web/thdProject/apps/frontend/lib/myUser.class.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/lib/myUser.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -1,5 +1,22 @@
 <?php
 
-class myUser extends sfBasicSecurityUser
-{
+class myUser extends sfBasicSecurityUser {
+
+  public function login($identity) {
+    $this->setAuthenticated(true);
+
+    // Store identity in a cookie
+    if (!is_null($identity)) {
+      sfContext::getInstance()->getResponse()->setCookie('openid_identity', $identity);
+    }
+  }
+
+  public function logout() {
+    $this->clearCredentials();
+    $this->setAuthenticated(false);
+  }
+
+  public function getIdentity() {
+    return sfContext::getInstance()->getRequest()->getCookie('openid_identity', null);
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/actions/loginUserAction.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,23 @@
+<?php
+
+class loginUserAction extends openidAction {
+
+  public function execute($request) {
+    if ($request->isMethod('post')) {
+      if (sfConfig::get('app_openid_fake') === true) {
+        $user = $this->getUser();
+        $user->login(null);
+        return $this->redirect('@homepage');
+      } else {
+        // Get openid object
+        $openid = $this->getOpenIdObject();
+
+        // Redirect to open id provider
+        $redirectUrl = $openid->getRedirectURL(false);
+        return $this->redirect($redirectUrl['content']);
+      }
+    }
+
+  	return "Form";
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/actions/logoutUserAction.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,9 @@
+<?php
+
+class logoutUserAction extends sfAction
+{
+  public function execute($request) {
+    $this->getUser()->logout();
+    return $this->redirect('@homepage');
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/actions/openidLoginAction.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,22 @@
+<?php
+
+class openidLoginAction extends openidAction {
+
+  public function execute($request) {
+    // Get openid object
+    $openid = $this->getOpenIdObject();
+
+    // Check authentication validity
+    $authResult = $openid->getAuthResult();
+    $user = $this->getUser();
+
+    if ($authResult['result'] == sfPHPOpenID::AUTH_SUCCESS) {
+      // User is authenticated by open id provider
+      $user->login($authResult['identity']);
+    } else {
+      $user->setFlash('login_error', 'Authentification échoué');
+    }
+
+    return $this->redirect('@homepage');
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/config/security.yml	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,5 @@
+loginUser:
+  is_secure: off
+  
+openidLogin:
+  is_secure: off
--- a/web/thdProject/apps/frontend/modules/account/templates/_loginUserForm.php	Wed Mar 24 17:25:25 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-<form class="table-form<?php if (isset($classes)) echo ' '.$classes; ?>" method="post" action="<?php echo url_for('@loginUser')?>">
-  <?php if($sf_user->hasFlash('login_error')): ?>
-    <div class="form-error">
-      Votre email et/ou votre mot de passe sont incorrects.
-      <br />
-      Vérifiez vos informations de connexion et connectez-vous à nouveau.
-    </div>
-  <?php endif;?>
-  <div class="field required">
-    <label for="login[email]"><?php echo __('form_label_email');?><sup class="required">*</sup></label>
-    <input type="text" name="login[email]" />
-  </div>
-
-  <div class="field required">
-    <label for="login[password]"><?php echo __('form_label_password');?><sup class="required">*</sup></label>
-    <input type="password" name="login[password]" />
-  </div>
-
-  <?php if (isset($serializedOriginRequest)) echo uc_render_hidden_fields($serializedOriginRequest); ?>
-
-  <div class="buttons">
-    <?php echo uc_render_submit_button('Validez'); ?>
-  </div>
-</form>
--- a/web/thdProject/apps/frontend/modules/account/templates/_loginUserFormHeader.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/account/templates/_loginUserFormHeader.php	Wed Mar 24 19:04:36 2010 +0100
@@ -1,16 +0,0 @@
-<form class="table-form<?php if (isset($classes)) echo ' '.$classes; ?>" method="post" action="<?php echo url_for('@loginUser')?>">
-  <span class="head">Bienvenue sur UniversCine THD</span>
-  <?php if($sf_user->hasFlash('login_error')): ?>
-    <div class="form-error">
-      Votre email et/ou votre mot de passe sont incorrects.
-    </div>
-  <?php endif;?>
-  <ul>
-  	<li><a href="" class="link-action">Mon compte</a></li>
-  	<li><a href=""class ="link-action">Mes tags</a></li>
-  </ul>
- <div class="buttons">
-    <?php echo uc_render_submit_button('se déconnecter'); ?>
-  </div>  
-</form>
-
--- a/web/thdProject/apps/frontend/modules/account/templates/_registerUserForm.php	Wed Mar 24 17:25:25 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<div id="register">
-	<div class="head"><h3>Pas encore inscrit ?</div>
-	<div class="infos">Bienvenue dans le projet UniversCiné THD.<br/><br/>Ce site entre dans le cadre d'un projet de recherche sur le très haut débit réunissant trois acteurs autour de ce site :<br/><a href="http://www.universcine.com">UniversCiné</a>, <a href="http://ww.iri.centrepompidou.com">l'iri</a>, <a href="http://www.csl.sony.fr">Sony CSL</a> et <a href="http://www.capdigital.com">Cap digital</a></div>
-	<div class="access">
-		<div class="buttons">
-		    <?php echo uc_render_submit_button('Accéder au service'); ?>
-		 </div>  
-	</div>	
-</div>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/account/templates/loginUserForm.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,11 @@
+<div id="register">
+  <div class="head"><h3>Pas encore inscrit ?</div>
+  <div class="infos">Bienvenue dans le projet UniversCiné THD.<br/><br/>Ce site entre dans le cadre d'un projet de recherche sur le très haut débit réunissant trois acteurs autour de ce site :<br/><a href="http://www.universcine.com">UniversCiné</a>, <a href="http://ww.iri.centrepompidou.com">l'iri</a>, <a href="http://www.csl.sony.fr">Sony CSL</a> et <a href="http://www.capdigital.com">Cap digital</a></div>
+  <div class="access">
+    <form action="<?php echo url_for('@loginUser'); ?>" method="post">
+      <div class="buttons">
+        <?php echo uc_render_submit_button('Accéder au service'); ?>
+      </div>
+    </form>
+  </div>
+</div>
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/editor/templates/_player.php	Wed Mar 24 19:04:36 2010 +0100
@@ -1,6 +1,6 @@
 <script type="text/javascript">
     // Charge le player
-    flowplayer("player", "<?php echo flash_path('/flashes/flowplayer-3.1.2.swf') ?>",
+    flowplayer("player", "<?php echo flash_path('flowplayer-3.1.2.swf') ?>",
                {
                    clip: {url: "<?php echo video_path($filmVideo['file']); ?>",
                           autoPlay: false,
@@ -12,7 +12,7 @@
 
                    plugins: {
 
-                       content: {url: "<?php echo flash_path('/flashes/flowplayer.content-3.1.0.swf') ?>",
+                       content: {url: "<?php echo flash_path('flowplayer.content-3.1.0.swf') ?>",
                                  backgroundColor: 'transparent',
                                  display: 'none',
                                  style: {p: {fontSize: 15}}
--- a/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/actions/components.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -2,7 +2,7 @@
 
 class homepageComponents extends sfComponents
 {
-  public function executeLeftPanel() {
+  public function executeSideBar() {
 
   }
   public function executeSearch() {
--- a/web/thdProject/apps/frontend/modules/homepage/config/view.yml	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/config/view.yml	Wed Mar 24 19:04:36 2010 +0100
@@ -1,5 +1,4 @@
 all:
-  
   stylesheets:    [ /css/flashplayer.css ]
 
   javascripts:   [ /js/flowplayer/flowplayer-3.1.0.min.js, /js/flowplayer/uc.flowplayer.config.js]
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/homepage/templates/_lastTaggedList.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/templates/_lastTaggedList.php	Wed Mar 24 19:04:36 2010 +0100
@@ -17,7 +17,7 @@
 			<div class="infos">
 		    	<a href="<?php echo url_for('@editor?ref='.$ref.'&film_slug='.$slug); ?>" class="title" target="_top"><?php echo $title; ?></a> <span class="film-infos">De <?php echo thd_render_flat_list($item->getDirectors(), 'name'); ?></span>
 		    </div>
-		    <img src="images/buttons/btn_play.png"/ id="play"></a>
+		    <img src="<?php echo image_path('images/buttons/btn_play.png'); ?>"/ id="play"></a>
 		     <div class="tags">
 				<ul class="item-list tag-list">
 				<li><span class="head">
--- a/web/thdProject/apps/frontend/modules/homepage/templates/_leftPanel.php	Wed Mar 24 17:25:25 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-<?php include_component( "homepage", "search" ) ?>
-<?php include_component( "homepage", "tagList" ) ?>
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/homepage/templates/_randomFilm.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/templates/_randomFilm.php	Wed Mar 24 19:04:36 2010 +0100
@@ -2,7 +2,7 @@
 <script>
 function launchSelected(video) {
 	  var video = video;
-	  $f("player-ba", "flashes/flowplayer-3.1.0.swf", {
+	  $f("player-ba", "<?php echo flash_path('flowplayer-3.1.0.swf') ?>", {
 			// configuration for a clip
 			clip: {
 				autoPlay: true,
@@ -19,12 +19,12 @@
 	}
 </script>
   	<h3 class="head">Regardez et annotez des extraits :</h3>
-	<div id="player-ba" class="player-ba" style="background:transparent url('images/test/anna_m/capt720.jpg') no-repeat;">
+	<div id="player-ba" class="player-ba" style="background:transparent url(<?php echo image_path('test/anna_m/capt720.jpg'); ?>) no-repeat;">
 		<div class="infos">
 	    	<a href="http://embryon/videos/001009_l-humanite.f4v" onclick="launchSelected(this.href);return false;" class="title">Anna M</a><br/><span class="film-infos">De <b>Michel Spinosa</b></span>
 	    </div>
 	    <div id="play">
-			<a href="http://embryon/videos/001009_l-humanite.f4v" onclick="launchSelected(this.href);return false;"><img src="images/buttons/btn_play.png"/></a>
+			<a href="http://embryon/videos/001009_l-humanite.f4v" onclick="launchSelected(this.href);return false;"><img src="<?php echo image_path('buttons/btn_play.png') ?>"/></a>
 	    </div>
 	     <div class="tags">
 	    	<span class="head">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/apps/frontend/modules/homepage/templates/_sideBar.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,2 @@
+<?php include_component( "homepage", "search" ) ?>
+<?php include_component( "homepage", "tagList" ) ?>
\ No newline at end of file
--- a/web/thdProject/apps/frontend/modules/homepage/templates/indexSuccess.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/homepage/templates/indexSuccess.php	Wed Mar 24 19:04:36 2010 +0100
@@ -1,18 +1,7 @@
-
 <div id="homepage">
-	<?php include_partial('partials/navigation')?>
-	<div id="document-sidebar">
-		<?php include_component( "homepage", "leftPanel" ) ?>
-	</div>
-	
-	<div id="document">
-	<?php include_component( "account", "registerUserForm" ) ?>
-	</div>
-	<!--<div id="document">
-		<?php include_component( "homepage", "randomFilm" ) ?>
-		<?php include_component( "homepage", "lastTaggedList") ?>
-		<?php include_component( "homepage", "mostTaggedList" ) ?>		
-	</div>-->
+  <?php include_component( "homepage", "randomFilm" ) ?>
+	<?php include_component( "homepage", "lastTaggedList") ?>
+	<?php include_component( "homepage", "mostTaggedList" ) ?>
 </div>
 <script language="JavaScript">
 	// a very simple setup
--- a/web/thdProject/apps/frontend/modules/partials/actions/components.class.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/partials/actions/components.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -2,9 +2,15 @@
 <?php
 
 class partialsComponents extends sfComponents {
-  
+
   public function executeUserPanel() {
+    $this->user = $this->getUser();
+    if (!$this->user->isAuthenticated()) return sfView::NONE;
+  }
 
+  public function executeNavigation() {
+    $this->user = $this->getUser();
+    if (!$this->user->isAuthenticated()) return sfView::NONE;
   }
-  
+
 }
--- a/web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/modules/partials/templates/_userPanel.php	Wed Mar 24 19:04:36 2010 +0100
@@ -1,11 +1,14 @@
 <div id="header-user">
-  <div class="main"> 
-    <div class="login">
-      <?php include_partial('account/loginUserFormHeader', Array('classes' => 'ajax')); ?>
-    </div>    
-    <div class="retrieve-password">
-      <a href="<?php echo url_for('@loginUser'); ?>">Mot de passe oublié ?</a>
+  <div class="main">
+  <form class="table-form<?php if (isset($classes)) echo ' '.$classes; ?>" method="post" action="<?php echo url_for('@logoutUser')?>">
+    <span class="head">Bienvenue sur UniversCine THD</span>
+    <ul>
+      <li><a href="" class="link-action">Mon compte</a></li>
+      <li><a href=""class ="link-action">Mes tags</a></li>
+    </ul>
+    <div class="buttons">
+      <?php echo uc_render_submit_button('se déconnecter'); ?>
     </div>
+  </form>
   </div>
-  
 </div>
\ No newline at end of file
--- a/web/thdProject/apps/frontend/templates/layout.php	Wed Mar 24 17:25:25 2010 +0100
+++ b/web/thdProject/apps/frontend/templates/layout.php	Wed Mar 24 19:04:36 2010 +0100
@@ -1,27 +1,41 @@
+<?php
+$hasSideBar = has_component_slot('sideBar');
+?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <?php include_http_metas() ?>
     <?php include_metas() ?>
-    <?php include_title() ?>    
+    <?php include_title() ?>
     <link rel="shortcut icon" href="/favicon.ico" />
   </head>
   <body>
-  	<div id="global-wrapper">
-  		<!--HEADER-->
-        <div id="header">
-        <?php include_component('partials', 'userPanel'); ?>
-		<?php include_partial('partials/header')?>
-		</div>
-   		<!--HEADER END-->
-   		<!--BODY-->
-    	<?php echo $sf_content ?>
-    	<!--BODY END-->
-    	<!--FOOTER-->
-    	<div id="footer">
-    	<?php include_partial('partials/footer')?>
-    	</div>
-    	<!--FOOTER END-->
+    <div id="global-wrapper">
+      <div id="global">
+        <div id="page-wrapper">
+          <div id="page">
+            <div id="header">
+              <?php include_component('partials', 'userPanel'); ?>
+              <?php include_partial('partials/header')?>
+              <?php include_component('partials', 'navigation'); ?>
+            </div>
+            <div id="content-wrapper"<?php if ($hasSideBar) echo ' class="sidebar"' ;?>>
+              <div id="content">
+                <?php echo $sf_content ?>
+              </div>
+              <?php if ($hasSideBar): ?>
+              <div id="sidebar">
+                <?php include_component_slot('sideBar'); ?>
+              </div>
+              <?php endif; ?>
+            </div>
+            <div id="footer">
+          	  <?php include_partial('partials/footer')?>
+            </div>
+            <!--FOOTER END-->
+          </div>
+        </div>
+      </div>
    	</div>
   </body>
 </html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/lib/actions/openidAction.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,25 @@
+<?php
+
+class openidAction extends sfAction {
+  public function execute($request) {
+
+  }
+
+  public function getOpenIdObject() {
+    // Instantiate openid
+    $identity = sfConfig::get('app_openid_service_uri');
+    $controller = $this->getController();
+    $openid = new sfPHPOpenID();
+    $openid->setIdentity($identity);
+
+    // Script which handles a response from OpenID Server
+    $processUrl = $controller->genUrl('@openidLogin', true);
+    $openid->setApprovedURL($processUrl);
+
+    // Url of website
+    $trustUrl = $controller->genUrl('@homepage', true);
+    $openid->SetTrustRoot($trustUrl);
+
+    return $openid;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/sfPHPOpenIdPlugin/CHANGELOG	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,10 @@
+v.1.1 (August 7th 2009)
+-Dropped dependance to sfCompat10Plugin. This is now a real Symfony 1.2 plugin.
+-Make it easier to customize 'authentication in progress' page.
+-Fixed a bug in AX data retrieving.
+-Few cleanups
+
+
+v.1.0 (April 2009)
+
+First release
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/sfPHPOpenIdPlugin/LICENSE	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,166 @@
+		   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/sfPHPOpenIdPlugin/README	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,233 @@
+sfPHPOpenIDPlugin symfony plugin
+================================
+
+Overview
+--------
+
+sfPHPOpenIDPlugin is a Symfony plugin which can be used by Symfony applications to authenticate users using OpenID system. With this plugin Symfony applications become OpenID consumer (or relying party).
+It uses the PHP OpenID library (http://openidenabled.com/php-openid) which brings support for OpenID 1.0 and 2.0 specifications with Simple Registration, Attribute Exchange and PAPE extensions.
+
+Based on sfPHPOpenIDExtPlugin v1.0.1.
+
+Changelog
+---------
+
+See the CHANGELOG file.
+
+License
+-------
+
+For the full copyright and license information, please view the LICENSE
+file that was distributed with this source code.
+
+Installation
+------------
+
+* Install the plugin
+
+    From Symfony official channel:
+
+        php symfony plugin:install  sfPHPOpenIdPlugin
+
+    or from a downloaded archive:
+
+        php symfony plugin:install /home/path/to/downloads/sfPHPOpenIdPlugin-1.1.0.tgz
+
+* You must tell to the plugin where is the lib. So edit the file /yourProject/apps/yourApp/config/app.yml and add the following lines:
+
+         all:
+           <other app specific data>
+           sf_phpopenid_plugin:
+             lib_path: %SF_ROOT_DIR%/lib/php-openid
+
+
+Don't forget to adapt the last line to your installation.
+
+Update instructions
+--------------------
+
+Version 1.1 introduces many changes in the code. So update from version 1.0 requires a bit of tweaking. Here are a few guidelines to help you.
+
+* There's no longer the need to enable sfPHPOpenIDAuth module. So remove the corresponding line in yourApp/config/settings.yml.
+
+* openid_signin and openid_autosignin routes and corresponding actions are no longer defined inside the plugin. Briefly, in v1.0, your OpenID form submitted data directly to openid_signin and the corresponding plugin action displayed a waiting message ('Authentication in progress') with HTML redirect code. Now, to allow customization of waiting message, the form needs to submit data to another action in your app. This action will call method getRedirectHtml($theOpenIDURL) which will return html redirect code that you need to include in whatever template you want. It is the same principle for autosignin. See below for more details.
+
+
+Using the plugin
+----------------
+
+The plugin define a special action class (BasesfPHPOpenIDAuthActions) that handles all the OpenID authentification steps.
+To use the plugin, you have to create a new module (let's call it authModule) in your app (yourApp). The action class of this module should inherit from the plugin class BasesfPHPOpenIDAuthActions: edit authModule/actions/actions.class.php so that it looks like in the following lines:
+
+    class mainActions extends BasesfPHPOpenIDAuthActions {
+	    // Some code
+    }
+
+The next steps will focus on modifying this action class.
+
+* Routing
+
+The plugin uses a few predefined routes to redirect the user during the authentication procedure. Your app must define these routes in yourApp/config/routing.yml.
+This is the list of needed routes: homepage, openid_finishauth and openid_error.
+Your routing file should look like this:
+
+    openid_finishauth:
+      url: /authModule/finish
+      param: { module: authModule, action: finish }
+    openid_error:
+      url: /authModule/openidError
+      param: { module: authModule, action: openidError }
+
+As you can see, these routes are binded to actions of authModule. So let's talk a bit about these actions.
+
+* Actions
+
+As said earlier, authModule's action class inherit from the class BasesfPHPOpenIDAuthActions.
+This base class already define one needed action: executeFinish().
+Most of the time you won't have to override this method unless you have specific needs.
+The action openidError is not defined in BasesfPHPOpenIDAuthActions, so you have to write it. This action will be called by the plugin when an error occurs while authenticating a user (wrong password, user cancelling). Here's an example of code you can write in this action:
+
+    public function executeOpenidError() {
+      $this->error = $this->getRequest() ->getErrors();
+    }
+
+You'll probably want to create a template for this action (openidErrorSuccess) to display the error message.
+
+Now that we're sure these actions are defined, we have to override another method: openIDCallback. These method is called when a user is successfully authenticated. This is the perfect place to do any action needed by your app (setting cookies, displaying welcome message).
+You have two choices for this action: you can forward or redirect to another action (go to the homepage for example). The other option is to let it return without any redirection. If you do so, you'll have to create a finishSuccess.php template in your authModule (because openIDCallback is in fact called by executeFinish action).
+Here's an example of openIDCallback code:
+
+    public function openIDCallback($openid_validation_result)
+    {
+      $this->getUser()->setAuthenticated(true);
+      sfContext::getInstance()->getResponse()->setCookie('known_openid_identity',$openid_validation_result['identity']);
+      $back = '@homepage';
+      $this->redirect($back);
+    }
+
+As you can see, the method is given an attribute ($openid_validation_result) containing information about the authenticated user. Its content is:
+
+    'result' => 'result code',
+    'message' => 'an optional message',
+    'identity' => 'the user's identity (http://misterx.myopenid.com)',
+    'userData' => 'array of user fields values ('fullname' => array('the fullname', 'another fullname'), 'email' => array('the email'), ...)'}
+    'PAPEResp' => 'a Auth_OpenID_PAPE_Response object (null if the provider didn't send a PAPE response)'
+
+
+* User interaction
+
+Now that we have defined the routing and actions, we must focus on the way to use it in our app. The classical workflow when using OpenID is to ask the user to fill a form with his OpenID (http://misterx.myopenidprovider.com for example). The user then submit the form. It gets redirect to his provider, tries to authenticate and gets back to the application.
+For the first step, just create a form wherever in your application. The form will submit the data to one of your app action.
+The plugin comes with an openID validator (sfPHPOpenIdValidator) to check openid urls. It takes no specific options and may throw 'invalid' or 'required' error messages.
+
+In the action where the form submit the OpenID URL, you have to call a plugin method named "getRedirectHtml". This method check the given OpenID and returns html code for redirection if the identity is valid. It takes the following arguments:
+
+    @param $identity     The OpenID the user want to login with
+    @param $immediate    Should this be an immediate login (ie provider should answer yes or no without showing any form, used for autosignin)
+    @param $submitLabel  The value of the submit button that will be displayed if javascript is disabled. Optional, default is 'Continue'.
+    @param $linkLabel    The label of the link that will be displayed if javascript is disabled. Optional, default is 'Click here to continue login with OpenID.'.
+    @param $linkAttrs    An array of attributes of the link that will be displayed if javascript is disabled. Optional.
+
+And it returns the following value:
+
+    array(
+         'success' => true or false,
+         'error' => An error message if success is false,
+         'htmlCode' => The html code performing redirection (html link or form, hidden if javascript is on). To be included in the template. Empty if success is false.
+         )
+
+The only thing you have to do is including the htmlCode in your template (unless success is false). Once this is done, you have completed the first step of the OpenID workflow. The user will be redirected to his provider.
+The next step is when the provider gets the user back to our application after user authentication (successful or not). The action invoked in this step is openid_finishauth, which is already defined in the plugin. In case of success, it calls your openIDCallback method to let you do your app specific treatments. On failure, it redirects to openid_error route.
+
+Other related features
+----------------------
+
+* Redirection after successful signin
+
+After a successful OpenID authentication, the user gets automatically redirected to the openid_finishauth route. However, you might want after this step to bring back the user to the page he was viewing before the authentication procedure. A possible solution to this problem is the following.
+First, in authModule actions file, before calling getRedirectHtml method, insert the following code:
+
+      $this->getUser()->setAttribute('openid_real_back_url', $this->getRequest()->getReferer());
+
+The previous page url will be stored in user's session. The only thing to do after this is to modify your openIDCallback to redirect the user to this url:
+
+      public function openIDCallback($openid_validation_result)
+      {
+      // ...App specific code...
+      $back = $this->getUser()->getAttribute('openid_real_back_url');
+      $this->getUser()->getAttributeHolder()->remove('openid_real_back_url');
+      if (empty($back))
+        $back = '@homepage';
+      $this->redirect($back);
+      }
+
+* Automatic signin
+
+For the moment we have only talked about authenticating for a single session. But the user might want to automatically signin with his OpenID every time he visits your application.
+To do this, we're going to use cookies and a special type of OpenID request.
+OpenID provides a way to ask a provider an instant response for a user authentication. Usually, a user can ask his OpenID provider to remember him and to always allow your application to access his profile. When asking an instant response, we send to the provider the OpenID of the user. The provider will then try to authenticate the user without any interaction from him. If it needs more info (like a password), it will not ask the user but simply get back to the application with a corresponding response code.
+This is how we can use this procedure in our application : upon a successful authentication, in your openIDCallback method, store the user's OpenID identity in a cookie:
+
+    sfContext::getInstance()->getResponse()->setCookie('known_openid_identity',$openid_validation_result['identity']);
+  
+Now suppose the user goes away and come back a few days later. We found his identity in the 'known_openid_identity' cookie. So your application can use it and ask the provider to authenticate the user transparently.
+This check must be done on every page the user may visit. So we're going to use a filter to do this treatment. Add the following code to yourApp/lib/rememberFilter.class.php:
+
+    class rememberFilter extends sfFilter
+    {
+      public function execute($filterChain)
+      {
+        // Filters don't have direct access to the request and user objects.
+        // You will need to use the context object to get them
+        $request = $this->getContext()->getRequest();
+        $user    = $this->getContext()->getUser();
+        // Execute this filter only once
+        if ($this->isFirstCall() && !$user->isAuthenticated() && ($user->getAttribute('openid_triedAutoLog') != 'yes'))
+        {
+          $user->setAttribute('openid_triedAutoLog', 'yes'); // Don't come back here anymore for this session
+          $cookie = $request->getCookie('known_openid_identity');
+          if (!empty($cookie)) {
+            $user->setAttribute('openid_url', $cookie);
+            return $this->getContext()->getController()->forward('authModule', 'autoSignin');
+          }
+        }
+        // Execute next filter
+        $filterChain->execute();
+      }
+    }
+
+Notice that when we try to auto signin, we use the autoSignin action from authModule. This action needs to be defined in your app. It should be quite similar to signin action except getRedirectHtml method should be called with $immediate argument set to true.
+Now activate this filter by editing yourApp/config/filters.yml:
+
+    remember:
+      class: rememberFilter
+    rendering: ~
+    security:  ~
+    # insert your own filters here
+    cache:     ~
+    common:    ~
+    execution: ~
+
+We have to be sure that we don't try to automatically signin when not needed. So upon logout, we should delete the cookie (in your logout action):
+
+    $this->getResponse()->setCookie('known_openid_identity', '');
+
+The same line should be added to your authModule's openidError action too: there is no need to retry endlessly to automatically signin when it has already failed.
+
+* OpenID parameters and extensions
+
+The default behaviour of this plugin is to ask user's fullname and email with the Simple Registration (SREG) and Attribute Exchange (AX) specifications. However, you might want to get other user's data (date of birth, nickname, ...) using SREG or AX. You might also want to use PAPE extension to specify an authentication method.
+All of this can be done with this plugin. The only thing to do is to override a method in your authModule action class: setOpenIDRequestParameters(sfPHPOpenID $openid_object). In this method, you get a sfPHPOpenID object as parameter which can be used to change the OpenID request. These are the methods you can call on this object:
+
+    getAvailablePAPEPolicies() -> Returns an array of available PAPE policy URIs
+    setPAPEPolicies($uris) -> Set the PAPE policy URIs (adding to the ones already set)
+    setRequestFields($fields) -> Sets the fields that should be retrieved from the user openid account.
+
+For more detail on these methods, look at the code in sfPHPOpenIDPlugin/lib/sfPHPOpenId.class.php.
+
+For example, in the following example, we ask for another user data: his nickname.
+
+    protected function setOpenIDRequestParameters(sfPHPOpenID $openid_object) {
+        $openid_object->setRequestFields(array('nickname'));
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/sfPHPOpenIdPlugin/lib/BasesfPHPOpenIDAuthActions.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,134 @@
+<?php
+
+/*
+ * This file is part of sfPHPOpenIDPlugin.
+ * (c) 2009 GenOuest Platform <support@genouest.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfPHPOpenID class.
+ *
+ * @package    sfPHPOpenIDPlugin
+ * @author     GenOuest Platform <support@genouest.org>
+ * @version    SVN: $Id: sfPHPOpenID.class.php 18089 2009-05-09 06:36:09Z fabien $
+ */
+
+/**
+ * This class is the base class for modules actions classes.
+ */
+
+class BasesfPHPOpenIDAuthActions extends sfActions
+{
+
+  /*
+   * Check the given OpenID and returns html code for redirection if the identity is valid.
+   *
+   * @param $identity     The OpenID the user want to login with
+   * @param $immediate    Should this be an immediate login (ie provider should answer yes or no without showing any form)
+   * @param $submitLabel  The value of the submit button that will be displayed if javascript is disabled. Optional, default is 'Continue'.
+   * @param $linkLabel    The label of the link that will be displayed if javascript is disabled. Optional, default is 'Click here to continue login with OpenID.'.
+   * @param $linkAttrs    An array of attributes of the link that will be displayed if javascript is disabled. Optional.
+   *
+   * @returns array(
+   *               'success' => true or false,
+   *               'error' => 'An error message if success is false',
+   *               'htmlCode' => 'The html code performing redirection (html link or form, hidden if javascript is on). To be included in the template. Empty if success is false.'
+   *               )
+   */
+  public function getRedirectHtml($identity, $immediate = false, $submitLabel = '', $linkLabel = '', $linkAttrs = array()) {
+
+    if (empty($linkLabel))
+      $linkLabel = 'Click here to continue login with OpenID.';
+
+    $result = array('success' => false,
+                    'error' => '',
+                    'htmlCode' => '');
+
+	  $openid = new sfPHPOpenID();
+		$openid->setIdentity($identity);
+
+		$process_url = $this->getController()->genUrl('@openid_finishauth', true);
+		$openid->setApprovedURL($process_url); // Script which handles a response from OpenID Server
+
+		$trust_root = $this->getController()->genUrl('@homepage', true);
+		$openid->SetTrustRoot($trust_root);
+
+		$this->setOpenIDRequestParameters($openid); // Call a function to customize the openid object from the app
+
+		$nextStep = $openid->getRedirectURL($immediate, $submitLabel);
+
+		if (($nextStep['type'] == 'url') && (!empty($nextStep['content']))) {
+		  // Using OpenID 1 => redirection using URL
+		  $result['success'] = true;
+
+	    $result['htmlCode'] = "<script type=\"text/javascript\">var transiting = true;document.location.href = \"".$nextStep['content']."\"</script>"; // auto redirect if js on
+	    $result['htmlCode'] .= "<a href=\"".$nextStep['content']."\" ";
+	    unset($linkAttrs['href']);
+	    $linkAttrs['id'] = 'openid_message';
+
+      foreach ($linkAttrs as $name => $attr) {
+          $result['htmlCode'] .= sprintf(" %s=\"%s\"", $name, $attr);
+      }
+	    $result['htmlCode'] .= ">$linkLabel</a>";
+		  $result['htmlCode'] .= "<script type=\"text/javascript\">document.getElementById('".$linkAttrs['id']."').style.display = 'none';</script>"; // Hide the link if js on (=auto redirect)
+		}
+		else if (($nextStep['type'] == 'form') && (!empty($nextStep['content']))) {
+		  // Using OpenID 2 => redirection using a form
+		  $result['success'] = true;
+
+		  $result['htmlCode'] = $nextStep['content'];
+	    $result['htmlCode'] .= "<script type=\"text/javascript\">document.getElementById('openid_message').style.display = 'none';</script>"; // Auto submit if js on
+	    $result['htmlCode'] .= "<script type=\"text/javascript\">var transiting = true;document.getElementById('openid_message').submit();</script>"; // hide form if js on
+		}
+		else {
+		  // Show an error message
+		  if (empty($nextStep['content']))
+		    $result['error'] = "Unexpected error.";
+		  else
+			  $result['error'] = $nextStep['content'];
+		}
+
+		return $result;
+  }
+
+  // Override this method in your app if you want to add parameters to the openid request
+  // For example, adding fields to request like nickname or date of birth.
+  protected function setOpenIDRequestParameters(sfPHPOpenID $openid_object) {
+    /*
+    // This is an example of code you can write in your app
+    $openid_object->setRequestFields(array('nickname'));
+    */
+  }
+
+	// This is the callback action used by the openID provider
+	public function executeFinish(sfWebRequest $request)
+	{
+    $openid = new sfPHPOpenID();
+    $openid->setIdentity($this->getRequestParameter('openid_identity'));
+
+		$process_url = $this->getController()->genUrl('@openid_finishauth', true);
+		$openid->setApprovedURL($process_url); // Script which handles a response from OpenID Server
+
+		$trust_root = $this->getController()->genUrl('@homepage', true);
+		$openid->SetTrustRoot($trust_root);
+
+    $openid_validation_result = $openid->getAuthResult();
+
+    if ($openid_validation_result['result'] == sfPHPOpenID::AUTH_SUCCESS) {
+      $this->openIDCallback($openid_validation_result);
+    }
+    else {
+      if (!empty($openid_validation_result['message']))
+        $this->getUser()->setFlash('openid_error', $openid_validation_result['message']);
+      $this->redirect('@openid_error');
+    }
+	}
+
+  // Override this method in your app. It is called when user has been authenticated.
+	public function openIDCallback($openid_validation_result)
+	{
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/sfPHPOpenIdPlugin/lib/sfPHPOpenID.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,514 @@
+<?php
+
+/*
+ * This file is part of sfPHPOpenIDPlugin.
+ * (c) 2009 GenOuest Platform <support@genouest.org>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+ 
+/**
+ * sfPHPOpenID class.
+ *
+ * @package    sfPHPOpenIDPlugin
+ * @author     GenOuest Platform <support@genouest.org>
+ * @version    SVN: $Id: sfPHPOpenID.class.php 18089 2009-05-09 06:36:09Z fabien $
+ */
+
+/**
+ * This class is a wrapper around PHP OpenID library.
+ */
+ 
+$libIncludePath = sfConfig::get('app_sf_phpopenid_plugin_lib_path');
+if (empty($libIncludePath))
+  $libIncludePath = sfConfig::get('sf_root_dir') . '/lib/php-openid';
+
+set_include_path(get_include_path() . PATH_SEPARATOR . $libIncludePath);
+require_once "Auth/OpenID/Consumer.php";
+require_once "Auth/OpenID/FileStore.php";
+require_once "Auth/OpenID/SReg.php";
+require_once "Auth/OpenID/PAPE.php";
+require_once "Auth/OpenID/AX.php";
+
+error_reporting(E_ERROR | E_WARNING | E_PARSE); // php-openid generate a lot of harmless warnings with php5
+
+class sfPHPOpenID {
+  const AUTH_SUCCESS        = 0;
+  const AUTH_CANCEL         = 1;
+  const AUTH_FAILURE        = 2;
+  const AUTH_SETUP_NEEDED   = 3;
+  
+  private $openid_url_identity;
+  private $trust_root;
+  private $approved_url;
+  private $PAPE_policies = array();
+  private $request_fields_sreg = array('fullname', 'email');
+  private $request_fields_AX = array('fullname' => 'http://axschema.org/namePerson',
+                                     'firstname' => 'http://axschema.org/namePerson/first',
+                                     'lastname' => 'http://axschema.org/namePerson/last',
+                                     'email' =>'http://axschema.org/contact/email');
+  private $required_AX_fields = array('fullname', 'email', 'firstname', 'lastname'); // List of required fields from $request_fields_AX. Default (= not specified) is not required.
+  private $count_AX_fields = array(); // The number of values requested for the corresponding AX field. Default (= not specified) is unlimited.
+  
+  private $available_sreg_values =  array('dob',
+                                          'gender',
+                                          'postcode',
+                                          'country',
+                                          'language',
+                                          'timezone');
+
+  private $default_sreg_values =    array('nickname',
+                                          'email',
+                                          'fullname');
+
+  private $mapping_sreg_ax     =    array('nickname' => 'http://axschema.org/namePerson/friendly',
+                                          'email' => 'http://axschema.org/contact/email',
+                                          'fullname' => 'http://axschema.org/namePerson',
+                                          'firstname' => 'http://axschema.org/namePerson/first',
+                                          'lastname' => 'http://axschema.org/namePerson/last',
+                                          'dob' => 'http://axschema.org/birthDate',
+                                          'gender' => 'http://axschema.org/person/gender',
+                                          'postcode' => 'http://axschema.org/contact/postalCode/home',
+                                          'country' => 'http://axschema.org/contact/country/home',
+                                          'language' => 'http://axschema.org/pref/language',
+                                          'timezone' => 'http://axschema.org/pref/timezone');
+
+  /**
+   * getRedirectURL
+   * Prepare an http request to send to the openid provider.
+   * 
+   * @returns An array: 'type' => 'url|form|error', 'content' => 'the Url or the form content or error message'
+   */
+  public function getRedirectURL($immediate = false, $submitLabel = '')
+  {
+    if (empty($submitLabel))
+      $submitLabel = 'Continue';
+      
+    $consumer = $this->getConsumer();
+
+    // Begin the OpenID authentication process.
+    $auth_request = $consumer->begin($this->getIdentity());
+
+    // No auth request means we can't begin OpenID.
+    if (!$auth_request) {
+        return array('type' => 'error', 'content' => "Authentication error: not a valid OpenID (".$this->getIdentity().").");
+    }
+
+    $sreg_request = Auth_OpenID_SRegRequest::build(
+                                     // Required
+                                     array('nickname'),
+                                     // Optional
+                                     $this->getRequestFieldsSREG());
+
+    if ($sreg_request) {
+        $auth_request->addExtension($sreg_request);
+    }
+
+    // PAPE support (see http://openid.net/specs/openid-provider-authentication-policy-extension-1_0.html)
+    $pape_request = new Auth_OpenID_PAPE_Request($this->PAPE_policies);
+    if ($pape_request) {
+        $auth_request->addExtension($pape_request);
+    }
+
+    // Add Attribute Exchange request information (see http://openid.net/specs/openid-attribute-exchange-1_0.html).
+    $ax_request = new Auth_OpenID_AX_FetchRequest();
+    if ($ax_request) {
+      foreach ($this->request_fields_AX as $alias => $url) {
+        $ax_request->add(new Auth_OpenID_AX_AttrInfo($url, $this->getCountForAXField($alias), $this->isRequiredAXField($alias), $alias));
+      }
+      $auth_request->addExtension($ax_request);
+    }
+
+    // Redirect the user to the OpenID server for authentication.
+    // Store the token for this authentication so we can verify the
+    // response.
+
+    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
+    // form to send a POST request to the server.
+    if ($auth_request->shouldSendRedirect()) {
+        $redirect_url = $auth_request->redirectURL($this->getTrustRoot(),
+                                                   $this->getApprovedURL(),
+                                                   $immediate);
+
+        // If the redirect URL can't be built, display an error
+        // message.
+        if (Auth_OpenID::isFailure($redirect_url)) {
+            return array('type' => 'error', 'content' => "Could not redirect to server: " . $redirect_url->message);
+        } else {
+            // Send redirect.
+            return array('type' => 'url', 'content' => $redirect_url);
+        }
+    } else {
+        // Generate form markup and render it.
+        $form_id = 'openid_message';
+        
+        $form_html = $this->formMarkupWithLabel($auth_request, $this->getTrustRoot(), $this->getApprovedURL(),
+                                               $immediate, array('id' => $form_id), $submitLabel);
+
+        // Display an error if the form markup couldn't be generated;
+        // otherwise, render the HTML.
+        if (Auth_OpenID::isFailure($form_html)) {
+            return array('type' => 'error', 'content' => "Could not redirect to server: " . $form_html->message);
+        } else {
+            return array('type' => 'form', 'content' => $form_html);
+        }
+    }
+  }
+
+  // This method has been adapted from PHP OpenID lib code to allow the use of submitLabel
+  private function formMarkupWithLabel($auth_request, $realm, $return_to=null, $immediate=false,
+                                       $form_tag_attrs=null, $submitLabel)
+  {
+      $message = $auth_request->getMessage($realm, $return_to, $immediate);
+
+      if (Auth_OpenID::isFailure($message))
+          return $message;
+
+      return $message->toFormMarkup($auth_request->endpoint->server_url,
+                                    $form_tag_attrs, $submitLabel);
+  }
+
+  /**
+   * setIdentity
+   * Sets the url given by the user as his identity
+   *
+   * @param identity The user's identity (example: http://misterx.myopenid.com)
+   */
+  public function setIdentity($identity)
+  {   // Set Identity URL
+    if (strpos($identity, 'http://') === false && strpos($identity, 'https://') === false) {
+      // Gmail is an exception: user can give an email adress and we'll discover the correct url for him
+      // This kind of behavior might be more widely used in the future. Or not.
+      if (strrpos($identity, '@gmail.com') == strlen($identity) - strlen('@gmail.com'))
+        $identity = 'http://www.google.com/accounts/o8/id';
+      else
+        $identity = 'http://'.$identity;
+    }
+    // if this is a server we want a trailing slash
+    // therefore if there isn't a slash somewhere in the url after
+    // http:// add one
+    if (preg_match('|^http[s]?://[^/]+$|', $identity))
+    {
+      $identity .= '/';
+    }
+    $this->openid_url_identity = $identity;
+  }
+  
+  /**
+   * getIdentity
+   * Returns the url given by the user as his identity
+   *
+   * @returns The user's identity (example: http://misterx.myopenid.com)
+   */
+  public function getIdentity()
+  {
+    return $this->openid_url_identity;
+  }
+
+  /**
+   * setApprovedURL
+   * Set the url where the user will get back after authentification
+   *
+   * @param The url
+   */
+  public function setApprovedURL($url)
+  {
+    $this->approved_url = $url;
+  }
+
+  /**
+   * getApprovedURL
+   * Returns the url where the user will get back after authentification
+   *
+   * @returns The url
+   */
+  public function getApprovedURL()
+  {
+    return $this->approved_url;
+  }
+
+  /**
+   * setTrustRoot
+   * Set the root of the website where the user wants to login
+   *
+   * @param The url of the root
+   */
+  public function setTrustRoot($url)
+  {
+    $this->trust_root = $url;
+  }
+
+  /**
+   * getTrustRoot
+   * Returns the root of the website where the user wants to login
+   *
+   * @returns The url of the root
+   */
+  public function getTrustRoot()
+  {
+    return $this->trust_root;
+  }
+
+  /**
+   * setPAPEPolicies
+   * Set the PAPE policy URIs (adding to the ones already set)
+   *
+   * @param $uris An array of PAPE policy URIs
+   */
+  public function setPAPEPolicies($uris)
+  {
+    if (is_array($uris))
+      $this->PAPE_policies = array_merge($this->PAPE_policies, $uris);
+    else
+      $this->PAPE_policies[] = $uris;
+  }
+
+  /**
+   * getPAPEPolicies
+   * Returns the currently active PAPE policy URIs
+   *
+   * @returns An array of currently active PAPE policy URIs
+   */
+  public function getPAPEPolicies()
+  {
+    return $this->PAPE_policies;
+  }
+
+  /**
+   * getAvailablePAPEPolicies
+   * Returns the list of available PAPE policies
+   *
+   * @returns An array of available PAPE policy URIs
+   */
+  public function getAvailablePAPEPolicies()
+  {
+    $pape_policy_uris = array(
+			  PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
+			  PAPE_AUTH_MULTI_FACTOR,
+			  PAPE_AUTH_PHISHING_RESISTANT
+			  );
+    return $pape_policy_uris;
+  }
+  
+  /**
+   * setRequestFields
+   * Sets the fields that should be retrieved from the user openid account.
+   * There's no guarantee that the user allow the publication of these info!
+   * Fields beginning with 'http://' and with a non-numeric key are considered as AX types
+   * (for example: array(..., 'companyName' => 'http://axschema.org/company/name', ...))
+   * (see http://openid.net/specs/openid-attribute-exchange-1_0.html).
+   *
+   * @param fields An array of fields to retrieve
+   */
+  public function setRequestFields($fields)
+  {
+    foreach ($fields as $id => $field) {
+      if (!empty($field)) {
+        if ( in_array($field, $this->available_sreg_values) && !in_array($field, $this->request_fields_sreg)) {
+          $this->request_fields_sreg[] = $field;
+          $this->request_fields_AX[$field] = $mapping_sreg_ax[$field];
+        }
+        else if (!is_numeric($id) && (strpos($field, 'http://') === 0 || strpos($field, 'https://') === 0) && !array_key_exists($id, $this->request_fields_AX) && !in_array($id, $this->request_fields_SREG)) {
+          // This is and AX field with no SREG corresponding field
+          $this->request_fields_AX[$id] = $field;
+        }
+      }
+    }
+  }
+  
+  /**
+   * getRequestFieldsSREG
+   * Gets the SREG fields that should be retrieved from the user openid account
+   *
+   * @returns fields An array of fields to retrieve
+   */
+  public function getRequestFieldsSREG()
+  {
+    return $this->request_fields_sreg;
+  }
+  
+  /**
+   * getRequestFieldsAX
+   * Gets the AX fields that should be retrieved from the user openid account
+   *
+   * @returns fields An array of fields to retrieve
+   */
+  public function getRequestFieldsAX()
+  {
+    return $this->request_fields_AX;
+  }
+  
+ /**
+  * setRequiredAXFields
+  * Set the given AX fields as required.
+  *
+  * @param required An array of AX fields aliases.
+  */
+  public function setRequiredAXFields($required) {
+    $this->required_AX_fields = array_merge($this->required_AX_fields, $required);
+  }
+  
+ /**
+  * getRequiredAXFields
+  * Get the required AX fields.
+  *
+  * @returns An array of required AX fields aliases.
+  */
+  public function getRequiredAXFields() {
+    return $this->required_AX_fields;
+  }
+  
+ /**
+  * isRequiredAXField
+  * Returns wether the given AX field alias is required or not.
+  *
+  * @param $alias An AX field alias
+  * @returns Returns wether the given AX field alias is required or not.
+  */
+  public function isRequiredAXField($alias) {
+    return in_array($alias, $this->required_AX_fields);
+  }
+  
+ /**
+  * setCountAXFields
+  * Set the number of values to ask for the given AX fields.
+  *
+  * @param count An array of AX fields aliases (key) with the corresponding count (value).
+  */
+  public function setCountAXFields($count) {
+    $this->count_AX_fields = array_merge($this->count_AX_fields, $count);
+  }
+  
+ /**
+  * getCountAXFields
+  * Get the number of values to ask for each AX field (If not specified, count is unlimited).
+  *
+  * @returns An array of AX fields aliases (key) with the corresponding count (value).
+  */
+  public function getCountAXFields() {
+    return $this->count_AX_fields;
+  }
+  
+ /**
+  * getCountForAXField
+  * Get the number of values to ask for the given AX field alias.
+  *
+  * @param alias An AX field alias
+  * @returns An array of AX fields aliases (key) with the corresponding count (value).
+  */
+  public function getCountForAXField($alias) {
+    if (array_key_exists($alias, $this->count_AX_fields))
+      return $this->count_AX_fields[$alias];
+      
+    return Auth_OpenID_AX_UNLIMITED_VALUES;
+  }
+
+ /**
+  * getAuthResult
+  * Returns the result of the authentification and the data retrieved from the user profile.
+  * 
+  * @returns An array containing result and user data (in case of success):
+  *  {'result' => 'result code',
+  *   'message' => 'an optional message',
+  *   'identity' => 'the user's identity (http://misterx.myopenid.com)',
+  *   'userData' => 'array of user fields values ('fullname' => array('the fullname', 'another fullname'), 'email' => array('the email'), ...)'}
+  *   'PAPEResp' => 'a Auth_OpenID_PAPE_Response object (null if the provider didn't send a PAPE response)'
+  */
+  public function getAuthResult()
+  {
+    $res = array();
+    $res['result'] = sfPHPOpenID::AUTH_FAILURE;
+    $res['message'] = '';
+    $res['identity'] = '';
+    $res['userData'] = array();
+    $res['PAPEResp'] = '';
+    
+    $consumer = $this->getConsumer();
+
+    // Complete the authentication process using the server's
+    // response.
+    $return_to = $this->getApprovedURL();
+    $response = $consumer->complete($return_to);
+
+    // Check the response status.
+    if ($response->status == Auth_OpenID_CANCEL)
+    {
+        // This means the authentication was cancelled.
+        $res['message'] = 'Verification cancelled.';
+        $res['result'] = sfPHPOpenID::AUTH_CANCEL;
+    }
+    else if ($response->status == Auth_OpenID_FAILURE)
+    {
+        // Authentication failed; display the error message.
+        $res['message'] = $response->message;
+        $res['result'] = sfPHPOpenID::AUTH_FAILURE;
+    }
+    else if ($response->status == Auth_OpenID_SETUP_NEEDED)
+    {
+      $res['result'] = sfPHPOpenID::AUTH_SETUP_NEEDED;
+    }
+    else if ($response->status == Auth_OpenID_SUCCESS)
+    {
+        // This means the authentication succeeded; extract the
+        // identity URL and Simple Registration data (if it was
+        // returned).
+        $openid = $response->getDisplayIdentifier();
+        $res['result'] = sfPHPOpenID::AUTH_SUCCESS;
+        $res['identity'] = htmlentities($openid);
+
+        // Get SREG data
+        $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
+        $sregData = $sreg_resp->contents();
+        foreach ($sregData as $field => $value) {
+          $res['userData'][$field] = array($value);
+        }
+        
+        // Get AX data (use AX instead of SREG data if both are returned by the provider (or no SREG data))
+        $ax_resp = new Auth_OpenID_AX_FetchResponse();
+        $ax_resp = $ax_resp->fromSuccessResponse($response);
+        if ($ax_resp) {
+          foreach ($this->request_fields_AX as $alias => $url) {
+            $get_ax = $ax_resp->get($url);
+            if ((get_class($get_ax) != "Auth_OpenID_AX_Error") && (count($get_ax) > 0))
+              if (empty($res['userData'][$alias]))
+                $res['userData'][$alias] = $get_ax;
+              else
+                $res['userData'][$alias] = array_filter(array_merge($res['userData'][$alias], $get_ax));
+          }
+        }
+        
+        $res['PAPEResp'] = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
+    }
+    
+    return $res;
+  }
+  
+  private function getStore() {
+      /**
+       * This is where the app will store its OpenID information.
+       * You should change this path if you want the example store to be
+       * created elsewhere.
+       */
+      $store_path = "/tmp/symfony_openid_filestore";
+
+      if (!file_exists($store_path) &&
+          !mkdir($store_path)) {
+          print "OpenID: Could not create the FileStore directory '$store_path'. ".
+              " Please check the effective permissions.";
+          exit(0);
+      }
+
+      return new Auth_OpenID_FileStore($store_path);
+  }
+
+  private function getConsumer() {
+      /**
+       * Create a consumer object using the store object created
+       * earlier.
+       */
+      $store = $this->getStore();
+      $consumer = new Auth_OpenID_Consumer($store);
+      return $consumer;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/thdProject/plugins/sfPHPOpenIdPlugin/lib/validator/sfPHPOpenIdValidator.class.php	Wed Mar 24 19:04:36 2010 +0100
@@ -0,0 +1,63 @@
+<?php
+
+/*
+ * This file is part of sfPHPOpenIDPlugin.
+ * (c) 2009 GenOuest Platform <support@genouest.org>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+ 
+/**
+ * sfPHPOpenID class.
+ *
+ * @package    sfPHPOpenIDPlugin
+ * @author     GenOuest Platform <support@genouest.org>
+ * @version    SVN: $Id: sfPHPOpenID.class.php 18089 2009-05-09 06:36:09Z fabien $
+ */
+
+/**
+ * This validator will check if a given string is a valid OpenID
+ *
+ */
+
+class sfPHPOpenIdValidator extends sfValidatorBase
+{
+
+  public function configure($options = array(), $messages = array())
+  {
+    parent::configure($options, $messages);
+    $this->setMessage('required', 'Your OpenID URL is missing.');
+    $this->setMessage('invalid', 'Your OpenID is incorrect.');
+  }
+  
+  public function doClean($value)
+  {
+    $re = "
+      /^                                                      # Start at the beginning of the text
+      ((?:https?):\/\/)?                                      # Look for http, or https schemes (or no scheme)
+      (?:                                                     # Userinfo (optional) which is typically
+        (?:(?:[\w\.\-\+!$&'\(\)*\+,;=]|%[0-9a-f]{2})+:)*      # a username or a username and password
+        (?:[\w\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})+@          # combination
+      )?
+      (?:
+        (?:[a-z0-9\-\.]|%[0-9a-f]{2})+                        # A domain name or a IPv4 address
+        |(?:\[(?:[0-9a-f]{0,4}:)*(?:[0-9a-f]{0,4})\])         # or a well formed IPv6 address
+      )
+      (?::[0-9]+)?                                            # Server port number (optional)
+      (?:[\/|\?]
+        (?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})   # The path and query (optional)
+      *)?
+    $/xi";
+    
+    if (empty($value) || ($value == 'http://') || ($value == 'https://')) {
+      throw new sfValidatorError($this, 'required');
+    }
+    
+    if (!preg_match($re, $value)) {
+      throw new sfValidatorError($this, 'invalid');
+    }
+
+    return $value;
+  }
+}