User Roles in Play!

1,149 views
Skip to first unread message

Kenny Meyer

unread,
Mar 9, 2011, 3:56:19 AM3/9/11
to play-framework
Hi,

How can I implement multiple user roles in Play!, with each having
role-specific permissions and views, and what would be an appropriated
database scheme?

Basically, I have these roles:

- Administrator
- Organizer
- Contestant
- Unregistered (not authenticated or anonymous)

Each of those roles has different permissions and views within the web
application.

Is the Secure module sufficient for this purpose? If yes, are the any
code examples you can provide? Well, I would be thankful if you can
give me the basic idea, because I can't wrap my head around this.

There is this question on the list, which is very similar to mine:
http://groups.google.com/group/play-framework/browse_thread/thread/7f56fd62af992cec/9a40e8404ab42bfa?#9a40e8404ab42bfa
Consider the actual thread as a follow-up.

Thanks -- Kenny

Steve Chaloner

unread,
Mar 9, 2011, 4:10:32 AM3/9/11
to play-framework
If each user only has a single role, then the Secure module is what
you need. I can't really add more than what's detailed in
http://www.playframework.org/documentation/1.1.1/secure and
http://www.playframework.org/documentation/1.1.1/guide8 - these cover
everything you need, and the example code of yabe can be used as a
guide. Check ${your play installation}/samples-and-tests/yabe for the
yabe code.

If each user can have more than one role, consider the deadbolt module
- this allows you to and, or and not role combinations in your
security restrictions.

- Steve

On Mar 9, 9:56 am, Kenny Meyer <knny.m...@gmail.com> wrote:
> Hi,
>
> How can I implement multiple user roles in Play!, with each having
> role-specific permissions and views, and what would be an appropriated
> database scheme?
>
> Basically, I have these roles:
>
>   - Administrator
>   - Organizer
>   - Contestant
>   - Unregistered (not authenticated or anonymous)
>
> Each of those roles has different permissions and views within the web
> application.
>
> Is the Secure module sufficient for this purpose? If yes, are the any
> code examples you can provide? Well, I would be thankful if you can
> give me the basic idea, because I can't wrap my head around this.
>
> There is this question on the list, which is very similar to mine:http://groups.google.com/group/play-framework/browse_thread/thread/7f...

Gustavo Arjones

unread,
Mar 9, 2011, 8:57:58 AM3/9/11
to play-fr...@googlegroups.com
Hi Kenny,
Have you go forward with this solution? I have same needs for my project.
I'm thinking we could work together to write a solution as a module.

I used to work with Microsoft Membership on my ASP.net/C# days. And I think we could be inspired, take ideas from their implementation:
http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx

Regards,
Gustavo

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>

Kenny Meyer

unread,
Mar 9, 2011, 10:56:08 AM3/9/11
to play-fr...@googlegroups.com
On Wed, Mar 9, 2011 at 6:10 AM, Steve Chaloner <steve.c...@gmail.com> wrote:
> If each user only has a single role, then the Secure module is what
> you need.  I can't really add more than what's detailed in
> http://www.playframework.org/documentation/1.1.1/secure and
> http://www.playframework.org/documentation/1.1.1/guide8 - these cover
> everything you need, and the example code of yabe can be used as a
> guide.  Check ${your play installation}/samples-and-tests/yabe for the
> yabe code.

Yes, the yabe application looks like a good starting point. I could
separate the admin interface from the "Anonymous" interface, but
currently I am stuck integrating the other roles. The documentation is
not very helpful in this case, which is sad.


> If each user can have more than one role, consider the deadbolt module
> - this allows you to and, or and not role combinations in your
> security restrictions.

I haven't thought about giving each user more than one role, but maybe
I will have to use deadbolt in the future.

Thank you very much for you help Steve!

> - Steve
>
> On Mar 9, 9:56 am, Kenny Meyer <knny.m...@gmail.com> wrote:
>> Hi,
>>
>> How can I implement multiple user roles in Play!, with each having
>> role-specific permissions and views, and what would be an appropriated
>> database scheme?
>>
>> Basically, I have these roles:
>>
>>   - Administrator
>>   - Organizer
>>   - Contestant
>>   - Unregistered (not authenticated or anonymous)
>>
>> Each of those roles has different permissions and views within the web
>> application.
>>
>> Is the Secure module sufficient for this purpose? If yes, are the any
>> code examples you can provide? Well, I would be thankful if you can
>> give me the basic idea, because I can't wrap my head around this.
>>
>> There is this question on the list, which is very similar to mine:http://groups.google.com/group/play-framework/browse_thread/thread/7f...
>> Consider the actual thread as a follow-up.
>>
>> Thanks -- Kenny
>

Kenny Meyer

unread,
Mar 9, 2011, 11:07:41 AM3/9/11
to play-fr...@googlegroups.com
Gustavo,

I don't know if I can help you, but I am interested and eager to learn.

Are you planning to complement the Secure module (like deadbolt) or
writing an Auth system from scratch like from the ASP.NET
implementation?

I am just an average Java developer (still, but I'm working on it),
with a stronger background in other programming languages like Python.

Feel free to contact me personally, if you want to talk.

Kenny

Gustavo Arjones

unread,
Mar 9, 2011, 11:26:16 AM3/9/11
to play-fr...@googlegroups.com
For my project I gonna need 3 parts (Authentication, Authorization and Audit).

I thought would be great create a Authentication module similar to ASP.net, with DB and "controls" so you have everything from the module, and connect with Deadbolt module - I don't think we should rewrite things there already done.

I gonna contact you in PVT, just wondering if someone else have the same needs and how they are thinking to solve it.

Regards,

Steve Chaloner

unread,
Mar 9, 2011, 1:11:00 PM3/9/11
to play-framework
I'm updating Deadbolt this evening to support dynamic user/resource
authorisation, if that's useful for you?

- Steve
> >>>http://groups.google.com/group/play-framework/browse_thread/thread/7f...
> >>> Consider the actual thread as a follow-up.
>
> >>> Thanks -- Kenny
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups "play-framework" group.
> >>> To post to this group, send email to play-fr...@googlegroups.com.
> >>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> >>> For more options, visit this group athttp://groups.google.com/group/play-framework?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "play-framework" group.
> >> To post to this group, send email to play-fr...@googlegroups.com.
> >> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/play-framework?hl=en.

Gustavo Arjones

unread,
Mar 9, 2011, 2:48:20 PM3/9/11
to play-fr...@googlegroups.com
It is great Steve! Certainly helps a lot!
Look forward for the new commit.

- Gustavo

Kenny Meyer

unread,
Mar 9, 2011, 6:50:24 PM3/9/11
to play-fr...@googlegroups.com, Steve Chaloner
> If each user can have more than one role, consider the deadbolt module
> - this allows you to and, or and not role combinations in your
> security restrictions.

Steve, it seems like deadbolt is exactly what I needed. The great
examples given in samples-and-tests/ made my day . :)

> On Mar 9, 9:56 am, Kenny Meyer <knny.m...@gmail.com> wrote:
>> Hi,
>>
>> How can I implement m

On Wed, Mar 9, 2011 at 6:10 AM, Steve Chaloner <steve.c...@gmail.com> wrote:
> If each user only has a single role, then the Secure module is what
> you need. I can't really add more than what's detailed in
> http://www.playframework.org/documentation/1.1.1/secure and
> http://www.playframework.org/documentation/1.1.1/guide8 - these cover
> everything you need, and the example code of yabe can be used as a
> guide. Check ${your play installation}/samples-and-tests/yabe for the
> yabe code.

>ultiple user roles in Play!, with each having
>> role-specific permissions and views, and what would be an appropriated
>> database scheme?
>>
>> Basically, I have these roles:
>>
>>   - Administrator
>>   - Organizer

>>   - Contestant> If each user can have more than one role, consider the deadbolt module


> - this allows you to and, or and not role combinations in your
> security restrictions.

Steve, it seems like deadbolt is exactly what I needed. The great
examples given in samples-and-tests/ made my day . :)

> On Mar 9, 9:56 am, Kenny Meyer <knny.m...@gmail.com> wrote:
>> Hi,
>>
>> How can I implement m

>>   - Unregistered (not authenticated or anonymous)
>>
>> Each of those roles has different permissions and views within the web
>> application.
>>
>> Is the Secure module sufficient for this purpose? If yes, are the any
>> code examples you can provide? Well, I would be thankful if you can
>> give me the basic idea, because I can't wrap my head around this.
>>
>> There is this question on the list, which is very similar to mine:http://groups.google.com/group/play-framework/browse_thread/thread/7f...
>> Consider the actual thread as a follow-up.
>>
>> Thanks -- Kenny
>

sas

unread,
Mar 9, 2011, 8:09:15 PM3/9/11
to play-framework
wel, I'll definitely have a look at deadbolt, I think I was about to
reinvent the wheel...

On 9 mar, 20:50, Kenny Meyer <knny.m...@gmail.com> wrote:
> > If each user can have more than one role, consider the deadbolt module
> > - this allows you to and, or and not role combinations in your
> > security restrictions.
>
> Steve, it seems like deadbolt is exactly what I needed. The great
> examples given in samples-and-tests/ made my day . :)
>
>
>
>
>
>
>
>
>
> > On Mar 9, 9:56 am, Kenny Meyer <knny.m...@gmail.com> wrote:
> >> Hi,
>
> >> How can I implement m
> On Wed, Mar 9, 2011 at 6:10 AM, Steve Chaloner <steve.chalo...@gmail.com> wrote:
> > If each user only has a single role, then the Secure module is what
> > you need.  I can't really add more than what's detailed in
> >http://www.playframework.org/documentation/1.1.1/secureand
> >http://www.playframework.org/documentation/1.1.1/guide8- these cover
Reply all
Reply to author
Forward
0 new messages