Skip to content

Commit bb1ab56

Browse files
CloudFlo2312cesmarvin
authored andcommitted
Merge branch 'release/v1.6.0-1'
2 parents 6bfa9af + e091b4d commit bb1ab56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6355
-291
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [v1.6.0-1] - 2022-04-27
10+
Note: CAS version >= 6.5.3-2 is required for this version.
11+
12+
### Added
13+
- Possibility to set the attribute that the user has to change his password at the next login (#51)
14+
915
## [v1.5.0-3] - 2022-04-26
1016
### Removed
1117
- remove unused source of `/etc/ces/functions.sh` in `startup.sh` (#52)

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN set -x \
88
FROM registry.cloudogu.com/official/java:8u302-1
99

1010
LABEL NAME="official/usermgt" \
11-
VERSION="1.5.0-3" \
11+
VERSION="1.6.0-1" \
1212
maintainer="[email protected]"
1313

1414
# mark as webapp for nginx

Jenkinsfile

+12-12
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ node('docker') {
132132
}
133133

134134
stage('Integration Tests') {
135-
echo "No integration test exists."
136-
// ecoSystem.runCypressIntegrationTests([
137-
// cypressImage: "cypress/included:8.6.0",
138-
// enableVideo: params.EnableVideoRecording,
139-
// enableScreenshots : params.EnableScreenshotRecording,
140-
// ])
135+
echo "run integration tests."
136+
ecoSystem.runCypressIntegrationTests([
137+
cypressImage: "cypress/included:8.6.0",
138+
enableVideo: params.EnableVideoRecording,
139+
enableScreenshots : params.EnableScreenshotRecording,
140+
])
141141
}
142142

143143
if (params.TestDoguUpgrade != null && params.TestDoguUpgrade){
@@ -161,12 +161,12 @@ node('docker') {
161161
}
162162

163163
stage('Integration Tests - After Upgrade') {
164-
echo "No integration test exists."
165-
// ecoSystem.runCypressIntegrationTests([
166-
// cypressImage: "cypress/included:8.6.0",
167-
// enableVideo: params.EnableVideoRecording,
168-
// enableScreenshots : params.EnableScreenshotRecording,
169-
// ])
164+
echo "run integration tests."
165+
ecoSystem.runCypressIntegrationTests([
166+
cypressImage: "cypress/included:8.6.0",
167+
enableVideo: params.EnableVideoRecording,
168+
enableScreenshots : params.EnableScreenshotRecording,
169+
])
170170
}
171171
}
172172

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set these to the desired values
22
ARTIFACT_ID=usermgt
3-
VERSION=1.5.0-3
3+
VERSION=1.6.0-1
44
# overwrite ADDITIONAL_LDFLAGS to disable static compilation
55
# this should fix https://github.com/golang/go/issues/13470
66
ADDITIONAL_LDFLAGS=""

app/env/data/mapping/user.xml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ and open the template in the editor.
2929
in-search="false">
3030
password
3131
</attribute>
32+
<attribute decoder="de.triology.universeadm.mapping.LDAPBooleanConverter"
33+
encoder="de.triology.universeadm.mapping.LDAPBooleanConverter">pwdReset</attribute>
3234
<attribute ldap-name="memberOf" is-multi-value="true" in-modify="false"
3335
in-create="false"
3436
decoder="de.triology.universeadm.mapping.MemberOfMappingConverter"

app/src/main/java/de/triology/universeadm/CasSecurityModule.java

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ protected void configureRealm() {
114114
addFilterChain("/api/users/*", API, config(ROLES, Roles.ADMINISTRATOR));
115115
addFilterChain("/api/groups", API, config(ROLES, Roles.ADMINISTRATOR));
116116
addFilterChain("/api/groups/*", API, config(ROLES, Roles.ADMINISTRATOR));
117+
addFilterChain("/api/account", API);
118+
addFilterChain("/api/account/*", API);
117119
addFilterChain("/**", AUTHC);
118120
}
119121

app/src/main/java/de/triology/universeadm/account/AccountResource.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,25 @@ public Response getConfig()
8686
final Configuration conf = Configuration.getInstance();
8787
builder = Response.ok(conf.getContent(), MediaType.APPLICATION_JSON);
8888
} else {
89-
logger.error("call /api/conf/passwordpolicy without prior authentication");
89+
logger.error("call /api/account/passwordpolicy without prior authentication");
90+
builder = Response.status(Response.Status.FORBIDDEN);
91+
}
92+
93+
return builder.build();
94+
}
95+
96+
@GET
97+
@Path("gui_config")
98+
@Produces(MediaType.APPLICATION_JSON)
99+
public Response getGuiConfig()
100+
{
101+
Response.ResponseBuilder builder;
102+
User account = accountManager.getCurrentUser();
103+
if ( account != null ){
104+
final Configuration conf = Configuration.getInstance();
105+
builder = Response.ok(conf.getGuiContent(), MediaType.APPLICATION_JSON);
106+
} else {
107+
logger.error("call /api/account/gui_config without prior authentication");
90108
builder = Response.status(Response.Status.FORBIDDEN);
91109
}
92110

app/src/main/java/de/triology/universeadm/account/Configuration.java

+7
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ public class Configuration {
1212
private static final Logger logger = LoggerFactory.getLogger(Configuration.class);
1313
private static final String defaultPath = "/var/lib/usermgt/conf";
1414
private static final String configFilePath = defaultPath + "/optional.conf";
15+
private static final String guiConfigFilePath = defaultPath + "/gui.conf";
1516
private static Configuration instance;
1617
private final String content;
18+
private final String guiContent;
1719

1820
private Configuration() {
1921
this.content = this.readConfigurationFromFile(configFilePath);
22+
this.guiContent = this.readConfigurationFromFile(guiConfigFilePath);
2023
}
2124

2225
public static Configuration getInstance() {
@@ -30,6 +33,10 @@ public String getContent() {
3033
return this.content;
3134
}
3235

36+
public String getGuiContent() {
37+
return this.guiContent;
38+
}
39+
3340
private String readConfigurationFromFile(final String path) {
3441
String configuration = "";
3542
try {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package de.triology.universeadm.mapping;
2+
3+
/**
4+
* Converter for the conversion of a Java Boolean to an LDAP Boolean and vice versa.
5+
*
6+
* In LDAP, the boolean values are capitalised ("FALSE", "TRUE).
7+
*/
8+
public class LDAPBooleanConverter extends AbstractMappingConverter {
9+
10+
private static final String LDAP_FALSE = "FALSE";
11+
private static final String LDAP_TRUE = "TRUE";
12+
13+
@Override
14+
public String encodeAsString(Object object) {
15+
if (object instanceof Boolean) {
16+
Boolean bool = (Boolean) object;
17+
18+
if (Boolean.TRUE.equals(bool)) {
19+
return LDAP_TRUE;
20+
} else {
21+
return LDAP_FALSE;
22+
}
23+
}
24+
25+
return LDAP_FALSE;
26+
}
27+
28+
@Override
29+
public <T> Object decodeFromString(FieldDescriptor<T> type, String string) {
30+
return LDAP_TRUE.equals(string);
31+
}
32+
}

app/src/main/java/de/triology/universeadm/user/User.java

+32-4
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,15 @@ public User(String username)
8484
* @param memberOf
8585
*/
8686
public User(String username, String displayName, String givenname,
87-
String surname, String mail, String password, List<String> memberOf)
87+
String surname, String mail, String password, boolean pwdReset, List<String> memberOf)
8888
{
8989
this.username = username;
9090
this.displayName = displayName;
9191
this.givenname = givenname;
9292
this.surname = surname;
9393
this.mail = mail;
9494
this.password = password;
95+
this.pwdReset = pwdReset;
9596
this.memberOf = memberOf;
9697
}
9798

@@ -140,7 +141,8 @@ public boolean equals(Object obj)
140141
&& Objects.equal(givenname, other.givenname)
141142
&& Objects.equal(surname, other.surname)
142143
&& Objects.equal(mail, other.mail)
143-
&& Objects.equal(memberOf, other.memberOf);
144+
&& Objects.equal(memberOf, other.memberOf)
145+
&& Objects.equal(pwdReset, other.pwdReset);
144146
}
145147

146148
/**
@@ -153,7 +155,7 @@ public boolean equals(Object obj)
153155
public int hashCode()
154156
{
155157
return Objects.hashCode(username, displayName, givenname, surname, mail,
156-
memberOf);
158+
memberOf, pwdReset);
157159
}
158160

159161
/**
@@ -168,7 +170,7 @@ public String toString()
168170
return MoreObjects.toStringHelper(this).add("username",
169171
username).add("displayName", displayName).add("givenname",
170172
givenname).add("surname", surname).add("mail", mail).add("memberOf",
171-
memberOf).toString();
173+
memberOf).add("pwdReset", pwdReset).toString();
172174
}
173175

174176
//~--- get methods ----------------------------------------------------------
@@ -233,6 +235,16 @@ public String getPassword()
233235
return password;
234236
}
235237

238+
/**
239+
* Method description
240+
*
241+
*
242+
* @return
243+
*/
244+
public boolean isPwdReset() {
245+
return pwdReset;
246+
}
247+
236248
/**
237249
* Method description
238250
*
@@ -312,6 +324,16 @@ public void setPassword(String password)
312324
this.password = password;
313325
}
314326

327+
/**
328+
* Method description
329+
*
330+
*
331+
* @param pwdReset
332+
*/
333+
public void setPwdReset(boolean pwdReset) {
334+
this.pwdReset = pwdReset;
335+
}
336+
315337
/**
316338
* Method description
317339
*
@@ -363,6 +385,12 @@ public void setUsername(String username)
363385
*/
364386
private String password;
365387

388+
389+
/**
390+
* Field description
391+
*/
392+
private boolean pwdReset;
393+
366394
/**
367395
* Field description
368396
*/

app/src/main/webapp/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<script type="text/javascript" src="scripts/users/controllers.js"></script>
112112
<script type="text/javascript" src="scripts/passwordpolicy/services.js"></script>
113113
<script type="text/javascript" src="scripts/constrainthandling/services.js"></script>
114+
<script type="text/javascript" src="scripts/passwordresethandling/services.js"></script>
114115
<script type="text/javascript" src="scripts/groups/config.js"></script>
115116
<script type="text/javascript" src="scripts/groups/services.js"></script>
116117
<script type="text/javascript" src="scripts/groups/controllers.js"></script>

app/src/main/webapp/scripts/account/controllers.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828

2929
angular.module('universeadm.account.controllers', ['universeadm.validation.directives',
3030
'universeadm.account.services', 'universeadm.groups.services', 'universeadm.passwordpolicy.services', 'universeadm.constrainthandling.services'])
31-
.controller('accountController', function($scope, accountService, groupService, account, passwordPolicyService, constraintHandlingService) {
31+
.controller('accountController', function($scope, $rootScope, accountService, groupService, account, passwordPolicyService, constraintHandlingService) {
3232

3333
function setAccount(account) {
3434
$scope.user = account;
3535
$scope.master = angular.copy(account);
3636
$scope.confirmPassword = account.password;
37+
$scope.userIsCurrentUser = $rootScope.username === account.username;
3738
}
3839

3940
setAccount(account);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
angular.module('universeadm.passwordresethandling.services', ['restangular'])
4+
.factory('passwordResetHandlingService', function(Restangular){
5+
return {
6+
getPasswordResetDefaultValue: function (){
7+
return new Promise(function (resolve) {
8+
Restangular.one('account/gui_config').withHttpConfig({ cache: true}).get().then(function (result) {
9+
// If result is undefined because of a failure in backend, make sure not to throw an error here
10+
if (!!result){
11+
resolve(result.pwdResetPreselected);
12+
} else {
13+
resolve(false);
14+
}
15+
});
16+
});
17+
}
18+
};
19+
});

app/src/main/webapp/scripts/universeadm.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ angular.module('universeadm', ['angular-loading-bar', 'ngAnimate', 'restangular'
9696
$state.go('error404');
9797
});
9898
})
99-
.controller('navigationController', function ($scope, $location, $log, navigation) {
99+
.controller('navigationController', function ($scope, $rootScope, $location, $log, navigation) {
100100
function setNavigation(subject) {
101101
$scope.navItems = _.filter(navigation.items, function (item) {
102102
$scope.username = subject.principal;
103+
$rootScope.username = subject.principal;
103104
return !item.requireAdminPrivileges || subject.admin;
104105
});
105106
}

0 commit comments

Comments
 (0)