Reputation: 1150
Using WIF with .NET 4.5 in MVC4 app with Ninject
Here's the situation - I have a custom ClaimsAuthenticationManager
subclass called TenantAccessClaimsAuthenticationManager
that does some claims transformation. The TenantAccessClaimsAuthenticationManager
needs a IRepository object to be injected into it (using ninject).
The .NET 4.5 impl of WIF suggests that I can stick my custom claims authentication manager in the web.config - however, this approach can only instantiate the object via a no-args ctor.
The second approach I had is to not have anything int the web.config, but in App_start
, get a handle to the WIF configuration and stick in the TenantAccessClaimsAuthenticationManager
in RegisterServices
How do I get a handle to the currently application's WIF configuration context? MSDN docs aren't helping.
Edit: Obviously the problem is that the onServiceConfigurationCreated
event is no longer available. What's the best way to do this now
Upvotes: 2
Views: 830
Reputation: 18482
The event is still available!
code://System.IdentityModel.Services:4.0.0.0:b77a5c561934e089/System.IdentityModel.Services.FederatedAuthentication/event:FederationConfigurationCreated:System.EventHandler
More specifically, the event is available at FederatedAuthentication.FederationConfigurationCreated. An example implementation is below:
FederatedAuthentication.FederationConfigurationCreated += (sender, e) => {
e.FederationConfiguration.IdentityConfiguration.ClaimsAuthenticationManager = new MyCustomClaimsAuthenticationManager();
}
There's a blog post at http://dunnry.com/blog/2012/12/20/SettingClaimsAuthenticationManagerProgrammaticallyInNET45.aspx with more information.
Upvotes: 3