Issues with SignInAsync on production server
# help-with-umbraco
t
Hi all, Localhost building - Fine Staging environment - Fine. I have a 3rd party SSO implementation with Umbraco 13. On everything all good I run the following: await _memberSignInManager.SignInAsync(memberIdentity, true); It is not working on production and I can see the ASP Identity cookies are not being set. I am at a bit of a loss what it could be. I have this in my startup to target production but this does not resolve the issue: if (_env.IsProduction()) { services.AddAuthentication(options => { options.DefaultAuthenticateScheme = IdentityConstants.ExternalScheme; options.DefaultSignInScheme = IdentityConstants.ExternalScheme; options.DefaultScheme = IdentityConstants.ExternalScheme; }) .AddCookie(options => { options.ExpireTimeSpan = TimeSpan.FromDays(7); }); } I of course have: app.UseAuthentication(); app.UseAuthorization(); Could anyone help point me in the right direction?
I should add that the live server is going through cloudflare if that helps anyone
m
Hi! Could you explain more about “not working”? 🙂 Any errors? I’ve seen issues where redirects (e.g. remove/add trailing slash) make form posts to be redirected hence loose the body. Are you use that the endpoint/controller is hit with populated data?
t
Hi Markus. I interact with the SSO, return and it has its refresh token, it allows you to then get the user data with that which I use to make or check member in Umbraco. All good. As I mentioned when this is fired: _memberSignInManager.SignInAsync(memberIdentity, true); It simply does not login. On the staging environment and localhost everything is all good. Other then no code which checks isAuthenticated working of course on the site the two cookies that exist are not created. .AspNetCore.Antiforgery And .AspNetCore.Identity.Application
bool isAuthenticated = _httpContextAccessor.HttpContext?.User.Identity?.IsAuthenticated ?? false; This returns true But I cant access secure pages _httpContextAccessor.HttpContext?.User (httpContextAccessor) does not seem to work
This issue got worked out. The .net/windows login functionality must have an IP portion to it. The Production runs through cloudflare and without IP forwarding this was preventing it from functioning correctly. As I mentioned Umbraco sees you logged in but the httpContext simply does not work without the understanding of the correct IP it seems
43 Views