Ver a proveniência

remove ldap related

tags/Baseline_30082024_BACKEND_UAT
Terence há 1 ano
ascendente
cometimento
3a2e4dd2a4
5 ficheiros alterados com 0 adições e 48 eliminações
  1. +0
    -2
      build.gradle
  2. +0
    -9
      src/main/java/com/ffii/tsms/config/security/SecurityConfig.java
  3. +0
    -23
      src/main/java/com/ffii/tsms/config/security/jwt/web/JwtAuthenticationController.java
  4. +0
    -5
      src/main/resources/application-db-2fi.yml
  5. +0
    -9
      src/main/resources/application-ldap-local.yml

+ 0
- 2
build.gradle Ver ficheiro

@@ -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'


+ 0
- 9
src/main/java/com/ffii/tsms/config/security/SecurityConfig.java Ver ficheiro

@@ -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();


+ 0
- 23
src/main/java/com/ffii/tsms/config/security/jwt/web/JwtAuthenticationController.java Ver ficheiro

@@ -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) {


+ 0
- 5
src/main/resources/application-db-2fi.yml Ver ficheiro

@@ -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

+ 0
- 9
src/main/resources/application-ldap-local.yml Ver ficheiro

@@ -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

Carregando…
Cancelar
Guardar