Search code examples
javasecurityrolesshiro

Shiro-Guice Filter Chain Roles Configuration


How can I configure the Roles in the addFilterChain Method??

in the INI file it is something like

[url]
/secure/** = authc, roles[admin]

How would it be in the Java method?

addFilterChain("/secure/**", ROLES);

Solution

  • The ShiroWebModule provides a "config" method that mimics the INI [] syntax.

    So the equivalent of your INI config would be:

    addFilterChain("/secure/**", AUTHC, config(ROLES, "admin"));