Skip to content

Commit

Permalink
refactor: optimize imports, remove unused properties in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bilskik committed Jun 14, 2024
1 parent 7e28b49 commit f13f3ba
Show file tree
Hide file tree
Showing 17 changed files with 12 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 1,21 @@
package pl.bilskik.backend.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.server.Cookie;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;
import org.springframework.security.web.csrf.*;
import org.springframework.security.web.header.writers.XXssProtectionHeaderWriter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import pl.bilskik.backend.config.cookie.CsrfCookieConfig;
import pl.bilskik.backend.config.cors.CorsConfig;
import pl.bilskik.backend.config.failure.AuthenticationFailureCounter;
import pl.bilskik.backend.config.filter.AuthFilter;
import pl.bilskik.backend.config.manager.AuthManager;
import pl.bilskik.backend.config.userconfig.UserRole;

import java.util.Arrays;

import static pl.bilskik.backend.config.cookie.SessionCookieConfig.SESSION_COOKIE_NAME;
import static pl.bilskik.backend.controller.mapping.UrlMapping.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 5,17 @@
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import pl.bilskik.backend.data.request.LoginRequest;
import pl.bilskik.backend.config.manager.AuthManager;
import pl.bilskik.backend.data.request.LoginRequest;

import java.io.IOException;

import static pl.bilskik.backend.controller.mapping.UrlMapping.LOGIN_FINISH_URL;

@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 7,6 @@
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import pl.bilskik.backend.config.failure.AuthenticationFailureCounter;
import pl.bilskik.backend.config.failure.LoginAttemptsContainer;
import pl.bilskik.backend.config.userconfig.DetailsService;
import pl.bilskik.backend.config.userconfig.SecurityUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 8,6 @@

import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class SecurityUser implements UserDetails {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 1,20 @@
package pl.bilskik.backend.controller;

import jakarta.validation.Valid;
import org.apache.coyote.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.web.csrf.CsrfToken;
import org.springframework.web.bind.annotation.*;
import pl.bilskik.backend.data.request.BeginResetPasswordRequest;
import pl.bilskik.backend.data.request.FinishResetPasswordRequest;
import pl.bilskik.backend.data.request.UserRegisterRequest;
import pl.bilskik.backend.data.request.FirstLoginRequest;
import pl.bilskik.backend.data.request.UserRegisterRequest;
import pl.bilskik.backend.data.response.FirstLoginResponse;
import pl.bilskik.backend.data.response.ResponseMessage;
import pl.bilskik.backend.data.response.UserResponse;
import pl.bilskik.backend.service.AuthService;
import pl.bilskik.backend.service.auth.AuthServiceImpl;

import java.security.Principal;

import static pl.bilskik.backend.controller.mapping.UrlMapping.*;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 2,11 @@

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pl.bilskik.backend.data.response.UserResponse;
import pl.bilskik.backend.data.response.UserDetailsResponse;
import pl.bilskik.backend.data.response.UserResponse;
import pl.bilskik.backend.service.UserService;

import java.security.Principal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 2,10 @@
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 1,5 @@
package pl.bilskik.backend.data.request;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import pl.bilskik.backend.data.response.FirstLoginResponse;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,6 @@
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
4 changes: 0 additions & 4 deletions backend/src/main/java/pl/bilskik/backend/entity/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 3,9 @@
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import pl.bilskik.backend.entity.Password;
import pl.bilskik.backend.entity.Transfer;
import pl.bilskik.backend.entity.embeded.Address;
import pl.bilskik.backend.entity.util.Encrypt;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 9,6 @@
import pl.bilskik.backend.entity.Users;

import java.util.List;
import java.util.Optional;

@Repository
public interface PasswordRepository extends JpaRepository<Password, Integer> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 1,5 @@
package pl.bilskik.backend.service.auth.creator;

import jakarta.persistence.criteria.CriteriaBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 7,8 @@
import pl.bilskik.backend.repository.UserRepository;
import pl.bilskik.backend.service.auth.creator.PasswordCreator;

import java.util.*;
import java.util.List;
import java.util.Random;

@Service
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 10,13 @@
import pl.bilskik.backend.entity.Users;
import pl.bilskik.backend.repository.UserRepository;
import pl.bilskik.backend.service.auth.creator.PasswordCreator;
import pl.bilskik.backend.service.exception.EntropyException;
import pl.bilskik.backend.service.auth.validator.Entropy;
import pl.bilskik.backend.service.auth.validator.PasswordValidator;
import pl.bilskik.backend.service.exception.EntropyException;

import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static pl.bilskik.backend.service.auth.validator.Entropy.GOOD;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 3,8 @@
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pl.bilskik.backend.data.response.UserResponse;
import pl.bilskik.backend.data.response.UserDetailsResponse;
import pl.bilskik.backend.data.response.UserResponse;
import pl.bilskik.backend.entity.Users;
import pl.bilskik.backend.repository.UserRepository;
import pl.bilskik.backend.service.UserService;
Expand Down
59 changes: 0 additions & 59 deletions backend/src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,62 42,3 @@ cipher:
key: "1234567812345678"
iv : "1234567812345678"
algoList : "AES/CBC/PKCS5PADDING"

#server.port=8080
#server.ssl.key-store-type=PKCS12
#server.ssl.key-store=classpath:secure-bank-pro.p12
#server.ssl.key-store-password=root
#server.ssl.enabled=true
#
#spring.jpa.hibernate.ddl-auto=update
#spring.datasource.url=jdbc:postgresql://postgresdb/bank
#spring.datasource.username=user
#spring.datasource.password=password
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#
#spring.datasource.url=jdbc:mysql://localhost:3306/bankdb
#spring.datasource.username=root
#spring.datasource.password=password
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.jpa.show-sql=true

#spring.session.redis.repository-type=default
#spring.data.redis.server=redis
#spring.data.redis.host=redis
#spring.data.redis.port=6379
#
#spring.jpa.properties.hibernate.format_sql=true
#spring.jpa.properties.hibernate.use_sql_comments=true
#spring.jpa.properties.hibernate.highlight_sql=true
#
#logging.level.org.springframework.security=TRACE


#server.port=8080
#server.ssl.key-store-type=PKCS12
#server.ssl.key-store=classpath:secure-bank-pro.p12
#server.ssl.key-store-password=root
#server.ssl.enabled=true
#
#spring.jpa.hibernate.ddl-auto=update
#spring.datasource.url=jdbc:postgresql://postgresdb/bank
#spring.datasource.username=user
#spring.datasource.password=password
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
##
##spring.datasource.url=jdbc:mysql://localhost:3306/bankdb
##spring.datasource.username=root
##spring.datasource.password=password
##spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
##spring.jpa.show-sql=true
#
#spring.session.redis.repository-type=default
#spring.data.redis.server=redis
#spring.data.redis.host=redis
#spring.data.redis.port=6379
#
#spring.jpa.properties.hibernate.format_sql=true
#spring.jpa.properties.hibernate.use_sql_comments=true
#spring.jpa.properties.hibernate.highlight_sql=true
#
#logging.level.org.springframework.security=TRACE

0 comments on commit f13f3ba

Please sign in to comment.