-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27a7bad
commit 4dc83f9
Showing
8 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...on-security-ldap/deployment/src/test/java/io/quarkus/elytron/security/ldap/CacheTest.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,30 @@ | ||
package io.quarkus.elytron.security.ldap; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.elytron.security.ldap.rest.SingleRoleSecuredServlet; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.quarkus.test.ldap.LdapServerTestResource; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTestResource(LdapServerTestResource.class) | ||
public class CacheTest { | ||
protected static Class[] testClasses = { | ||
SingleRoleSecuredServlet.class | ||
}; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(testClasses) | ||
.addAsResource("cache/application.properties", "application.properties")); | ||
|
||
@Test() | ||
public void testNoCacheFailure() { | ||
RestAssured.given().auth().preemptive().basic("standardUser", "standardUserPassword") | ||
.when().get("/servlet-secured").then() | ||
.statusCode(200); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
extensions/elytron-security-ldap/deployment/src/test/resources/cache/application.properties
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,15 @@ | ||
quarkus.security.ldap.enabled=true | ||
|
||
quarkus.security.ldap.dir-context.principal=uid=admin,ou=system | ||
quarkus.security.ldap.dir-context.url=ldap://127.0.0.1:10389 | ||
quarkus.security.ldap.dir-context.password=secret | ||
|
||
quarkus.security.ldap.identity-mapping.search-base-dn=ou=Users,dc=quarkus,dc=io | ||
|
||
quarkus.security.ldap.identity-mapping.attribute-mappings."0".from=cn | ||
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter=(member=uid={0},ou=Users,dc=quarkus,dc=io) | ||
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter-base-dn=ou=Roles,dc=quarkus,dc=io | ||
|
||
quarkus.security.ldap.cache.enabled=true | ||
quarkus.security.ldap.cache.max-age=60s | ||
quarkus.security.ldap.cache.size=10 |
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
30 changes: 30 additions & 0 deletions
30
...urity-ldap/runtime/src/main/java/io/quarkus/elytron/security/ldap/config/CacheConfig.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,30 @@ | ||
package io.quarkus.elytron.security.ldap.config; | ||
|
||
import java.time.Duration; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.smallrye.config.WithDefault; | ||
|
||
@ConfigGroup | ||
public interface CacheConfig { | ||
|
||
/** | ||
* If set to true, request to the LDAP server are cached | ||
*/ | ||
@WithDefault("false") | ||
boolean enabled(); | ||
|
||
/** | ||
* The duration that an entry can stay in the cache | ||
*/ | ||
@WithDefault("60s") | ||
Duration maxAge(); | ||
|
||
/** | ||
* The maximum number of entries to keep in the cache | ||
*/ | ||
@WithDefault("100") | ||
int size(); | ||
|
||
String toString(); | ||
} |
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
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
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
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