I have an API that has different consumers. I'd like them to get relevant documentation based on their roles in Spring Security.
E.g
API operation A is constricted to Role A and Role B
API operation B is constricted to Role B
API operation C is open for all
I'm using SpringFox, Spring 4, Spring Rest, Security
I know there is an annotation called @ApiIgnore
, which could perhaps be utilized.
Is this at all possible?
You may have already seen this, but SpringFox itself provides mechanism for configuring security. See this section in the official SpringFox documentation, and this section for an example (note points #14 and #15).
If you are open to allowing different consumers viewing the APIs, but still not being able to execute the APIs, you can consider adding @Secured annotation on the APIs with the appropriate roles.
For example:
Make sure that you have added
@EnableGlobalMethodSecurity (securedEnabled = true)
in yourSecurityConfig
class (or whatever the one that you have) for @Secured to work.