Skip to content

Commit

Permalink
Merge pull request #7224 from PasinduYeshan/migration/rule-based-pass…
Browse files Browse the repository at this point in the history
…word-expiry

Hide rule-based password expiry for users missing required scopes
  • Loading branch information
PasinduYeshan authored Jan 6, 2025
2 parents 6aca12c + 058e4a4 commit 18ad315
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .changeset/lemon-pets-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@wso2is/admin.core.v1": patch
"@wso2is/admin.validation.v1": patch
"@wso2is/console": patch
---

Disable rule based password expiry for users without required scopes
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,37 @@
]
},
{% endif %}
{% if console.rule_based_password_expiry is defined %}
"ruleBasedPasswordExpiry": {
"disabledFeatures": [
{% if console.rule_based_password_expiry.disabled_features is defined %}
{% for feature in console.rule_based_password_expiry.disabled_features %}
"{{ feature }}"{{ "," if not loop.last }}
{% endfor %}
{% endif %}
],
"enabled": {% if console.rule_based_password_expiry.enabled is defined %} {{ console.rule_based_password_expiry.enabled }},
{% else %} true,
{% endif %}
"scopes": {
{% if console.rule_based_password_expiry.scopes is defined %}
{% for operation, scopes in console.rule_based_password_expiry.scopes.items() %}
"{{ operation }}": [
{% for scope in scopes %}
"{{ scope }}"{{ "," if not loop.last }}
{% endfor %}
]{{ "," if not loop.last }}
{% endfor %}
{% else %}
"create": [],
"read": [],
"feature": [],
"update": [],
"delete": []
{% endif %}
}
},
{% endif %}
{% if console.server is defined %}
"server": {
"disabledFeatures": [
Expand Down
23 changes: 20 additions & 3 deletions apps/console/src/public/deployment.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,7 @@
"console:loginAndRegistration"
],
"read": [
"internal_governance_view",
"internal_group_mgt_view",
"internal_role_mgt_view"
"internal_governance_view"
],
"update": [
"internal_config_update",
Expand Down Expand Up @@ -940,6 +938,25 @@
]
}
},
"ruleBasedPasswordExpiry": {
"disabledFeatures": [],
"enabled": true,
"scopes": {
"create": [],
"delete": [],
"feature": [],
"read": [
"internal_governance_view",
"internal_group_mgt_view",
"internal_role_mgt_view"
],
"update": [
"internal_config_update",
"internal_governance_update",
"internal_validation_rule_mgt_update"
]
}
},
"saml2Configuration": {
"disabledFeatures": [],
"enabled": true,
Expand Down
4 changes: 4 additions & 0 deletions features/admin.core.v1/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ export interface FeatureConfigInterface {
* Resident Outbound Provisioning feature
*/
residentOutboundProvisioning?: FeatureAccessConfigInterface;
/**
* Rule based password expiry feature
*/
ruleBasedPasswordExpiry?: FeatureAccessConfigInterface;
/**
* Connection management feature.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export class ValidationConfigConstants {
PASSWORD_MIN_VALUE: 5
};

/**
* Set of keys used to enable/disable features.
*/
public static readonly FEATURE_DICTIONARY: Map<string, string> = new Map<string, string>()
.set("RULE_BASED_PASSWORD_EXPIRY", "validation.ruleBasedPasswordExpiry");;
}

/**
Expand Down
17 changes: 12 additions & 5 deletions features/admin.validation.v1/pages/validation-config-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const ValidationConfigEditPage: FunctionComponent<MyAccountSettingsEditPa
state?.config?.ui?.isPasswordInputValidationEnabled);
const disabledFeatures: string[] = useSelector((state: AppState) =>
state?.config?.ui?.features?.loginAndRegistration?.disabledFeatures);
const isRuleBasedPasswordExpiryDisabled: boolean = disabledFeatures?.includes("ruleBasedPasswordExpiry");
const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state?.config?.ui?.features);
const maxPasswordLengthLimit: number = useSelector((state: AppState) =>
state?.config?.ui?.passwordPolicyConfigs?.maxPasswordAllowedLength);
Expand Down Expand Up @@ -140,6 +139,11 @@ export const ValidationConfigEditPage: FunctionComponent<MyAccountSettingsEditPa
const [ legacyPasswordPolicies, setLegacyPasswordPolicies ] = useState<ConnectorPropertyInterface[]>([]);

const isReadOnly: boolean = !useRequiredScopes(featureConfig?.governanceConnectors?.scopes?.update);
const hasRuleBasedPasswordExpiryReadPermissions: boolean =
useRequiredScopes(featureConfig?.ruleBasedPasswordExpiry?.scopes?.read);
const isRuleBasedPasswordExpiryDisabled: boolean =
disabledFeatures?.includes(ValidationConfigConstants.FEATURE_DICTIONARY.get("RULE_BASED_PASSWORD_EXPIRY"))
|| !hasRuleBasedPasswordExpiryReadPermissions;

const {
data: passwordHistoryCountData,
Expand Down Expand Up @@ -604,12 +608,15 @@ export const ValidationConfigEditPage: FunctionComponent<MyAccountSettingsEditPa

const processedFormValues: ValidationFormInterface = {
...values,
passwordExpiryEnabled: passwordExpiryEnabled,
passwordExpiryRules: processPasswordExpiryRules(),
passwordExpirySkipFallback: passwordExpirySkipFallback,
passwordExpiryTime: defaultPasswordExpiryTime
passwordExpiryEnabled: passwordExpiryEnabled
};

if (!isRuleBasedPasswordExpiryDisabled) {
processedFormValues.passwordExpiryRules = processPasswordExpiryRules();
processedFormValues.passwordExpirySkipFallback = passwordExpirySkipFallback;
processedFormValues.passwordExpiryTime = defaultPasswordExpiryTime;
}

const updatePasswordPolicies: Promise<void> = serverConfigurationConfig.processPasswordPoliciesSubmitData(
processedFormValues,
!isPasswordInputValidationEnabled
Expand Down

0 comments on commit 18ad315

Please sign in to comment.