User Authentication in separate module - question

Topics: CAB & Smart Client Software Factory
Jan 3, 2007 at 4:46 AM
I would like to put my user authentication code in a separate module/assembly so that it may be easily re-used in other projects and applications. I used the Bank Teller Workbench project as a model and used the SimpleWinFormAuthenticationService and UserSelectorService pretty much verbatim to test this out. The only difference is that I added these services to a separate Foundation Module called UserSecurity instead of leaving them in the Infrastructure.Library.

The problem is that AuthenticateUser gets called in the Run method of CABApplication before my UserSecurity module is even loaded. So CAB uses the default WindowsPrincipalAuthenticationService which will just take the user currently running the app. My AuthenticateUser method (in my UserSecurity module) never gets called.

Everything works fine, however, if I add the services within Infrastructure.Library (as the Bank Teller Workbench does). But this means I will need to add references to my UserSecurity assembly withing Infrastructure.Library and then they become tightly coupled.

I am new to both the CAB and SCSF, so if I am missing something please excuse my ignorance.

Any feedback on how to maintain loose coupling between Infrastructure.Library and my UserSecurity assembly would be greatly appreciated.

Jan 3, 2007 at 9:15 AM
These services must be added directly in your ShellApplication or in the /configuration/CompositeUI/services section of the config file.

You can package it all in the same assembly (or not) but it's not a CAB module.
Jan 6, 2007 at 2:42 AM
Duh...Sorry, I am having the same problem and your response seems too hard for me to understand :-)

Could you develop?


Jan 8, 2007 at 9:48 AM
In your ShellApplication class (or whatever class you have directly or indirectly derived from SmartClientApplication<TWorkItem, TShellForm> you have an AddServices method:

protected override void AddServices()
RootWorkItem.Services.AddOnDemand<MyService, IMyService>();

You can also add services using the configuration file (App.config in development time):

<add serviceType="IMyService" instanceType="MyService" />
Jan 9, 2007 at 1:56 PM
Nice! Now I get it!

Thank you for taking time to answer.