Silverlight, loading authorization rules from database

Silverlight, loading authorization rules from database

Old forum URL:

mesh posted on Tuesday, June 29, 2010

What would be the most efficient way to load authorization rules from the database, especially when it comes to Silverlight?

1) I already have users, roles, permissions class model
2) I have a BusinessBase base class where I can override AddAuthorizationRules
3) If I try to load the permissions from the database (in AddAuthorizationRules), authorization rules are loaded after the object has been used (because of async DataPortal call, in unit tests).
4) I think the best solution is to load all the privileges in a static property that is shared by both server side and Silverlight. But I do not know how, when and where.

Can someone please point me in the right direction?


RockfordLhotka replied on Tuesday, June 29, 2010

Yes, the async nature of SL makes this more complex.

What I've been doing is using a unit of work object (in my case a ReadOnlyBase subclass) to go retrieve the metadata as the app loads. I block the app's navigation system (the toolbar or whatever) until the metadata is available.

I do the same thing for the login process - block navigation until the identity object has come back from the server.

If you have a lot of metadata this might cause too much of a startup delay - in which case you might consider loading the metadata in chunks - and unlocking parts of the navigation system as the various chunks of metadata come back from the server.

mesh replied on Tuesday, June 29, 2010

Thanks Rocky.
Yes,  UI based solution would be easy. I was thinking more of unit tests with permissions stored in database.
Calling objects directly in VM or code behind would be another example. What is the best way to override AddAuthorizationRules in similar situations?

Copyright (c) Marimer LLC