Web: SSO: Fix setFields by api response config
This commit is contained in:
parent
71f7cea44e
commit
ed67603126
@ -129,7 +129,7 @@ class SsoFormStore {
|
|||||||
this.isSsoEnabled = res.enableSso;
|
this.isSsoEnabled = res.enableSso;
|
||||||
this.spMetadata = res.enableSso;
|
this.spMetadata = res.enableSso;
|
||||||
this.defaultSettings = res;
|
this.defaultSettings = res;
|
||||||
this.setFieldsFromObject(res);
|
this.setFields(res);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
@ -349,40 +349,94 @@ class SsoFormStore {
|
|||||||
|
|
||||||
resetForm = async () => {
|
resetForm = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await resetSsoForm();
|
const config = await resetSsoForm();
|
||||||
|
|
||||||
this.setFieldsFromObject(response);
|
this.setFields(config);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toastr.error(err);
|
toastr.error(err);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
setFieldsFromObject = (object) => {
|
setFields = (config) => {
|
||||||
for (let key of Object.keys(object)) {
|
const {
|
||||||
if (typeof object[key] !== "object") {
|
enableSso,
|
||||||
this[key] = object[key];
|
idpSettings,
|
||||||
} else {
|
idpCertificates,
|
||||||
let prefix = "";
|
idpCertificateAdvanced,
|
||||||
|
spLoginLabel,
|
||||||
|
spCertificates,
|
||||||
|
spCertificateAdvanced,
|
||||||
|
fieldMapping,
|
||||||
|
hideAuthPage,
|
||||||
|
} = config;
|
||||||
|
const { entityId, ssoBinding, sloBinding, nameIdFormat } = idpSettings;
|
||||||
|
const {
|
||||||
|
verifyAlgorithm,
|
||||||
|
verifyAuthResponsesSign,
|
||||||
|
verifyLogoutRequestsSign,
|
||||||
|
verifyLogoutResponsesSign,
|
||||||
|
decryptAlgorithm,
|
||||||
|
decryptAssertions,
|
||||||
|
} = idpCertificateAdvanced;
|
||||||
|
const { firstName, lastName, email, title, location, phone } = fieldMapping;
|
||||||
|
|
||||||
if (key === "idpSettings") {
|
const {
|
||||||
this.setSsoUrls(object[key]);
|
signingAlgorithm,
|
||||||
this.setSloUrls(object[key]);
|
signAuthRequests,
|
||||||
}
|
signLogoutRequests,
|
||||||
|
signLogoutResponses,
|
||||||
|
encryptAlgorithm,
|
||||||
|
decryptAlgorithm: spDecryptAlgorithm,
|
||||||
|
encryptAssertions,
|
||||||
|
} = spCertificateAdvanced;
|
||||||
|
|
||||||
if (key !== "fieldMapping" && key !== "idpSettings") {
|
this.enableSso = enableSso;
|
||||||
prefix = key.includes("idp") ? "idp" : "sp";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(object[key])) {
|
// idpSettings
|
||||||
this[`${prefix}Certificates`] = object[key].slice();
|
this.entityId = entityId;
|
||||||
} else {
|
this.ssoBinding = ssoBinding;
|
||||||
for (let field of Object.keys(object[key])) {
|
this.setSsoUrls(idpSettings);
|
||||||
this[`${prefix}${field}`] = object[key][field];
|
|
||||||
}
|
this.sloBinding = sloBinding;
|
||||||
}
|
this.setSloUrls(idpSettings);
|
||||||
}
|
|
||||||
}
|
this.nameIdFormat = nameIdFormat;
|
||||||
|
|
||||||
|
//idpCertificates
|
||||||
|
this.idpCertificates = [...idpCertificates];
|
||||||
|
|
||||||
|
//idpCertificateAdvanced
|
||||||
|
this.idpVerifyAlgorithm = verifyAlgorithm;
|
||||||
|
this.idpVerifyAuthResponsesSign = verifyAuthResponsesSign;
|
||||||
|
this.idpVerifyLogoutRequestsSign = verifyLogoutRequestsSign;
|
||||||
|
this.idpVerifyLogoutResponsesSign = verifyLogoutResponsesSign;
|
||||||
|
this.idpDecryptAlgorithm = decryptAlgorithm;
|
||||||
|
this.ipdDecryptAssertions = decryptAssertions;
|
||||||
|
|
||||||
|
this.spLoginLabel = spLoginLabel;
|
||||||
|
|
||||||
|
//spCertificates
|
||||||
|
this.spCertificates = [...spCertificates];
|
||||||
|
|
||||||
|
//spCertificateAdvanced
|
||||||
|
this.spSigningAlgorithm = signingAlgorithm;
|
||||||
|
this.spSignAuthRequests = signAuthRequests;
|
||||||
|
this.spSignLogoutRequests = signLogoutRequests;
|
||||||
|
this.spSignLogoutResponses = signLogoutResponses;
|
||||||
|
this.spEncryptAlgorithm = encryptAlgorithm;
|
||||||
|
this.spDecryptAlgorithm = spDecryptAlgorithm;
|
||||||
|
this.spEncryptAssertions = encryptAssertions;
|
||||||
|
|
||||||
|
//fieldMapping
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.email = email;
|
||||||
|
this.title = title;
|
||||||
|
this.location = location;
|
||||||
|
this.phone = phone;
|
||||||
|
|
||||||
|
this.hideAuthPage = hideAuthPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
setSsoUrls = (o) => {
|
setSsoUrls = (o) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user