|
20 | 20 | package org.apache.guacamole.auth.duo.conf;
|
21 | 21 |
|
22 | 22 | import com.google.inject.Inject;
|
| 23 | +import inet.ipaddr.IPAddress; |
| 24 | +import java.util.List; |
23 | 25 | import org.apache.guacamole.GuacamoleException;
|
24 | 26 | import org.apache.guacamole.environment.Environment;
|
| 27 | +import org.apache.guacamole.properties.IPListProperty; |
25 | 28 | import org.apache.guacamole.properties.StringGuacamoleProperty;
|
26 | 29 |
|
27 | 30 | /**
|
@@ -90,6 +93,40 @@ public class ConfigurationService {
|
90 | 93 | public String getName() { return "duo-application-key"; }
|
91 | 94 |
|
92 | 95 | };
|
| 96 | + |
| 97 | + /** |
| 98 | + * The optional property that contains a comma-separated list of IP addresses |
| 99 | + * or CIDRs for which the MFA requirement should be bypassed. If the Duo |
| 100 | + * extension is installed, any/all users authenticating from clients that |
| 101 | + * match this list will be able to successfully log in without fulfilling |
| 102 | + * the MFA requirement. If this option is omitted or is empty, and the |
| 103 | + * Duo module is installed, all users from all hosts will have Duo MFA |
| 104 | + * enforced. |
| 105 | + */ |
| 106 | + private static final IPListProperty DUO_BYPASS_HOSTS = |
| 107 | + new IPListProperty() { |
| 108 | + |
| 109 | + @Override |
| 110 | + public String getName() { return "duo-bypass-hosts"; } |
| 111 | + |
| 112 | + }; |
| 113 | + |
| 114 | + /** |
| 115 | + * The optional property that contains a comma-separated list of IP addresses |
| 116 | + * or CIDRs for which the MFA requirement should be explicitly enforced. If |
| 117 | + * the Duo module is enabled and this property is specified, users that log |
| 118 | + * in from hosts that match the items in this list will have Duo MFA required, |
| 119 | + * and all users from hosts that do not match this list will be able to log |
| 120 | + * in without the MFA requirement. If this option is missing or empty and |
| 121 | + * the Duo module is installed, MFA will be enforced for all users. |
| 122 | + */ |
| 123 | + private static final IPListProperty DUO_ENFORCE_HOSTS = |
| 124 | + new IPListProperty() { |
| 125 | + |
| 126 | + @Override |
| 127 | + public String getName() { return "duo-enforce-hosts"; } |
| 128 | + |
| 129 | + }; |
93 | 130 |
|
94 | 131 | /**
|
95 | 132 | * Returns the hostname of the Duo API endpoint to be used to verify user
|
@@ -156,5 +193,43 @@ public String getSecretKey() throws GuacamoleException {
|
156 | 193 | public String getApplicationKey() throws GuacamoleException {
|
157 | 194 | return environment.getRequiredProperty(DUO_APPLICATION_KEY);
|
158 | 195 | }
|
| 196 | + |
| 197 | + /** |
| 198 | + * Returns the list of IP addresses and subnets defined in guacamole.properties |
| 199 | + * for which Duo MFA should _not_ be enforced. Users logging in from hosts |
| 200 | + * contained in this list will be logged in without the MFA requirement. |
| 201 | + * |
| 202 | + * @return |
| 203 | + * A list of IP addresses and subnets for which Duo MFA should not be |
| 204 | + * enforced. |
| 205 | + * |
| 206 | + * @throws GuacamoleException |
| 207 | + * If guacamole.properties cannot be parsed, or if an invalid IP address |
| 208 | + * or subnet is specified. |
| 209 | + */ |
| 210 | + public List<IPAddress> getBypassHosts() throws GuacamoleException { |
| 211 | + return environment.getProperty(DUO_BYPASS_HOSTS); |
| 212 | + } |
| 213 | + |
| 214 | + /** |
| 215 | + * Returns the list of IP addresses and subnets defined in guacamole.properties |
| 216 | + * for which Duo MFA should explicitly be enforced, while logins from all |
| 217 | + * other hosts should not enforce MFA. Users logging in from hosts |
| 218 | + * contained in this list will be required to complete the Duo MFA authentication, |
| 219 | + * while users from all other hosts will be logged in without the MFA requirement. |
| 220 | + * |
| 221 | + * @return |
| 222 | + * A list of IP addresses and subnets for which Duo MFA should be |
| 223 | + * explicitly enforced. |
| 224 | + * |
| 225 | + * @throws GuacamoleException |
| 226 | + * If guacamole.properties cannot be parsed, or if an invalid IP address |
| 227 | + * or subnet is specified. |
| 228 | + */ |
| 229 | + public List<IPAddress> getEnforceHosts() throws GuacamoleException { |
| 230 | + return environment.getProperty(DUO_ENFORCE_HOSTS); |
| 231 | + } |
| 232 | + |
| 233 | + |
159 | 234 |
|
160 | 235 | }
|
0 commit comments