Grails Spring Security check if User belongs to Group (Rolegroup)

Asked

Viewed 96 times

0

I have the following domain classes:

User hasOne Rolegroup hasMany Roll

  • Examples:

Rolegroup: Admin, Professional, Client, ...

Roll: ROLE_ACTION_1, ROLE_ACTION_2, ...

How do I check if the User belongs to a specific Rolegroup?

On @Secured I can only insert "ROLE"... Do I need to include all the roles of the group whenever I want to grant access to a specific group? There’s a viable way to do this?

1 answer

0

Usually when you use the plugin command to generate the classes are generated classes User, Profile, User.

    grails s2-quickstart com.yourapp Usuario Perfil

In this third there is a static method called: get(long usuarioId, long perfilId), its call would be like this.

    UsuarioPerfil.get(usuario.id, perfil.id)

If it exists it returns a Userprofile object which is relationship between the two, User + Profile.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.