예제 #1
0
 public function getLogin()
 {
     if (Auth::guest()) {
         $msg = $this->memento_service->getCurrentRequest();
         $auth_request = new OpenIdAuthenticationRequest($msg);
         $params = array('realm' => $auth_request->getRealm());
         if (!$auth_request->isIdentitySelectByOP()) {
             $params['claimed_id'] = $auth_request->getClaimedId();
             $params['identity'] = $auth_request->getIdentity();
             $params['identity_select'] = false;
         } else {
             $params['identity_select'] = true;
         }
         return View::make("login", $params);
     } else {
         return Redirect::action("UserController@getProfile");
     }
 }
 public function process(User $user)
 {
     //check if we have a current openid message
     $msg = $this->memento_service->getCurrentRequest();
     if (!is_null($msg) && $msg->isValid() && OpenIdAuthenticationRequest::IsOpenIdAuthenticationRequest($msg)) {
         //check if current user is has the same identity that the one claimed on openid message
         $auth_request = new OpenIdAuthenticationRequest($msg);
         if (!$auth_request->isIdentitySelectByOP()) {
             $claimed_id = $auth_request->getClaimedId();
             $identity = $auth_request->getIdentity();
             $current_identity = $this->server_configuration->getUserIdentityEndpointURL($user->getIdentifier());
             //if not return fail ( we cant log in with a different user that the one stated on the authentication message!
             if ($claimed_id !== $current_identity && $identity !== $current_identity) {
                 Log::warning(sprintf(OpenIdErrorMessages::AlreadyExistSessionMessage, $current_identity, $identity));
                 throw new AuthenticationException(sprintf(OpenIdErrorMessages::AlreadyExistSessionMessage, $current_identity, $identity));
             }
         }
     }
 }