Class ApplicationConfig
java.lang.Object
edu.ntnu.idatt2106_2023_06.backend.config.ApplicationConfig
@Configuration
@EnableAsync(proxyTargetClass=true)
@EnableCaching
@ImportAutoConfiguration({DatabaseConfig.class,ApiKeyConfig.class,MailConfig.class})
public class ApplicationConfig
extends Object
This class provides application configuration for Spring Security. It sets up the user details service to
fetch user details from the user repository, creates an authentication provider that uses the user details service,
and provides a password encoder to be used for password hashing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.authentication.AuthenticationManager
authenticationManager
(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration config) This method returns an AuthenticationManager bean that can be used to authenticate users.org.springframework.security.authentication.AuthenticationProvider
This method returns an AuthenticationProvider that uses the user details service and password encoder to authenticate users.org.springframework.security.crypto.password.PasswordEncoder
This method return the application's current Password Encoder, which leverages the bcrypt algorithm.org.springframework.security.core.userdetails.UserDetailsService
This method returns a UserDetailsService that retrieves user details from the user repository.
-
Constructor Details
-
ApplicationConfig
public ApplicationConfig()
-
-
Method Details
-
userDetailsService
@Bean public org.springframework.security.core.userdetails.UserDetailsService userDetailsService()This method returns a UserDetailsService that retrieves user details from the user repository.- Returns:
- a UserDetailsService that retrieves user details from the user repository.
-
authenticationProvider
@Bean public org.springframework.security.authentication.AuthenticationProvider authenticationProvider()This method returns an AuthenticationProvider that uses the user details service and password encoder to authenticate users.- Returns:
- an AuthenticationProvider that uses the user details service and password encoder to authenticate users.
-
authenticationManager
@Bean public org.springframework.security.authentication.AuthenticationManager authenticationManager(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration config) throws Exception This method returns an AuthenticationManager bean that can be used to authenticate users.- Parameters:
config
- The AuthenticationConfiguration to use- Returns:
- An AuthenticationManager bean that can be used to authenticate users.
- Throws:
Exception
- Any exception thrown by theAuthenticationConfiguration.getAuthenticationManager()
-
passwordEncoder
@Bean public org.springframework.security.crypto.password.PasswordEncoder passwordEncoder()This method return the application's current Password Encoder, which leverages the bcrypt algorithm. The BCryptPasswordEncoder can take in a strength as a parameter and is recommended to take about 1 second to generate.- Returns:
- BCrypt password encoder, given as a PasswordEncoder object.
-