Class SecurityConfiguration
java.lang.Object
io.github.yvasyliev.forwarder.telegram.bot.configuration.SecurityConfiguration
@Configuration
@EnableGlobalAuthentication
@EnableMethodSecurity
public class SecurityConfiguration
extends Object
Security configuration for the Telegram Forwarder Bot. This class sets up the authentication manager and user details
service for the application, allowing for secure access to methods and resources.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticationManager(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration authConfig) Configures the authentication manager to allow for custom user details handling.org.springframework.security.core.userdetails.UserDetailsServiceuserDetailsService(TelegramAdminProperties adminProperties) Provides an in-memory user details service with an admin user.
-
Constructor Details
-
SecurityConfiguration
public SecurityConfiguration()
-
-
Method Details
-
authenticationManager
@Bean public TelegramAuthenticationManager authenticationManager(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration authConfig) Configures the authentication manager to allow for custom user details handling. This method sets thehideUserNotFoundExceptionsproperty tofalse, enabling more informative error messages during authentication failures.- Parameters:
authConfig- the authentication configuration- Returns:
- the configured authentication manager
-
userDetailsService
@Bean public org.springframework.security.core.userdetails.UserDetailsService userDetailsService(TelegramAdminProperties adminProperties) Provides an in-memory user details service with an admin user. This method creates a user details manager that contains a single admin user with the ID specified in the Telegram properties.- Parameters:
adminProperties- the Telegram admin properties- Returns:
- the user details service with the admin user
-