# HG changeset patch # User clebeaupin # Date 1269453876 -3600 # Node ID 4427c90bd892166094f698137d6484b89d3ae199 # Parent 31cc2136a768fc78893adf162814b19b1143689a Implements openid diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/config/app.yml.tmpl --- 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: diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/config/routing.yml --- 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 ######## diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/config/security.yml --- 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 diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/config/settings.yml --- 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: diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/lib/myUser.class.php --- 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 @@ 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); + } } diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/modules/account/actions/loginUserAction.class.php --- /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 @@ +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 diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/modules/account/actions/logoutUserAction.class.php --- /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 @@ +getUser()->logout(); + return $this->redirect('@homepage'); + } +} \ No newline at end of file diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/modules/account/actions/openidLoginAction.class.php --- /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 @@ +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 diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/modules/account/config/security.yml --- /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 diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/modules/account/templates/_loginUserForm.php --- 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 @@ -
diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/modules/account/templates/_loginUserFormHeader.php --- 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 @@ - - diff -r 31cc2136a768 -r 4427c90bd892 web/thdProject/apps/frontend/modules/account/templates/_registerUserForm.php --- 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 @@ -