Exemplo n.º 1
0
 public function onCheckidSetup(SetupRequest $request)
 {
     // the provider has to authenticate the user and if the authentication
     // was successful we can redirect the user back to the relying party.
     // The url can contains extensions like sreg or ax
     $redirect = new Redirect();
     $redirect->setOpEndpoint('http://127.0.0.1/openid');
     $redirect->setClaimedId('http://k42b3.com');
     $redirect->setIdentity('http://k42b3.com');
     $redirect->setReturnTo('http://127.0.0.1/callback');
     $redirect->setResponseNonce(uniqid());
     $redirect->setAssocHandle(self::$assoc->getAssocHandle());
     $redirect->setParams(array('foo' => 'bar'));
     return $redirect->getUrl(self::$assoc->getSecret(), self::$assoc->getAssocType());
 }
Exemplo n.º 2
0
 private function allowAccess()
 {
     // delete session
     $_SESSION['amun_openid_request'] = null;
     // build redirect
     $nonce = gmdate('Y-m-d\\TH:i:s\\Z') . Security::generateToken(15);
     $redirect = new Redirect();
     $redirect->setOpEndpoint($this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/openid/signon');
     $redirect->setClaimedId($this->claimedId);
     $redirect->setIdentity($this->identity);
     $redirect->setReturnTo($this->returnTo);
     $redirect->setResponseNonce($nonce);
     $redirect->setAssocHandle($this->assoc['assocHandle']);
     $redirect->setParams($this->request->getParams());
     if (!empty($this->sreg)) {
         $redirect->addExtension($this->handleSregExt());
     }
     if (!empty($this->oauth)) {
         $redirect->addExtension($this->handleOauthExt());
     }
     // insert or update connect
     $now = new DateTime('NOW', $this->registry['core.default_timezone']);
     $data = array('userId' => $this->user->getId(), 'assocId' => $this->assoc['id'], 'claimedId' => $this->claimedId, 'identity' => $this->identity, 'returnTo' => (string) $this->returnTo, 'responseNonce' => $nonce, 'date' => $now->format(DateTime::SQL));
     if (isset($_POST['remember']) && $_POST['remember'] === '1') {
         $data['status'] = Openid\Record::APPROVED;
     }
     $this->hm->getTable('AmunService\\Openid')->replace($data);
     // redirect to rp
     $redirect->redirect($this->assoc['secret'], $this->assoc['assocType']);
 }