Skip to content

Commit 4b18b6c

Browse files
committed
revisit password expiration policy templates customizations (#30)
Reading the Java class mentioned in issue #30, it seems that only 2 properties were modified in the original messages.properties from the classpath (what about the other languages ?). This commit should provide the same behaviour as the original PR. I had to reintroduce the pwdupdateform.html fragment from upstream, and customize the (hardcoded ?) URLs to get into the console webservices meant for password management. FTR, the original template is here: https://github.com/apereo/cas/blob/6.6.x/support/cas-server-support-thymeleaf/src/main/resources/templates/fragments/pwdupdateform.html BTW, it looks like CAS provides such password management from the user on its own code, via an optional module: https://apereo.github.io/cas/7.0.x/password_management/Password-Management-Reset.html but since we already have the feature provided by the console, it makes probably more sense to make use of them instead. Note: I am not sure why the `password.expiration.warning` does not seem to be used in any templates in the CAS6.6 codebase. Note2: we might want to be able to customize the console's endpoint url from the datadir, but since they were hardcoded in the java class, at least we are isofunctional here. tests: runtime, using https://github.com/georchestra/sample-docker-composition/tree/main/cas/password-expiration - tested with english & french locales.
1 parent dac6426 commit 4b18b6c

File tree

5 files changed

+169
-4
lines changed

5 files changed

+169
-4
lines changed

src/main/resources/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ screen.surrogates.button.cancel=Cancel
287287
screen.surrogates.account.selection.error=You are not authorized to impersonate the indicated user at this time.
288288

289289
# Password policy
290-
password.expiration.warning=Your password expires in {0} day(s). Please <a href="https://pm.example.edu">change your password</a> now.
290+
password.expiration.warning=Your password expires in {0} day(s). Please <a href="/console/account/changePassword">change your password</a> now.
291291
password.expiration.loginsRemaining=You have {0} login(s) remaining before you <strong>MUST</strong> change your password.
292292
screen.accountdisabled.heading=This account has been disabled.
293293
screen.accountdisabled.message=Please contact the system administrator to regain access.

src/main/resources/messages_de.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ screen.surrogates.button.cancel=Abbrechen
240240

241241

242242
# Password policy
243-
password.expiration.warning=Ihr Kennwort läuft in {0} Tagen ab. Bitte <a href\="{1}">ändern Sie Ihr Kennwort</a>.
243+
password.expiration.warning=Ihr Kennwort läuft in {0} Tagen ab. Bitte <a href="/console/account/changePassword">ändern Sie Ihr Kennwort</a>.
244244
password.expiration.loginsRemaining=Sie haben {0} Anmeldungen übrig, bevor Sie Ihr Kennwort ändern <strong>müssen</strong>.
245245
screen.accountdisabled.heading=Dieses Konto wurde deaktiviert.
246246
screen.accountdisabled.message=Bitte kontaktieren Sie Ihren System Administrator um wieder Zugriff zu erhalten.

src/main/resources/messages_es.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ screen.service.empty.error.message=El registro de servicios del CAS está vacío
6969
Las aplicaciones que quieren autenticar con CAS deben ser explícitamente definidas en el registro de servicios.
7070

7171
# Password policy
72-
password.expiration.warning=Su contraseña caduca en {0} días. Por favor <a href="{1}">cambie su contraseña</a> ahora.
72+
password.expiration.warning=Su contraseña caduca en {0} días. Por favor <a href="/console/account/changePassword">cambie su contraseña</a> ahora.
7373
password.expiration.loginsRemaining=Tiene {0} inicios de sesión restantes antes que <strong>DEBE</strong> cambiar su contraseña.
7474
screen.accountdisabled.heading=Se ha deshabilitado esta cuenta.
7575
screen.accountdisabled.message=Por favor contacte al administrador de sistema para recobrar acceso.

src/main/resources/messages_fr.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ screen.surrogates.button.cancel=Annuler
225225

226226

227227
# Password policy
228-
password.expiration.warning=Votre mot de passe expire dans {0} jour(s). Merci de <a href="{1}">changer votre mot de passe</a> maintenant.
228+
password.expiration.warning=Votre mot de passe expire dans {0} jour(s). Merci de <a href="/console/account/changePassword">changer votre mot de passe</a> maintenant.
229229
password.expiration.loginsRemaining=Il vous reste {0} authentification(s) avant de <strong>DEVOIR</strong> changer votre mot de passe.
230230
screen.accountdisabled.heading=Ce compte a été désactivé.
231231
screen.accountdisabled.message=Merci de contacter votre administrateur système pour récupérer votre accès.
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
7+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
8+
9+
<title>Password Update Form</title>
10+
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
11+
</head>
12+
13+
<body>
14+
<main role="main" class="container mt-3 mb-3">
15+
<div id="pwdmain" th:fragment="pwdupdateform">
16+
<script th:inline="javascript">
17+
/*<![CDATA[*/
18+
19+
var policyPattern = /*[[${passwordPolicyPattern}]]*/;
20+
var passwordStrengthI18n = {
21+
0: /*[[#{screen.pm.password.strength.0}]]*/,
22+
1: /*[[#{screen.pm.password.strength.1}]]*/,
23+
2: /*[[#{screen.pm.password.strength.2}]]*/,
24+
3: /*[[#{screen.pm.password.strength.3}]]*/,
25+
4: /*[[#{screen.pm.password.strength.4}]]*/
26+
};
27+
var passwordMinimumStrength = 0;
28+
29+
/*]]>*/
30+
</script>
31+
<h3 th:utext="${expiredPass}
32+
? #{screen.expiredpass.heading(${credential.id})}
33+
: #{screen.mustchangepass.heading(${credential.id})}">
34+
Change Password Heading</h3>
35+
36+
<form id="passwordManagementForm" th:if="${passwordManagementEnabled}" method="post"
37+
th:object="${password}">
38+
<div class="banner banner-danger alert alert-danger banner-dismissible my-4" th:if="${#fields.hasErrors('*')}">
39+
40+
<span th:each="err : ${#fields.errors('*')}" th:utext="${err}">Error text</span>
41+
</div>
42+
43+
<div class="cas-field my-3 mdc-input-group form-group d-flex">
44+
<div class="mdc-input-group-field mdc-input-group-field-append flex-grow-1">
45+
<div class="d-flex caps-check">
46+
47+
<label for="password"
48+
class="mdc-text-field caps-check mdc-text-field--outlined control-label mdc-text-field--with-trailing-icon">
49+
<input class="mdc-text-field__input form-control pwd"
50+
autocapitalize="none"
51+
spellcheck="false"
52+
type="password"
53+
name="password"
54+
id="password"
55+
th:field="*{password}"
56+
autocomplete="off" required/>
57+
<span class="mdc-notched-outline">
58+
<span class="mdc-notched-outline__leading"></span>
59+
<span class="mdc-notched-outline__notch">
60+
<span class="mdc-floating-label" th:utext="#{screen.pm.enterpsw}">Enter Password:</span>
61+
</span>
62+
<span class="mdc-notched-outline__trailing"></span>
63+
</span>
64+
</label>
65+
<i class="mdi mdi-alert mdc-text-field__icon text-danger caps-warn"></i>
66+
</div>
67+
</div>
68+
<button class="reveal-password align-self-end mdc-button mdc-button--raised mdc-input-group-append mdc-icon-button btn btn-primary"
69+
tabindex="-1" type="button">
70+
<i class="mdi mdi-eye reveal-password-icon fas fa-eye"></i>
71+
<span class="visually-hidden">Toggle Password</span>
72+
</button>
73+
</div>
74+
75+
<div class="cas-field form-group mdc-input-group my-3">
76+
<div class="d-flex caps-check">
77+
<label for="confirmedPassword" class="mdc-text-field mdc-text-field--outlined mdc-text-field--with-trailing-icon control-label">
78+
<input class="mdc-text-field__input form-control pwd"
79+
type="password"
80+
autocapitalize="none"
81+
spellcheck="false"
82+
name="confirmedPassword"
83+
id="confirmedPassword"
84+
th:field="*{confirmedPassword}"
85+
autocomplete="off" required/>
86+
87+
<span class="mdc-notched-outline">
88+
<span class="mdc-notched-outline__leading"></span>
89+
<span class="mdc-notched-outline__notch">
90+
<span class="mdc-floating-label" th:utext="#{screen.pm.confirmpsw}">Confirm Password:</span>
91+
</span>
92+
<span class="mdc-notched-outline__trailing"></span>
93+
</span>
94+
</label>
95+
<i class="mdi mdi-alert mdc-text-field__icon bs-hide text-danger caps-warn"></i>
96+
</div>
97+
</div>
98+
99+
<div class="cas-field form-group my-3 d-flex flex-column">
100+
<div class="d-flex align-items-center">
101+
<span th:text="#{screen.pm.password.strength}">Strength:</span>&nbsp;
102+
<span id="password-strength-icon" class="mdi" aria-hidden="true"></span>
103+
</div>
104+
<div id="strengthProgressBar" role="progressbar" class="d-none progress">
105+
<div id="progress-strength-indicator" class="progress-bar progress-bar-indicator text-center"></div>
106+
<div class="mdc-linear-progress">
107+
<div class="mdc-linear-progress__buffering-dots"></div>
108+
<div class="mdc-linear-progress__buffer"></div>
109+
<div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar" style="transform: scaleX(0);">
110+
<span class="mdc-linear-progress__bar-inner"></span>
111+
</div>
112+
<div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
113+
<span class="mdc-linear-progress__bar-inner"></span>
114+
</div>
115+
</div>
116+
</div>
117+
</div>
118+
<div class="cas-field form-group my-3 text-warning" id="password-strength-msg" style="display: none;">
119+
<div class="suggestions banner banner-warning alert alert-warning p-2 mb-2 d-flex align-items-center" role="alert">
120+
<span class="mdi mdi-information fas fa-info-circle" aria-hidden="true"></span>&nbsp;
121+
<p class="m-0">
122+
<span id="password-strength-warning"></span>&nbsp;
123+
<span id="password-strength-suggestions"></span>
124+
</p>
125+
</div>
126+
</div>
127+
<div class="cas-field form-group my-3 text-danger" id="password-strength-notes">
128+
<div id="password-policy-violation-msg" class="banner banner-danger alert alert-danger p-2" role="alert" style="display: none;">
129+
<span class="mdi mdi-alert fas fa-exclamation-triangle" aria-hidden="true"></span>&nbsp;
130+
<strong th:text="#{screen.pm.password.policyViolation}">Password does not match the password policy
131+
requirement.</strong>
132+
</div>
133+
<div id="password-confirm-mismatch-msg" class="banner banner-danger alert alert-danger p-2" role="alert" style="display: none;">
134+
<span class="mdi mdi-alert fas fa-exclamation-triangle" aria-hidden="true"></span>&nbsp;
135+
<strong th:text="#{screen.pm.password.confirmMismatch}">Passwords do not match.</strong>
136+
</div>
137+
</div>
138+
139+
<div class="cas-field form-group">
140+
<input type="hidden" name="execution" th:value="${flowExecutionKey}"/>
141+
<input type="hidden" name="_eventId" value="submit"/>
142+
<button class="mdc-button mdc-button--raised btn btn-primary me-2"
143+
name="submit"
144+
accesskey="s"
145+
th:value="#{screen.pm.button.submit}"
146+
th:attr="data-processing-text=#{screen.welcome.button.loginwip}"
147+
value="SUBMIT"
148+
id="submit"
149+
type="submit"
150+
disabled="true">
151+
<span class="mdc-button__label" th:text="#{screen.pm.button.submit}">Submit</span>
152+
</button>
153+
<a class="mdc-button mdc-button--outline btn btn-outline-secondary" th:href="@{/login}">
154+
<span class="mdc-button__label" th:text="#{screen.pm.button.cancel}">CANCEL</span>
155+
</a>
156+
</div>
157+
</form>
158+
159+
<p id="pwddesc" th:unless="${passwordManagementEnabled}"
160+
th:utext="${expiredPass} ? #{screen.expiredpass.message('/console/account/passwordRecovery')} : #{screen.mustchangepass.message('/console/account/passwordRecovery')}">Expired/Must Change Password text</p>
161+
162+
</div>
163+
</main>
164+
</body>
165+
</html>

0 commit comments

Comments
 (0)