Geneva Framework is a Framework is a Framework.
One part of that framework is the SessionAuthenticationModule for ASP.NET. In all the typical samples this is used to convert an incoming SAML token to a cookie to establish an authentication session.
A closer look reveals, that the purpose of this module is actually serializing SessionSecurityTokens into cookies. A SessionSecurityToken in turn is a container for an IClaimsPrincipal and an additional SecurityToken (the so called bootstrap token).
This means that the SessionAuthenticationModule is a general module and API to serialize claims principals and security tokens into cookies. In addition there is an extensible architecture around how these cookies are layed out and protected. You can utilize this infrastructure whenever you need to serialize and round-trip an IClaimsPrincipal.
Where can this be useful? Let’s do this little walkthrough…
First use the Visual Studio Geneva templates to create a simple “Claims-aware ASP.Net WebSite”. This sample uses the ClaimsPrincipalHttpModule to create an IClaimsPrincipal from the standard forms authentication principal.
In the next step add a ClaimsAuthenticationManager to the web site and register it, e.g.:
public class Transformer : ClaimsAuthenticationManager
public override IClaimsPrincipal Authenticate(string endpointUri, IClaimsPrincipal incomingPrincipal)
// expensive operation
Claim(“http://claims/expensive”, “expensive value”));
The custom claims you are adding in the authentication manager might come from some remote data store and you probably want to avoid such a round-trip on every request. To optimize this, you could come up with some server-local caching strategy – or use the SessionAuthenticationModule to serialize the IClaimsPrincipal after transformation to a cookie. The module will then reconstruct the IClaimsPrincipal on subsequest requests and set it as the current principal for the ASP.NET application.
First add the session authentication module to the modules section in web.config – then add this code to the authentication manager:
private void SetSessionCookie(IClaimsPrincipal incomingPrincipal)
SessionSecurityToken token = new SessionSecurityToken(incomingPrincipal);
Call this method before you return the transformed principal back to Geneva.
Note: When your app is not running over SSL – you need to set the requireSsl setting for the cookie handler in web.config to false.