There's a couple of us working on integrating/ further enhancing authorization in Wicket. With this email, I'd like to start a (hopefully short) discussion to get things really clear. For the framework, we should be concerned to have the basic support there without actually implementing one specific solution. Like checkAcces is now.
For authorization, we roughly have to following scenarios: 1. Component visibility. Components should only be rendered when they are allowed to be rendered. Example: you can have a page with a number of panels, of which you only want to render the subset that is available to the current user. This can be done now by overriding isVisible. I'd prefer a more specialized manner for authorization, so that it can easily be used as e.g. a pluggable strategy. 2. Component execution. 'Component code' should only be executed when allowed. a) Event methods like Link.onClick. This can be done by a method like the recently added beforeCallComponent. I'd prefer not to use that method, but to introduce a new one that is executed just before 'beforeCallComponent', so that we keep 'beforeCallComponent' clean (and thus users don't have to worry about calling super.beforeCallComponent).. b) Construction time. That's a hard one. Makes sense for e.g. bookmarkable pages, but would not be good for constructions like setPage(new SomePage()). Currently, Page.checkAccess is called first thing in onRender. Imo, that's the wrong place conceptually, as it should have been called much earlier. E.g. when a bookmarkable page is accessed by a users that shouldn't, all the construction code is executed - possibly executing stuff you don't want to execute in case a user doesn't have access to the page. Practically, this might be the only place where it makes sense using methods like we do now, as we can't call virtual methods from constructors. 3. References to components. Components/ resources should only be rendered when they reference allowed resources. Example: a link should not be rendered when it references a page that the current user doesn't have access to. Probably the only 'enforcement point' is to put checks in all urlFor methods that we have. These are a bit scattered, and it couldn't prevent users from constructing e.g. links without calling urlFor, but it covers all normal behaviour. Now, to sum up, the cases I sketched above are very different. It can not be one simple method that covers all. I think the most elegant would be to come up with a interface that enables users to plug in their own strategy for authentication. The methods of the interface should cover the above cases. In the case of 1 and 3, it should just return a boolean, so that checking is cheap and quick; I can't think of an actual case where you want to bubble up a message on why access was not allowed. In the case of 2, I think such an access checking method should throw a checked exception, possibly providing a reason for dissalowing access. Case 2 should be relatively rare (really an exception so to speak), and represents a case that, while not recoverable, potentially requires information to be bubbled up (that's why it needs a checked exception). Having such an interface will not give users an out-of-the-box working solution for authorization in Wicket. My idea is however, that this should enable for building working implementations for specific situations, like combined with annotations, Spring Acegi, etc. I'm still in thinking mode, so maybe I forgot implications, and I don't have a concrete idea about the interface yet, but I hope this email is a good start. Eelco ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop
