Class SecurityConfiguration

java.lang.Object
io.github.yvasyliev.telegramforwarderbot.configuration.SecurityConfiguration

@Configuration @Import(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration.class) @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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.authentication.AuthenticationManager
    authenticationManager(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.UserDetailsService
    Provides an in-memory user details service with an admin user.

    Methods inherited from class java.lang.Object

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

    • SecurityConfiguration

      public SecurityConfiguration()
  • Method Details

    • authenticationManager

      @Bean public org.springframework.security.authentication.AuthenticationManager authenticationManager(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration authConfig) throws Exception
      Configures the authentication manager to allow for custom user details handling. This method sets the hideUserNotFoundExceptions property to false, enabling more informative error messages during authentication failures.
      Parameters:
      authConfig - the authentication configuration
      Returns:
      the configured authentication manager
      Throws:
      Exception - if an error occurs during configuration
    • userDetailsService

      @Bean public org.springframework.security.core.userdetails.UserDetailsService userDetailsService(TelegramProperties telegramProperties)
      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:
      telegramProperties - the Telegram properties containing the admin ID
      Returns:
      the user details service with the admin user