Search code examples
fluent-security

Authorize all controllers in a given namespace?


Is it possible to apply an AuthorizeAttribute to all controllers within a given namespace using FluentSecurity?


Solution

  • Yes, you can do that using ForAllControllersInNamespaceContainingType<TType>() or ForActionsMatching(info => *predicate*) in FluentSecurity 2.0 (currently in beta).

    You can read more about it in the documentation here: https://github.com/kristofferahl/FluentSecurity/wiki/Securing-controllers