Skip to content

Commit

Permalink
Restrict modifying configurations for Enterprise IDP Login Applications
Browse files Browse the repository at this point in the history
  • Loading branch information
sumedhe committed May 10, 2022
1 parent ac14cdc commit c826a8d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
11 changes: 10 additions & 1 deletion apps/console/src/extensions/configs/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ export const applicationConfig: ApplicationConfig = {
renderHelpPanelItems: (): ReactNode => {
return null;
},
showProvisioningSettings: true
showProvisioningSettings: true,
showDangerZone: (applicationName: string): boolean => {
return true;
},
showDeleteButton: (applicationName: string): boolean => {
return true;
},
getTabPanelReadOnlyStatus: (tabPanelName: string, applicationName: string): boolean => {
return false;
}
},
excludeIdentityClaims: false,
excludeSubjectClaim: false,
Expand Down
3 changes: 3 additions & 0 deletions apps/console/src/extensions/configs/models/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export interface ApplicationConfig {
extendTabs: boolean; //should be true for cloud
showProvisioningSettings: boolean;
renderHelpPanelItems: () => ReactNode;
showDangerZone: (applicationName: string) => boolean;
showDeleteButton: (applicationName: string) => boolean;
getTabPanelReadOnlyStatus: (tabPanelName: string, applicationName: string) => boolean;
};
inboundOIDCForm: {
shouldValidateCertificate: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
ApplicationTemplateListItemInterface
} from "../models";
import { ApplicationTemplateManagementUtils } from "../utils";
import { applicationConfig } from "../../../extensions";

/**
*
Expand Down Expand Up @@ -380,7 +381,8 @@ export const ApplicationList: FunctionComponent<ApplicationListPropsInterface> =

return hasScopes ||
isSystemApp ||
(app?.access === ApplicationAccessTypes.READ);
(app?.access === ApplicationAccessTypes.READ) ||
!applicationConfig.editApplication.showDeleteButton(app.name);
},
icon: (): SemanticICONS => "trash alternate",
onClick: (e: SyntheticEvent, app: ApplicationListItemInterface): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ export const EditApplication: FunctionComponent<EditApplicationPropsInterface> =
onUpdate={ handleApplicationUpdate }
featureConfig={ featureConfig }
template={ template }
readOnly={ readOnly }
readOnly={ readOnly || applicationConfig.editApplication.getTabPanelReadOnlyStatus(
"APPLICATION_EDIT_GENERAL_SETTINGS", application.name) }
data-testid={ `${ testId }-general-settings` }
isManagementApp={ application.isManagementApp }
/>
Expand Down Expand Up @@ -620,7 +621,8 @@ export const EditApplication: FunctionComponent<EditApplicationPropsInterface> =
inboundProtocols={ inboundProtocolList }
featureConfig={ featureConfig }
template={ template }
readOnly={ readOnly }
readOnly={ readOnly || applicationConfig.editApplication.getTabPanelReadOnlyStatus(
"APPLICATION_EDIT_ACCESS_CONFIG", application.name) }
data-testid={ `${ testId }-access-settings` }
/>
</ResourceTab.Pane>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
ApplicationTemplateListItemInterface
} from "../../models";
import { GeneralDetailsForm } from "../forms";
import { applicationConfig } from "../../../../extensions";

/**
* Proptypes for the applications general details component.
Expand Down Expand Up @@ -237,6 +238,10 @@ export const GeneralApplicationSettings: FunctionComponent<GeneralApplicationSet
return null;
}

if (!applicationConfig.editApplication.showDangerZone(name)) {
return null;
}

if (hasRequiredScopes(
featureConfig?.applications, featureConfig?.applications?.scopes?.delete, allowedScopes)) {
return (
Expand Down

0 comments on commit c826a8d

Please sign in to comment.