so i use google authentication to validate the users on our system here is my code
public IActionResult Login()
{
System.IO.File.WriteAllText("log.txt", Url.Action("ExternalLoginCallback"));
return new ChallengeResult(
GoogleDefaults.AuthenticationScheme,
new AuthenticationProperties
{
RedirectUri = Url.Action("ExternalLoginCallback")
});
}
public IActionResult ExternalLoginCallback()
{
System.IO.File.AppendAllText("log.txt", "I am redirected");
var authenticateResult = HttpContext.AuthenticateAsync("External").Result;
if (!authenticateResult.Succeeded)
return BadRequest(); // TODO: Handle this better.
var claimsIdentity = new ClaimsIdentity("Application");
claimsIdentity.AddClaim(authenticateResult.Principal.FindFirst(ClaimTypes.NameIdentifier));
claimsIdentity.AddClaim(authenticateResult.Principal.FindFirst(ClaimTypes.Email));
var identity = authenticateResult.Principal.Identities.FirstOrDefault();
if (identity != null)
{
var emailClaim = identity.Claims.FirstOrDefault(c => c.Type.ToLower().Contains("emailaddress"));
if (emailClaim == null)
{
return BadRequest();
}
var emailData = emailClaim.Value;
if (string.IsNullOrEmpty(emailData))
{
return BadRequest();
}
var connectionString = _config.GetConnectionString("DefaultConnection");
UserBL userBL = new UserBL(connectionString);
var userModel = userBL.GetUserData(emailData);
if(userModel == null || userModel.HasError)
{
return BadRequest();
}
HttpContext.Session.SetString("UserData", JsonConvert.SerializeObject(userModel.Data));
if (userModel.Data.UserRoles.Any(r => r.Id == (int)UserRolesEnum.ProductOwner
|| r.Id == (int)UserRolesEnum.CopyEditor))
{
return RedirectToAction("Index", "Home");
}
else
{
return RedirectToAction("List", "Translation");
}
return RedirectToAction("UnAuthorized");
}
return BadRequest();
}
it worked fine users were redirected to google to enter their credentials and after that google redirects them back to the website till couple of days back google stopped redirecting back to the website and stays stuck on https://accounts.google.com.eg/accounts/SetSID
any pointers to how i can debug this or how to solve it
any help would be appreciated