necouchman commented on a change in pull request #495: GUACAMOLE-770: Support 
for clearing TOTP data
URL: https://github.com/apache/guacamole-client/pull/495#discussion_r403413872
 
 

 ##########
 File path: 
extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/user/TOTPUser.java
 ##########
 @@ -82,13 +106,15 @@ public User getUndecorated() {
     public void setAttributes(Map<String, String> attributes) {
 
         // Create independent, mutable copy of attributes
-        attributes = new HashMap<String, String>(attributes);
-
-        // Do not expose any TOTP-related attributes outside this extension
-        attributes.remove(TOTP_KEY_SECRET_ATTRIBUTE_NAME);
-        attributes.remove(TOTP_KEY_CONFIRMED_ATTRIBUTE_NAME);
+        attributes = new HashMap<>(attributes);
+        
+        // Pull off the boolean reset field
+        String reset = attributes.remove(TOTP_KEY_SECRET_RESET_FIELD);
+        
+        // If reset has been set to true, clear the secret.
+        if (reset != null && reset.equals("true"))
+            attributes.put(TOTP_KEY_SECRET_ATTRIBUTE_NAME, null);
 
 Review comment:
   Yeah, probably a good idea, although it doesn't matter all that much, 
because clearing out the secret results in a new QR code and the value being 
reset, anyway.  But probably good for the sake of cleanliness and consistency 
as much as anything.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to