So I need some help with the layout/structure of my project. I am making a website and so far I have a working login page which authenticates the user with Apache Shiro against an LDAP server and redirects the user to a splash page. Depending on the permissions the user has, they should/should not be able to view certain things on the splash page.
What I would like to do is create a new ShiroUser from the session information (i.e. the user who just logged in) and assign them some roles. So for example,
def shiroUser = new ShiroUser()
shiroUser.username = session.username
shiroUser.addToRoles(ShiroRole.findByName('ROLE_USER'))
shiroUser.save()
and ROLE_USER
would be defined by
def shiroRole = new ShiroRole()
shiroRole.name='ROLE_USER'
shiroRole.save()
Right now I'm just interested in hard coding it and later adapting it to look up in a table and assign roles based off of values in that table.
What I'm wondering is
- Where do I put this stuff?
- Do I create a new controller for this?
- Where do I define the shiroRoles?
- Is this even smart to do? (Creating a new ShiroUser every time someone logs in)
I've never built a website before, so I'm not sure how I should structure the code or where to put stuff. (I'm using GGTS by the way.) Some direction/advice would be greatly appreciated! I'm using lots of books like Grails in Action, Making Java Groovy, and The Definitive Guide to Grails 2 to help, but most of their examples don't match up with what I would like to do. If there are any tutorials out there that I haven't found, I am interested in seeing them. (I've looked through a lot, but they just have snippets of code like I listed, but don't specify where they actually go!)