A
A
Anatoly Evladov2016-05-06 15:21:20
Scala
Anatoly Evladov, 2016-05-06 15:21:20

How to work with annotations in Play Framework 2 on Scala?

There is a simple application on the Play Framework 2 (Scala)
Naturally, there is authentication and different groups for users, I want to allow some methods to be performed only by the administrator or other groups, but I really don’t want to get into the logic of the methods themselves.
They advised me to look in the direction of annotations, but I did not find anything that explains how it works and, most importantly, how to create them.
Actually I ask for help, either with a simple example of how to create an annotation so that a check is made for the ability to execute the method for the current user (if there are no rights, redirect to the main page), or where you can read about it.
PS It's strange, but I didn't find anything like that in the Play Framework 2 documentation(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Knyazev, 2016-05-06
@axaxa_man

Maybe you need this?
https://www.playframework.com/documentation/1.2.2/...
ps
@With(Secure.class) - this is the same annotation
Secure.class - your class for the user role

R
Rail Khusnutdinov, 2016-06-27
@rail-ka

There is a cool library for authentication on play framework 2:
silhouette.mohiva.com
All this is implemented there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question