-
Notifications
You must be signed in to change notification settings - Fork 679
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GUACAMOLE-990: Merge new guacamole-auth-ban extension to block brute-…
…force auth attempts.
- Loading branch information
Showing
30 changed files
with
1,492 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Caffeine (https://github.com/ben-manes/caffeine) | ||
------------------------------------------------ | ||
|
||
Version: 2.9.3 | ||
From: 'Ben Manes' (https://github.com/ben-manes) | ||
License(s): | ||
Apache v2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.github.ben-manes.caffeine:caffeine:jar:2.9.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Checker Framework qualifiers | ||
Copyright 2004-present by the Checker Framework developers | ||
|
||
MIT License: | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Checker Framework qualifiers (https://checkerframework.org/) | ||
------------------------------------------------------------ | ||
|
||
Version: 3.19.0 | ||
From: 'Checker Framework developers' (https://checkerframework.org/) | ||
License(s): | ||
MIT (bundled/checker-qual-3.19.0/LICENSE.txt) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.checkerframework:checker-qual:jar:3.19.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Error Prone (https://errorprone.info/) | ||
-------------------------------------- | ||
|
||
Version: 2.10.0 | ||
From: 'Google Inc.' (http://www.google.com/) | ||
License(s): | ||
Apache v2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.google.errorprone:error_prone_annotations:jar:2.10.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.apache.guacamole</groupId> | ||
<artifactId>guacamole-auth-ban</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.4.0</version> | ||
<name>guacamole-auth-ban</name> | ||
<url>http://guacamole.apache.org/</url> | ||
|
||
<parent> | ||
<groupId>org.apache.guacamole</groupId> | ||
<artifactId>extensions</artifactId> | ||
<version>1.4.0</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
|
||
<dependencies> | ||
|
||
<!-- Java servlet API --> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>2.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Guacamole Extension API --> | ||
<dependency> | ||
<groupId>org.apache.guacamole</groupId> | ||
<artifactId>guacamole-ext</artifactId> | ||
<version>1.4.0</version> | ||
<scope>provided</scope> | ||
|
||
<!-- Exclude transitive dependencies that will be overridden by | ||
newer versions required by Caffeine --> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.checkerframework</groupId> | ||
<artifactId>checker-qual</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.google.errorprone</groupId> | ||
<artifactId>error_prone_annotations</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
|
||
</dependency> | ||
|
||
<!-- Guava Base Libraries --> | ||
<dependency> | ||
<groupId>com.github.ben-manes.caffeine</groupId> | ||
<artifactId>caffeine</artifactId> | ||
<version>2.9.3</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<assembly | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 | ||
http://maven.apache.org/xsd/assembly-1.1.0.xsd"> | ||
|
||
<id>dist</id> | ||
<baseDirectory>${project.artifactId}-${project.version}</baseDirectory> | ||
|
||
<!-- Output tar.gz --> | ||
<formats> | ||
<format>tar.gz</format> | ||
</formats> | ||
|
||
<!-- Include licenses and extension .jar --> | ||
<fileSets> | ||
|
||
<!-- Include licenses --> | ||
<fileSet> | ||
<outputDirectory></outputDirectory> | ||
<directory>target/licenses</directory> | ||
</fileSet> | ||
|
||
<!-- Include extension .jar --> | ||
<fileSet> | ||
<directory>target</directory> | ||
<outputDirectory></outputDirectory> | ||
<includes> | ||
<include>*.jar</include> | ||
</includes> | ||
</fileSet> | ||
|
||
</fileSets> | ||
|
||
</assembly> |
82 changes: 82 additions & 0 deletions
82
...e-auth-ban/src/main/java/org/apache/guacamole/auth/ban/BanningAuthenticationListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.guacamole.auth.ban; | ||
|
||
import org.apache.guacamole.auth.ban.status.AuthenticationFailureTracker; | ||
import org.apache.guacamole.GuacamoleException; | ||
import org.apache.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException; | ||
import org.apache.guacamole.net.event.AuthenticationFailureEvent; | ||
import org.apache.guacamole.net.event.AuthenticationSuccessEvent; | ||
import org.apache.guacamole.net.event.listener.Listener; | ||
|
||
/** | ||
* Listener implementation which automatically tracks authentication failures | ||
* such that further authentication attempts may be automatically blocked by | ||
* {@link BanningAuthenticationProvider} if they match configured criteria. | ||
*/ | ||
public class BanningAuthenticationListener implements Listener { | ||
|
||
/** | ||
* Shared tracker of addresses that have repeatedly failed authentication. | ||
*/ | ||
private static AuthenticationFailureTracker tracker; | ||
|
||
/** | ||
* Assigns the shared tracker instance used by both the {@link BanningAuthenticationProvider} | ||
* and this listener. This function MUST be invoked with the tracker | ||
* created for BanningAuthenticationProvider as soon as possible (during | ||
* construction of BanningAuthenticationProvider), or processing of | ||
* received events will fail internally. | ||
* | ||
* @param tracker | ||
* The tracker instance to use for received authentication events. | ||
*/ | ||
public static void setAuthenticationFailureTracker(AuthenticationFailureTracker tracker) { | ||
BanningAuthenticationListener.tracker = tracker; | ||
} | ||
|
||
@Override | ||
public void handleEvent(Object event) throws GuacamoleException { | ||
|
||
if (event instanceof AuthenticationFailureEvent) { | ||
|
||
AuthenticationFailureEvent failure = (AuthenticationFailureEvent) event; | ||
|
||
// Requests for additional credentials are not failures per se, | ||
// but continuations of a multi-request authentication attempt that | ||
// has not yet succeeded OR failed | ||
if (failure.getFailure() instanceof GuacamoleInsufficientCredentialsException) { | ||
tracker.notifyAuthenticationRequestReceived(failure.getCredentials()); | ||
return; | ||
} | ||
|
||
// Consider all other errors to be failed auth attempts | ||
tracker.notifyAuthenticationFailed(failure.getCredentials()); | ||
|
||
} | ||
|
||
else if (event instanceof AuthenticationSuccessEvent) { | ||
AuthenticationSuccessEvent success = (AuthenticationSuccessEvent) event; | ||
tracker.notifyAuthenticationSuccess(success.getCredentials()); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.