JMSSecurityExtraBundle
JMSSecurityExtraBundle copied to clipboard
Annotation @Secure redirect mandatorily ?
Hi. I am using the annotation @Secure in my controller.
@Secure(roles="ROLE_ADMIN")
But I am doing an API Rest, i.e I want to send an code http 403, no redirect.
Is posible modify with the config of bundle, or I have that modify or create other annotation ?
thanks in advance
This bundle has nothing to do with the redirect. When the security check fails, it only throws an AccessDeniedException.
the handling of these exceptions is done by SecurityBundle (to redirect to the login page when needed and to render a 403 otherwise). If you want a different handling for exceptions, you can register a listener with a higher priority. FOSRestBundle does it for instance. See https://github.com/FriendsOfSymfony/FOSRestBundle/pull/411 for the PR which implemented it