mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUAC-1176: Add password expiration attribute.
This commit is contained in:
@@ -58,12 +58,19 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
*/
|
*/
|
||||||
public static final String DISABLED_ATTRIBUTE_NAME = "disabled";
|
public static final String DISABLED_ATTRIBUTE_NAME = "disabled";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the attribute which controls whether a user's password is
|
||||||
|
* expired and must be reset upon login.
|
||||||
|
*/
|
||||||
|
public static final String EXPIRED_ATTRIBUTE_NAME = "expired";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All attributes related to restricting user accounts, within a logical
|
* All attributes related to restricting user accounts, within a logical
|
||||||
* form.
|
* form.
|
||||||
*/
|
*/
|
||||||
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.asList(
|
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.asList(
|
||||||
new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true")
|
new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true"),
|
||||||
|
new Field(EXPIRED_ATTRIBUTE_NAME, "Password expired", "true")
|
||||||
));
|
));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +221,10 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
Map<String, String> attributes = new HashMap<String, String>();
|
Map<String, String> attributes = new HashMap<String, String>();
|
||||||
|
|
||||||
// Set disabled attribute
|
// Set disabled attribute
|
||||||
attributes.put("disabled", getModel().isDisabled() ? "true" : null);
|
attributes.put(DISABLED_ATTRIBUTE_NAME, getModel().isDisabled() ? "true" : null);
|
||||||
|
|
||||||
|
// Set password expired attribute
|
||||||
|
attributes.put(EXPIRED_ATTRIBUTE_NAME, getModel().isExpired() ? "true" : null);
|
||||||
|
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
@@ -223,7 +233,10 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
public void setAttributes(Map<String, String> attributes) {
|
public void setAttributes(Map<String, String> attributes) {
|
||||||
|
|
||||||
// Translate disabled attribute
|
// Translate disabled attribute
|
||||||
getModel().setDisabled("true".equals(attributes.get("disabled")));
|
getModel().setDisabled("true".equals(attributes.get(DISABLED_ATTRIBUTE_NAME)));
|
||||||
|
|
||||||
|
// Translate password expired attribute
|
||||||
|
getModel().setExpired("true".equals(attributes.get(EXPIRED_ATTRIBUTE_NAME)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,6 +48,13 @@ public class UserModel extends ObjectModel {
|
|||||||
*/
|
*/
|
||||||
private boolean disabled;
|
private boolean disabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the user's password is expired. If a user's password is expired,
|
||||||
|
* it must be changed immediately upon login, and the account cannot be
|
||||||
|
* used until this occurs.
|
||||||
|
*/
|
||||||
|
private boolean expired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new, empty user.
|
* Creates a new, empty user.
|
||||||
*/
|
*/
|
||||||
@@ -127,4 +134,28 @@ public class UserModel extends ObjectModel {
|
|||||||
this.disabled = disabled;
|
this.disabled = disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the user's password has expired. If a user's password is
|
||||||
|
* expired, it must be immediately changed upon login. A user account with
|
||||||
|
* an expired password cannot be used until the password has been changed.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* true if the user's password has expired, false otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isExpired() {
|
||||||
|
return expired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the user's password is expired. If a user's password is
|
||||||
|
* expired, it must be immediately changed upon login. A user account with
|
||||||
|
* an expired password cannot be used until the password has been changed.
|
||||||
|
*
|
||||||
|
* @param expired
|
||||||
|
* true to expire the user's password, false otherwise.
|
||||||
|
*/
|
||||||
|
public void setExpired(boolean expired) {
|
||||||
|
this.expired = expired;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
"USER_ATTRIBUTES" : {
|
"USER_ATTRIBUTES" : {
|
||||||
|
|
||||||
"FIELD_HEADER_DISABLED" : "Login disabled:",
|
"FIELD_HEADER_DISABLED" : "Login disabled:",
|
||||||
|
"FIELD_HEADER_EXPIRED" : "Password expired:",
|
||||||
|
|
||||||
"SECTION_HEADER_RESTRICTIONS" : "Account Restrictions"
|
"SECTION_HEADER_RESTRICTIONS" : "Account Restrictions"
|
||||||
|
|
||||||
|
@@ -77,6 +77,7 @@ CREATE TABLE `guacamole_user` (
|
|||||||
`password_hash` binary(32) NOT NULL,
|
`password_hash` binary(32) NOT NULL,
|
||||||
`password_salt` binary(32),
|
`password_salt` binary(32),
|
||||||
`disabled` boolean NOT NULL DEFAULT 0,
|
`disabled` boolean NOT NULL DEFAULT 0,
|
||||||
|
`expired` boolean NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
PRIMARY KEY (`user_id`),
|
PRIMARY KEY (`user_id`),
|
||||||
UNIQUE KEY `username` (`username`)
|
UNIQUE KEY `username` (`username`)
|
||||||
|
@@ -26,3 +26,9 @@
|
|||||||
|
|
||||||
ALTER TABLE guacamole_user ADD COLUMN disabled BOOLEAN NOT NULL DEFAULT 0;
|
ALTER TABLE guacamole_user ADD COLUMN disabled BOOLEAN NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add per-user password expiration flag
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE guacamole_user ADD COLUMN expired BOOLEAN NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
|
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
|
||||||
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
|
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
|
||||||
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
|
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
|
||||||
|
<result column="expired" property="expired" jdbcType="BOOLEAN"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- Select all usernames -->
|
<!-- Select all usernames -->
|
||||||
@@ -59,7 +60,8 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
WHERE username IN
|
WHERE username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
@@ -77,7 +79,8 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
||||||
WHERE username IN
|
WHERE username IN
|
||||||
@@ -98,7 +101,8 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
WHERE
|
WHERE
|
||||||
username = #{username,jdbcType=VARCHAR}
|
username = #{username,jdbcType=VARCHAR}
|
||||||
@@ -119,13 +123,15 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
#{object.identifier,jdbcType=VARCHAR},
|
#{object.identifier,jdbcType=VARCHAR},
|
||||||
#{object.passwordHash,jdbcType=BINARY},
|
#{object.passwordHash,jdbcType=BINARY},
|
||||||
#{object.passwordSalt,jdbcType=BINARY},
|
#{object.passwordSalt,jdbcType=BINARY},
|
||||||
#{object.disabled,jdbcType=BOOLEAN}
|
#{object.disabled,jdbcType=BOOLEAN},
|
||||||
|
#{object.expired,jdbcType=BOOLEAN}
|
||||||
)
|
)
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
@@ -135,7 +141,8 @@
|
|||||||
UPDATE guacamole_user
|
UPDATE guacamole_user
|
||||||
SET password_hash = #{object.passwordHash,jdbcType=BINARY},
|
SET password_hash = #{object.passwordHash,jdbcType=BINARY},
|
||||||
password_salt = #{object.passwordSalt,jdbcType=BINARY},
|
password_salt = #{object.passwordSalt,jdbcType=BINARY},
|
||||||
disabled = #{object.disabled,jdbcType=BOOLEAN}
|
disabled = #{object.disabled,jdbcType=BOOLEAN},
|
||||||
|
expired = #{object.expired,jdbcType=BOOLEAN}
|
||||||
WHERE user_id = #{object.objectID,jdbcType=VARCHAR}
|
WHERE user_id = #{object.objectID,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
@@ -118,6 +118,7 @@ CREATE TABLE guacamole_user (
|
|||||||
password_hash bytea NOT NULL,
|
password_hash bytea NOT NULL,
|
||||||
password_salt bytea,
|
password_salt bytea,
|
||||||
disabled boolean NOT NULL DEFAULT FALSE,
|
disabled boolean NOT NULL DEFAULT FALSE,
|
||||||
|
expired boolean NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
PRIMARY KEY (user_id),
|
PRIMARY KEY (user_id),
|
||||||
|
|
||||||
|
@@ -26,3 +26,9 @@
|
|||||||
|
|
||||||
ALTER TABLE guacamole_user ADD COLUMN disabled boolean NOT NULL DEFAULT FALSE;
|
ALTER TABLE guacamole_user ADD COLUMN disabled boolean NOT NULL DEFAULT FALSE;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Add per-user password expiration flag
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE guacamole_user ADD COLUMN expired boolean NOT NULL DEFAULT FALSE;
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
|
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
|
||||||
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
|
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
|
||||||
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
|
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
|
||||||
|
<result column="expired" property="expired" jdbcType="BOOLEAN"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- Select all usernames -->
|
<!-- Select all usernames -->
|
||||||
@@ -59,7 +60,8 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
WHERE username IN
|
WHERE username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
@@ -77,7 +79,8 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
||||||
WHERE username IN
|
WHERE username IN
|
||||||
@@ -98,7 +101,8 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
WHERE
|
WHERE
|
||||||
username = #{username,jdbcType=VARCHAR}
|
username = #{username,jdbcType=VARCHAR}
|
||||||
@@ -119,13 +123,15 @@
|
|||||||
username,
|
username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
disabled
|
disabled,
|
||||||
|
expired
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
#{object.identifier,jdbcType=VARCHAR},
|
#{object.identifier,jdbcType=VARCHAR},
|
||||||
#{object.passwordHash,jdbcType=BINARY},
|
#{object.passwordHash,jdbcType=BINARY},
|
||||||
#{object.passwordSalt,jdbcType=BINARY},
|
#{object.passwordSalt,jdbcType=BINARY},
|
||||||
#{object.disabled,jdbcType=BOOLEAN}
|
#{object.disabled,jdbcType=BOOLEAN},
|
||||||
|
#{object.expired,jdbcType=BOOLEAN}
|
||||||
)
|
)
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
@@ -135,7 +141,8 @@
|
|||||||
UPDATE guacamole_user
|
UPDATE guacamole_user
|
||||||
SET password_hash = #{object.passwordHash,jdbcType=BINARY},
|
SET password_hash = #{object.passwordHash,jdbcType=BINARY},
|
||||||
password_salt = #{object.passwordSalt,jdbcType=BINARY},
|
password_salt = #{object.passwordSalt,jdbcType=BINARY},
|
||||||
disabled = #{object.disabled,jdbcType=BOOLEAN}
|
disabled = #{object.disabled,jdbcType=BOOLEAN},
|
||||||
|
expired = #{object.expired,jdbcType=BOOLEAN}
|
||||||
WHERE user_id = #{object.objectID,jdbcType=VARCHAR}
|
WHERE user_id = #{object.objectID,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user