• Post Reply Bookmark Topic Watch Topic
  • New Topic

Application Access Control List  RSS feed

 
steward frank
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have posted this message at General Java itermediate but it seems that there is no one who is able to answer me there so i just tot that i would try out here. I would just like to ask anyone out there who has ever programmed an application that allows an administrator(through a web interface) to control which page or option or field of a form are available and whether they are read only , editable or not, whether a user has the rights to delete or not based on the authorizations a person is given. I am sure there are applications out there that have been developed with such features but how messy or complicated were they?

currently, the only thing i coud think of is using custom tags and surrounding the element of a form and the custom tag will check if the current user as rights to element of this form, if the user does, the custom tag will display the element but if it doesnt, it will not. but however, this approach also has its disadvantages: what if i have client side scripting that references this element and the user does not have acccess rights to this element, wont that result in a javascript error? or do i have to surround the script that affects that element with a acl custom tag as well? if that is the case, wouldnt that be very messy? in such an approach, i think i would have to give a unique identifier to each and every element, page, form, and that information would be stored in the database but i think that would be extremely hardcoded cos the application needs to know the link between the identifier in the database and the element in form and for that to happen, the identifier of the element would have to hardcoded into the jsp page for example.

to programme an application with page control(controls which page a user can see or not) is not too difficult but to not only control that page access and also the visibility of those fields in that page and its properties such as editable or not, i think it might be quite a headache

if i were to store all these access control list information in a database, how would the information be organized ?

i have come across applications that store references to elements to a form in a page as a "page.form.element" string so that at first glance, it becomes immediately recognizable in the database to a human to which element in the form does this permission belong to and the application also uses this string(the identifier) to match its permissions according to the the user rights.

is there already a design pattern out there already for this issue? I hope seasoned developers might be able to give me some pointers or shed some light into this issue cos i think a lot of people might faced the same task and go about it in different ways, some better than the others , some worse

Thanks!!!
 
Fletcher Estes
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just some thoughts...

Your Javascript doesn't need to depend on anything being there (just check for NULL first, and act accordingly). Your tags don't need to take an all or nothing approach either:

1. Check the user's role
2. If this role has access to this form element, display it, otherwise put in a hidden field (avoids the Javascript null problem you had earlier).

As for how to store what roles can see what elements, you could assign a category to each element, or better each <div> section of a page, and then assign one or more categories to each role. These assignments could be stored in a DB and loaded in a HashMap at runtime.

At some point, you will have to bite the bullet and manually ID each <DIV> section, but it's not really that much work...
 
steward frank
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Fletcher,
Thanks for your input it definitely gave me something to chew on. but a couple of follow up questions.

"If this role has access to this form element, display it, otherwise put in a hidden field (avoids the Javascript null problem you had earlier)."

regarding the above: what if the form element is a select element, how am i going to make it hidden? what if this select element has options to it and the javascript references those options? well i could check for null for those elements, to check if they are in the form or not but wouldnt that make the javascript more complicated with checks for null here and there?

is there a better way?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I won't go near the JSP end, but on the database end this kind of thing is common:

User many-to-many Role

Role many-to-many Resource

User, Role and Resource are all just string names for things.

You can build APIs to say "does this user have access to this resource" or "give me all resources for this user". Avoid checking user against role so you can introduce new roles with new combinations of resources without touching the code.

In the database when you do many-to-many you build a little association table in between with the keys of the other two tables, eg RoleKey & ResourceKey. You can add more information to this table to allow or deny specific permissions, eg Create Retrieve Update Delete Execute etc. If you can navigate from user to resource through two different role paths, the common rule is to use the more restrictive path. So if I have one role that allows execute access to "change employee salary" and another role that denies access, the more restrictive wins and I can't do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!