Files
openstackid/app/controllers/HomeController.php
stephane a1b1b353d5 Make content type check more robust
We currently check the accept request header a few times in this
code to make sure it matches application/xrds+xml. The existing
code worked fine for

Accept: application/xrds+xml

but not for more complex requests like

Accept: text/html; q=0.3, application/xhtml+xml; q=0.5, application/xrds+xml

This caused the server to not return XRDS when it would have been appropriate
to do so, which breaks discovery.

This patch simplifies the check for the XRDS content type to allow for
different formats of accept request headers.

Change-Id: I3877ef72f6d11346c772e83f95d43ab97123a364
2015-03-18 22:38:41 -07:00

27 lines
740 B
PHP

<?php
use openid\XRDS\XRDSDocumentBuilder;
class HomeController extends BaseController
{
private $discovery;
public function __construct(DiscoveryController $discovery)
{
$this->discovery = $discovery;
}
public function index()
{
//This field contains a semicolon-separated list of representation schemes
//which will be accepted in the response to this request.
$accept = Request::header('Accept');
if (strstr($accept, XRDSDocumentBuilder::ContentType))
return $this->discovery->idp();
if (Auth::guest())
return View::make("home");
else {
return Redirect::action("UserController@getProfile");
}
}
}