Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Updated Application.php for ApiProblem on HTTP Basic
<?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
You can’t perform that action at this time.