I have an application I am logging in using the One time password generated throuth the same web site but after Logging in the user is shown as logged in and when it redirects to another page the authentication details are lost and the user is not authenticated
any more....
How to configure the application to persist the authentication Details throughout the application?
You need to create a WIF authentication session for the user (not ASP.NET sessions, BTW):
var sessionToken = new SessionSecurityToken(principal, TimeSpan.FromHours(8));
FederatedAuthentication.SessionAuthenticationModule.WriteSessionTokenToCookie(sessionToken);
Also, disable forms auth -- you need to get rid of any use of it since you're using WIF as the framework.
Or if you dont want the Federated aauthentication just create the session and post the credential in some keyword in the session and access it for the authentication details. maintain the session accross the application. that will maintain the authentication
accross tha application.
</div>
Marked as answer by Mayur Rathi on Aug 09, 2012 09:22 AM
Mayur Rathi
Member
31 Points
28 Posts
How to set authentication for across the same application
Aug 01, 2012 12:03 PM|LINK
Hello,
I have an application I am logging in using the One time password generated throuth the same web site but after Logging in the user is shown as logged in and when it redirects to another page the authentication details are lost and the user is not authenticated any more....
How to configure the application to persist the authentication Details throughout the application?
The code for log in used isas follow
ClaimsIdentity objClaim = new ClaimsIdentity(AuthenticationTypes.Password, System.IdentityModel.Claims.ClaimTypes.Name, "Recipient");//(ClaimsIdentity)MyIdentity; objClaim.Claims.Add(new Claim(System.IdentityModel.Claims.ClaimTypes.Name, FirstName)); objClaim.Claims.Add(new Claim(ClaimTypes.AuthenticationMethod,"Level3")); objClaim.Claims.Add(new Claim(ClaimTypes.Name, objPostingRecipientBusiness.FirstName)); String[] Roles = { "Recipient" }; GenericPrincipal MyPrincipal = new GenericPrincipal(objClaim, Roles); IPrincipal Identity = (IPrincipal)MyPrincipal; HttpContext.User=Identity; Thread.CurrentPrincipal = MyPrincipal; FormsAuthentication.SetAuthCookie(FirstName, false);Am I missing some configuration....
Mayur Rathi
Member
31 Points
28 Posts
Re: How to set authentication for across the same application
Aug 09, 2012 09:22 AM|LINK
You need to create a WIF authentication session for the user (not ASP.NET sessions, BTW):
Also, disable forms auth -- you need to get rid of any use of it since you're using WIF as the framework.
Or if you dont want the Federated aauthentication just create the session and post the credential in some keyword in the session and access it for the authentication details. maintain the session accross the application. that will maintain the authentication accross tha application.
</div>