adding ldap test server

This commit is contained in:
alex 2024-08-14 22:45:28 -04:00
parent dff0175e83
commit 90221e9105
5 changed files with 71 additions and 4 deletions

View File

@ -92,6 +92,10 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>

View File

@ -39,7 +39,7 @@ public class SecurityConfig extends VaadinWebSecurity {
@Bean
public AuthenticationManager authenticationManager() {
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
"ldap://ldap.primefactorsolutions.com:389/dc=primefactorsolutions,dc=com");
"ldap://localhost:8389/dc=primefactorsolutions,dc=com");
contextSource.setCacheEnvironmentProperties(false);
LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource);
factory.setUserDnPatterns("uid={0},ou=users");

View File

@ -17,16 +17,25 @@ spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.ldap.embedded.ldif=classpath:test-server.ldif
spring.ldap.embedded.base-dn=dc=primefactorsolutions,dc=com
spring.ldap.embedded.port=8389
# spring.datasource.url=jdbc:h2:mem:testdb
# spring.datasource.url=jdbc:h2:file:./db
# spring.datasource.url=jdbc:h2:file:/var/opt/pfs/db
spring.datasource.url=${DB_URL:jdbc:h2:mem:testdb}
spring.jpa.hibernate.ddl-auto=update
spring.sql.init.mode=${SQL_INIT:embedded}
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=${H2_PASS:sa}
spring.h2.console.settings.web-allow-others=true
spring.jpa.show-sql=true
# spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.defer-datasource-initialization = true
spring.sql.init.mode=${SQL_INIT:embedded}
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true

View File

@ -0,0 +1,11 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,43 @@
dn: dc=primefactorsolutions,dc=com
objectclass: top
objectclass: domain
objectclass: extensibleObject
dc: primefactorsolutions
dn: ou=groups,dc=primefactorsolutions,dc=com
objectclass: top
objectclass: organizationalUnit
ou: groups
dn: ou=users,dc=primefactorsolutions,dc=com
objectclass: top
objectclass: organizationalUnit
ou: users
dn: uid=ben,ou=users,dc=primefactorsolutions,dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Ben User
sn: BenUser
uid: ben
userPassword: $2a$10$c6bSeWPhg06xB1lvmaWNNe4NROmZiSpYhlocU/98HNr2MhIOiSt36
dn: uid=bob,ou=users,dc=primefactorsolutions,dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Bob User
sn: BobUser
uid: bob
userPassword: bobspassword
dn: cn=employees,ou=groups,dc=primefactorsolutions,dc=com
objectclass: top
objectclass: groupOfUniqueNames
cn: employees
ou: groups
uniqueMember: uid=ben,ou=users,dc=primefactorsolutions,dc=com
uniqueMember: uid=bob,ou=users,dc=primefactorsolutions,dc=com