Package it.univr.passportease.config
Class SecurityConfig
java.lang.Object
it.univr.passportease.config.SecurityConfig
Security configuration class.
-
Field Summary
Modifier and TypeFieldDescriptionRedis template.private UserRepository
User repository.private WorkerRepository
Worker repository. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.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.
-
Field Details
-
userRepository
User repository. -
workerRepository
Worker repository. -
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 objectauthFilter
- 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
-