core
core copied to clipboard
How I can grant access for many roles using annotation?
I can grant access for many roles, but the forms below not work.
Example:
/**
- @ApiResource(
-
attributes={ -
"access_control"="is_granted('ROLE_STUDENT')", -
"access_control"="is_granted('ROLE_TEACHER')" -
} - ) ...
/**
- @ApiResource(
-
attributes={ -
"access_control"="is_granted('ROLE_STUDENT, ROLE_TEACHER')" -
} - ) ...
/**
- @ApiResource(
-
attributes={ -
"access_control"="is_granted('ROLE_STUDENT', 'ROLE_TEACHER')" -
} - ) ...
You can use logical operators in expression language, so the following should work:
@ApiResource(
attributes={
"access_control"="is_granted('ROLE_STUDENT') or is_granted('ROLE_TEACHER')"
}
)
@lukasluecke its work!! Thank u bro!!