diff --git a/build.gradle b/build.gradle index 14de75a..ea11e47 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,6 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-log4j2' - implementation 'org.springframework.security:spring-security-ldap' implementation 'org.liquibase:liquibase-core' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' @@ -48,7 +47,6 @@ dependencies { compileOnly group: 'jakarta.servlet', name: 'jakarta.servlet-api', version: '6.0.0' runtimeOnly 'com.mysql:mysql-connector-j' - runtimeOnly 'com.unboundid:unboundid-ldapsdk:6.0.9' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' diff --git a/src/main/java/com/ffii/tsms/config/security/SecurityConfig.java b/src/main/java/com/ffii/tsms/config/security/SecurityConfig.java index 6a92d38..2732b26 100644 --- a/src/main/java/com/ffii/tsms/config/security/SecurityConfig.java +++ b/src/main/java/com/ffii/tsms/config/security/SecurityConfig.java @@ -48,15 +48,6 @@ public class SecurityConfig { throws Exception { return authenticationConfiguration.getAuthenticationManager(); } - - @Bean - @Qualifier("LdapAuthenticationManager") - public AuthenticationManager ldapAuthenticationManager(BaseLdapPathContextSource contextSource) { - LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource); - factory.setUserSearchFilter("cn={0}"); - return factory.createAuthenticationManager(); - } - @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); diff --git a/src/main/java/com/ffii/tsms/config/security/jwt/web/JwtAuthenticationController.java b/src/main/java/com/ffii/tsms/config/security/jwt/web/JwtAuthenticationController.java index ef2a78a..f95b11b 100644 --- a/src/main/java/com/ffii/tsms/config/security/jwt/web/JwtAuthenticationController.java +++ b/src/main/java/com/ffii/tsms/config/security/jwt/web/JwtAuthenticationController.java @@ -45,10 +45,6 @@ public class JwtAuthenticationController { @Qualifier("AuthenticationManager") private AuthenticationManager authenticationManager; - @Autowired - @Qualifier("LdapAuthenticationManager") - private AuthenticationManager ldapAuthenticationManager; - @Autowired private JwtTokenUtil jwtTokenUtil; @@ -80,30 +76,11 @@ public class JwtAuthenticationController { return createAuthTokenResponse(authenticationRequest); } - @PostMapping("/ldap-login") - public ResponseEntity ldapLogin(@RequestBody JwtRequest authenticationRequest, HttpServletRequest request) throws Exception { - String username = authenticationRequest.getUsername(); - try { - boolean success = ldapAuthenticate(authenticationRequest.getUsername(), authenticationRequest.getPassword()); - loginLogService.createLoginLog(username, request.getRemoteAddr(), success); - } catch (Exception e) { - loginLogService.createLoginLog(username, request.getRemoteAddr(), false); - return ResponseEntity.status(HttpStatus.UNAUTHORIZED) - .body(new ExceptionResponse("Unauthorized", ExceptionUtils.getStackTrace(e))); - } - return createAuthTokenResponse(authenticationRequest); - } - private boolean authenticate(String username, String password) throws Exception { authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); return true; } - private boolean ldapAuthenticate(String username, String password) throws Exception { - ldapAuthenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); - return true; - } - private ResponseEntity createAuthTokenResponse(JwtRequest authenticationRequest) { final UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationRequest.getUsername()); if (userDetails == null) { diff --git a/src/main/resources/application-db-2fi.yml b/src/main/resources/application-db-2fi.yml deleted file mode 100644 index 661776e..0000000 --- a/src/main/resources/application-db-2fi.yml +++ /dev/null @@ -1,5 +0,0 @@ -spring: - datasource: - jdbc-url: jdbc:mysql://192.168.1.81:3306/arsdb?useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8 - username: root - password: secret \ No newline at end of file diff --git a/src/main/resources/application-ldap-local.yml b/src/main/resources/application-ldap-local.yml deleted file mode 100644 index 6974913..0000000 --- a/src/main/resources/application-ldap-local.yml +++ /dev/null @@ -1,9 +0,0 @@ -spring: - ldap: - embedded: - port: 8389 - base-dn: dc=springframework,dc=org - ldif: classpath:ldap-test-users.ldif - validation: - enabled: false - urls: ldap://localhost:8389 \ No newline at end of file