[coldbox-3.5.3] Dynamically Loading Modules

So…I think I know how I want to do this but need some confirmations.

In order to make this application modular based on either the users permissions (or maybe something else), key functional groups will be housed in modules and will either work/not work be visible/invisible according to those user permissions. Since I can easily load the modules via the moduleservice and can data-drive this, I think it’s completely do-able. But I have always been of the philosophy that just because you can do a thing does not mean you should. I also have found that I am always better off letting frameworks do most of the thinking for me.

Option 1
Exclude ALL modules (except one perhaps)

In this design, ALL modules are excluded then, after configuration loads, I can check to see if a user is logged in and if so, manually load the modules that the user can see.

Option 2
Include ALL modules and disable as needed

In this design, ALL modules are included, loaded via the framework as they need to be, use settings in config() and after modules loads set environment variables and keys, etc. One key difference here is that modules settings that dictate how the user can interact may all initially need to be set to “fully working” then those values have to be reset before any rendering occurs.

Option 3
Include ALL modules and secure/disable functionality on the fly

In this design, everything loads and is enabled as the framework wants them to be and if the user tries to interact with something, the module has to determine the course of action.

For me, all have pros and cons. Truthfully, I want this to be dynamic so ideally I’d like to exclude everything by default and load what I want, when I want. I also want the order of the load to be dynamically driven which further makes the include options a bit less tenable, though not impossible to manage. I have a service-controller class that interact and collect module settings to determine visual interaction, etc. so its not absolutely necessary.

I think I can visualize how all these options might work and have been getting better and better at CB so I’m much more comfortable now than I was maybe six months ago…but has anyone tried some of these options, or others to achieve dynamic / secured module loading that could share some experience? Is there a “best” way to manage this?

Thanks,
Mike Craig

Option 3 is what I would consider the best option, except you can disable a module if the module is needed for another user. So the best course of action is to lock down with security rules.

I agree…after I typed out all that thinking I started to realize how bad an idea it is to include individual user security in the load process. Must have been lack of sleep…so that is OFF the table.

So I’m only focusing the thinking of dynamic loading as it relates to the applications visual “state”…and the more I think about it…just load everything and after they are loaded, use the service-controller singleton to determine the order of display information (the modules provide a tab to the user interface).

Taking the security out of the thinking made a big difference…thanks for slapping me up against the head…DOH!

Mike

No problems Mike, but if you haven’t seen ContentBox it has the ability to load modules or disable them. That might give you a direction in how to load them if you want to go down that route for in your application.

EXCELLENT idea…I will do that