Created
June 15, 2015 17:59
Updated Application.php for ApiProblem on HTTP Basic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace KnpU\CodeBattle; | |
// ... | |
class Application extends SilexApplication | |
{ | |
// ... | |
private function configureSecurity() | |
{ | |
$app = $this; | |
$this->register(new SecurityServiceProvider(), array( | |
// ... no changes | |
)); | |
// register this service, so we can share it | |
$app['security.entry_point'] = $app->share(function() use ($app) { | |
return new ApiEntryPoint($app['translator'], $app['api.response_factory']); | |
}); | |
// setup the HttpBasic "api" firewall to use this entry point | |
$this['security.entry_point.api.http'] = $app->share(function() use ($app) { | |
return $app['security.entry_point']; | |
}); | |
// setup our custom API token authentication | |
$app['security.authentication_listener.factory.api_token'] = $app->protect(function ($name, $options) use ($app) { | |
// no changes | |
// make this use the security.entry_point service | |
// the class that decides what should happen if no authentication credentials are passed | |
$this['security.entry_point.'.$name.'.api_token'] = $app->share(function() use ($app) { | |
return $app['security.entry_point']; | |
}); | |
return array( | |
// ... | |
); | |
}); | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment