我正在阅读 Okta 对应用程序的响应如下。请让我知道是否有 nuget 包或开源类来读取属性。
var xml = HttpContext.Request.Form["SAMLResponse"];
byte[] byteData = Convert.FromBase64String(xml);
string samlXmlString = Encoding.UTF8.GetString(byteData);
var stream = new StringReader(samlXmlString);
var xmlReader = XmlReader.Create(stream);
XmlDocument doc = new XmlDocument();
doc.LoadXml(samlXmlString);
var emailElement = doc.GetElementsByTagName("saml2:NameID");
var attributes = doc.GetElementsByTagName("saml2:Attribute");
var attributesValues = doc.GetElementsByTagName("saml2:AttributeValue");
var username = emailElement[0].InnerText;
var role = attributesValues[0].InnerText;