Skip to content

Commit

Permalink
Improve password expiry error message for API based Authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
HasiniSama committed Sep 12, 2024
1 parent 29524ef commit 21b9b95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -43,13 +43,17 @@
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;

import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EnforcePasswordResetAuthenticationHandler extends AbstractPostAuthnHandler {

private static final Log log = LogFactory.getLog(EnforcePasswordResetAuthenticationHandler.class);
private static final String ENCODED_PASSWORD_EXPIRED_MSG = URLEncoder.encode(
PasswordPolicyConstants.PASSWORD_EXPIRED_ERROR_MESSAGE, StandardCharsets.UTF_8);

@Override
@SuppressFBWarnings("CRLF_INJECTION_LOGS")
Expand Down Expand Up @@ -171,7 +175,8 @@ private void redirectToPasswordResetPage(HttpServletResponse httpServletResponse
String confirmationCode) throws PostAuthenticationFailedException {

String queryString = PasswordPolicyConstants.CONFIRMATION_QUERY_PARAM + confirmationCode +
PasswordPolicyConstants.PASSWORD_EXPIRED_QUERY_PARAMS;
PasswordPolicyConstants.PASSWORD_EXPIRED_QUERY_PARAMS
+ PasswordPolicyConstants.PASSWORD_EXPIRED_MSG_QUERY_PARAM + PASSWORD_EXPIRED_MSG;
String passwordRestPage;
try {
passwordRestPage = PasswordPolicyUtils.getPasswordResetPageUrl(tenantDomain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class PasswordPolicyConstants {
public static final String FALSE = "false";
public static final String CONFIRMATION_QUERY_PARAM = "&confirmation=";
public static final String PASSWORD_EXPIRED_QUERY_PARAMS = "&passwordExpired=true";
public static final String PASSWORD_EXPIRED_MSG_QUERY_PARAM = "&passwordExpiredMsg=";
public static final String PASSWORD_EXPIRY_RULES_PREFIX = "passwordExpiry.rule";
public static final Integer MAX_PASSWORD_EXPIRY_RULE_VALUES = 5;

Expand Down

0 comments on commit 21b9b95

Please sign in to comment.