JMSSecurityExtraBundle icon indicating copy to clipboard operation
JMSSecurityExtraBundle copied to clipboard

Annotation @Secure redirect mandatorily ?

Open Chrysweel opened this issue 11 years ago • 1 comments

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

Chrysweel avatar Sep 06 '13 13:09 Chrysweel

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

stof avatar Sep 06 '13 13:09 stof