Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework controller with secure and non-secure methods. Possible?

I try to make a website with play with a member and a non member area. So i have controllers with member and non-member methods. But i can only make the whole controller secure [@With(Secure.class)]. Is it possibly to make only a few methods secure and access the others without a login?

Thanks

like image 315
developer_joe Avatar asked Jul 11 '11 13:07

developer_joe


1 Answers

Yes, you can, although it will require some tweaking on the Secure class. If you check @Secure it has a method annotated with @Before. As per documentation you can indicate which methods the @Before is applied to and for which ones it is skipped.

@Before(unless="login")

So it would be a matter of not running @Before on the public methods. Be aware it may not work properly using @With and you may need to create your own @Before in the controller that manages the security (calling the proper methods in secure).

But it would be simpler to just have 2 controllers, one for secure users and one for public methods.

like image 176
Pere Villega Avatar answered Sep 21 '22 15:09

Pere Villega