Skip to content

Commit

Permalink
Merge pull request wso2#4662 from savindi7/improvements-ws-fed-app
Browse files Browse the repository at this point in the history
Send inbound auth configuration details in the Passive STS application creation
  • Loading branch information
savindi7 authored Nov 18, 2023
2 parents de79c81 + 5851d0b commit daf8ee7
Showing 1 changed file with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/

import { Show } from "@wso2is/access-control";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { AlertLevels, TestableComponentInterface } from "@wso2is/core/models";
Expand Down Expand Up @@ -53,6 +54,7 @@ import { useDispatch, useSelector } from "react-redux";
import { Dispatch } from "redux";
import { Card, Checkbox, CheckboxProps, Dimmer, Divider, Grid } from "semantic-ui-react";
import { OauthProtocolSettingsWizardForm } from "./oauth-protocol-settings-wizard-form";
import { PassiveStsProtocolSettingsWizardForm } from "./passive-sts-protocol-settings-wizard-form";
import { SAMLProtocolAllSettingsWizardForm } from "./saml-protocol-settings-all-option-wizard-form";
import { applicationConfig } from "../../../../extensions";
import { AccessControlConstants } from "../../../access-control/constants/access-control";
Expand Down Expand Up @@ -259,6 +261,11 @@ export const MinimalAppCreateWizard: FunctionComponent<MinimalApplicationCreateW

handleError("all", false);

if (selectedTemplate.id === CustomApplicationTemplate.id &&
customApplicationProtocol === SupportedAuthProtocolTypes.WS_FEDERATION) {
return;
}

// If both `protocolFormValues` & `generalFormValues` are undefined, return.
if (!protocolFormValues && !generalFormValues) {
return;
Expand Down Expand Up @@ -351,9 +358,6 @@ export const MinimalAppCreateWizard: FunctionComponent<MinimalApplicationCreateW
}
);
}

} else if (customApplicationProtocol === SupportedAuthProtocolTypes.WS_FEDERATION) {
application.templateId = ApplicationManagementConstants.CUSTOM_APPLICATION_PASSIVE_STS;
}
}

Expand All @@ -369,7 +373,29 @@ export const MinimalAppCreateWizard: FunctionComponent<MinimalApplicationCreateW
}

setIsSubmitting(true);
createApp(application);

}, [ generalFormValues, protocolFormValues ]);

useEffect(() => {
if (!protocolFormValues) {
return;
}

const application: MainApplicationInterface = cloneDeep({
...templateSettings?.application,
...protocolFormValues,
name: generalFormValues.get("name").toString(),
templateId: ApplicationManagementConstants.CUSTOM_APPLICATION_PASSIVE_STS
});

if (customApplicationProtocol === SupportedAuthProtocolTypes.WS_FEDERATION && protocolFormValues) {
createApp(application);
}

}, [ protocolFormValues ]);

const createApp = (application: MainApplicationInterface): void => {
createApplication(application)
.then((response: AxiosResponse) => {
eventPublisher.compute(() => {
Expand Down Expand Up @@ -410,8 +436,8 @@ export const MinimalAppCreateWizard: FunctionComponent<MinimalApplicationCreateW
.catch((error: AxiosError) => {

if (error?.response?.status === 403 &&
error?.response?.data?.code ===
ApplicationManagementConstants.ERROR_CREATE_LIMIT_REACHED.getErrorCode()) {
error?.response?.data?.code ===
ApplicationManagementConstants.ERROR_CREATE_LIMIT_REACHED.getErrorCode()) {
setOpenLimitReachedModal(true);

return;
Expand Down Expand Up @@ -481,7 +507,7 @@ export const MinimalAppCreateWizard: FunctionComponent<MinimalApplicationCreateW
handleProtocolValueChange(false);
handleError("all", false);
});
}, [ generalFormValues, protocolFormValues ]);
};

const handleAppCreationComplete = (createdAppID: string): void => {
// The created resource's id is sent as a location header.
Expand Down Expand Up @@ -715,6 +741,16 @@ export const MinimalAppCreateWizard: FunctionComponent<MinimalApplicationCreateW
data-testid={ `${ testId }-saml-protocol-settings-form` }
/>
);
} else if (selectedProtocol === SupportedAuthProtocolTypes.WS_FEDERATION) {
return (
<PassiveStsProtocolSettingsWizardForm
triggerSubmit={ submitProtocolForm }
initialValues={ null }
templateValues={ templateSettings }
onSubmit={ (values: Record<string, any>): void => setProtocolFormValues(values) }
data-testid={ `${ testId }-passive-sts-protocol-settings-form` }
/>
);
}
};

Expand All @@ -728,7 +764,7 @@ export const MinimalAppCreateWizard: FunctionComponent<MinimalApplicationCreateW
};

const scrollToNotification = () => {
document.getElementById("notification-div").scrollIntoView({ behavior: "smooth" });
document.getElementById("notification-div")?.scrollIntoView({ behavior: "smooth" });
};

/**
Expand Down

0 comments on commit daf8ee7

Please sign in to comment.