Commit 8e8e5729 authored by Mohammed Abdon's avatar Mohammed Abdon Committed by Commit Bot

Fix ChromeOS.SAML.Provider metrics with Azure

Currently Azure is recorded as Failure as it's certificate
looks quiet different and need some special handling.

Bug: 1081324
Change-Id: I66b4b9589df9a7fd242ec01e67d2fdba113bc986
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2197437Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Mohammed Abdon <mohammedabdon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768786}
parent 5bff9102
......@@ -41,21 +41,24 @@ void RecordSAMLProvider(const std::string& x509certificate) {
std::string provider;
if (!third_party_cert_list.empty() && third_party_cert_list[0] != nullptr &&
!third_party_cert_list[0]->subject().organization_names.empty()) {
provider = third_party_cert_list[0]->subject().organization_names[0];
if (!third_party_cert_list.empty() && third_party_cert_list[0] != nullptr) {
if (!third_party_cert_list[0]->subject().organization_names.empty()) {
provider = third_party_cert_list[0]->subject().organization_names[0];
} else {
// Some providers don't include organization name in the certifcate
provider = third_party_cert_list[0]->subject().common_name;
}
}
provider = base::ToLowerASCII(provider);
ChromeOSSamlProvider samlProvider;
if (provider.empty()) {
samlProvider = ChromeOSSamlProvider::kFailure;
LOG(WARNING) << "Failed to parse SAML provider certificate";
} else if (provider == "adfs") {
samlProvider = ChromeOSSamlProvider::kAdfs;
} else if (provider == "azure") {
} else if (provider == "microsoft azure federated sso certificate") {
samlProvider = ChromeOSSamlProvider::kAzure;
} else if (provider == "okta") {
samlProvider = ChromeOSSamlProvider::kOkta;
......
......@@ -550,6 +550,11 @@ cr.define('cr.login', function() {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(samlResponse, 'text/xml');
let certificate = xmlDoc.getElementsByTagName('ds:X509Certificate');
if (!certificate || certificate.length == 0) {
// tag 'ds:X509Certificate' doesn't exist
certificate = xmlDoc.getElementsByTagName('X509Certificate');
}
if (certificate && certificate.length > 0 && certificate[0].childNodes &&
certificate[0].childNodes[0] &&
certificate[0].childNodes[0].nodeValue) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment