Class SecurityConfig

java.lang.Object
it.univr.passportease.config.SecurityConfig

@Configuration @EnableWebSecurity @EnableMethodSecurity public class SecurityConfig extends Object
Security configuration class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private org.springframework.data.redis.core.RedisTemplate<String,String>
    Redis template.
    User repository.
    Worker repository.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.authentication.AuthenticationManager
    authenticationManager(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration config)
    Creates an AuthenticationManager bean, used to authenticate the user.
    org.springframework.security.authentication.AuthenticationProvider
    Creates an AuthenticationProvider bean, used to authenticate the user.
    org.springframework.security.crypto.password.PasswordEncoder
    Creates a PasswordEncoder bean, used to encode the password.
    org.springframework.security.web.SecurityFilterChain
    securityFilterChain(org.springframework.security.config.annotation.web.builders.HttpSecurity http, JwtAuthFilter authFilter)
    Creates a SecurityFilterChain bean, used to configure the security filter chain.
    org.springframework.security.core.userdetails.UserDetailsService
    Creates a UserDetailsService bean, used to retrieve user details from the database or from the Redis cache.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • userRepository

      private UserRepository userRepository
      User repository.
    • workerRepository

      private WorkerRepository workerRepository
      Worker repository.
    • redisTemplate

      private org.springframework.data.redis.core.RedisTemplate<String,String> redisTemplate
      Redis template.
  • Constructor Details

    • SecurityConfig

      public SecurityConfig()
  • Method Details

    • userDetailsService

      @Bean public org.springframework.security.core.userdetails.UserDetailsService userDetailsService()
      Creates a UserDetailsService bean, used to retrieve user details from the database or from the Redis cache.
      Returns:
      UserDetailsService, used to retrieve user details from the database or from the Redis cache
    • securityFilterChain

      @Bean public org.springframework.security.web.SecurityFilterChain securityFilterChain(org.springframework.security.config.annotation.web.builders.HttpSecurity http, JwtAuthFilter authFilter) throws Exception
      Creates a SecurityFilterChain bean, used to configure the security filter chain. It is used to configure the authentication method, the authorization method and the session management.
      Parameters:
      http - HttpSecurity object
      authFilter - JwtAuthFilter object
      Returns:
      SecurityFilterChain, used to configure the security filter chain. It is used to configure the authentication method, the authorization method and the session management.
      Throws:
      Exception - if an error occurs in the csrf configuration
    • passwordEncoder

      @Bean public org.springframework.security.crypto.password.PasswordEncoder passwordEncoder()
      Creates a PasswordEncoder bean, used to encode the password.
      Returns:
      PasswordEncoder, used to encode the password
    • authenticationProvider

      @Bean public org.springframework.security.authentication.AuthenticationProvider authenticationProvider()
      Creates an AuthenticationProvider bean, used to authenticate the user.
      Returns:
      AuthenticationProvider, used to authenticate the user
    • authenticationManager

      @Bean public org.springframework.security.authentication.AuthenticationManager authenticationManager(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration config) throws Exception
      Creates an AuthenticationManager bean, used to authenticate the user.
      Parameters:
      config - AuthenticationConfiguration object, used to configure the authentication manager
      Returns:
      AuthenticationManager, used to authenticate the user
      Throws:
      Exception - if an error occurs in the authentication manager configuration