GUACAMOLE-96: Pull TOTP key from user attribute.

This commit is contained in:
Michael Jumper
2017-11-20 01:05:42 -08:00
parent 19e03a1632
commit 8dd5537cf3

View File

@@ -22,6 +22,7 @@ package org.apache.guacamole.auth.totp;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.util.Collections; import java.util.Collections;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.guacamole.GuacamoleClientException; import org.apache.guacamole.GuacamoleClientException;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
@@ -46,6 +47,11 @@ public class UserVerificationService {
*/ */
private final Logger logger = LoggerFactory.getLogger(UserVerificationService.class); private final Logger logger = LoggerFactory.getLogger(UserVerificationService.class);
/**
* The name of the user attribute which stores the TOTP key.
*/
private static final String TOTP_KEY_ATTRIBUTE_NAME = "guac-totp-key";
/** /**
* The name of the HTTP parameter which will contain the TOTP code provided * The name of the HTTP parameter which will contain the TOTP code provided
* by the user to verify their identity. * by the user to verify their identity.
@@ -84,10 +90,8 @@ public class UserVerificationService {
* UserContext, or null if no TOTP key is associated with the user. * UserContext, or null if no TOTP key is associated with the user.
*/ */
public String getKey(UserContext context){ public String getKey(UserContext context){
Map<String, String> attributes = context.self().getAttributes();
// FIXME: Hard-coded key return attributes.get(TOTP_KEY_ATTRIBUTE_NAME);
return "JBSWY3DPEHPK3PXP";
} }
/** /**