Class SecurityConfig

java.lang.Object
com.erudika.para.server.security.SecurityConfig

@Configuration @EnableWebSecurity @DeclareRoles({"ROLE_USER","ROLE_MOD","ROLE_ADMIN","ROLE_APP"}) public class SecurityConfig extends Object
Programmatic configuration for Spring Security.
Author:
Alex Bogdanovski [[email protected]]
  • Field Details

    • DEFAULT_ROLES

      public static final String[] DEFAULT_ROLES
      Default roles.
  • Constructor Details

    • SecurityConfig

      public SecurityConfig()
      No-args constructor.
  • Method Details

    • authenticationManager

      @Bean public org.springframework.security.authentication.AuthenticationManager authenticationManager()
      Configures the AuthenticationManager with various providers.
      Returns:
      the authentication manager
    • webSecurityCustomizer

      @Bean public org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer webSecurityCustomizer()
      Configures the unsecured public resources.
      Returns:
      web security customizer
    • filterChain

      @Bean public org.springframework.security.web.SecurityFilterChain filterChain(org.springframework.security.config.annotation.web.builders.HttpSecurity http, org.springframework.security.authentication.AuthenticationManager authManager, FacebookAuthFilter facebookAuth, GoogleAuthFilter googleAuth, GitHubAuthFilter githubAuth, LinkedInAuthFilter linkedinAuth, TwitterAuthFilter twitterAuth, MicrosoftAuthFilter microsoftAuth, SlackAuthFilter slackAuth, AmazonAuthFilter amazonAuth, GenericOAuth2Filter oauth2Auth, LdapAuthFilter ldapAuth, PasswordAuthFilter passwordAuth, PasswordlessAuthFilter passwordlessAuth) throws Exception
      Configures the protected private resources.
      Parameters:
      http - HTTP security object
      authManager - authentication manager
      facebookAuth - Facebook auth filter
      googleAuth - Google auth filter
      githubAuth - GitHub auth filter
      linkedinAuth - LinkedIn auth filter
      twitterAuth - Twitter auth filter
      microsoftAuth - Microsoft auth filter
      slackAuth - Slack auth filter
      amazonAuth - Amazon auth filter
      oauth2Auth - generic OAuth2 auth filter
      ldapAuth - LDAP auth filter
      passwordAuth - password auth filter
      passwordlessAuth - passwordless auth filter
      Returns:
      the security filter chain
      Throws:
      Exception - ex
    • simpleUserDetailsService

      @Bean public org.springframework.security.core.userdetails.UserDetailsService simpleUserDetailsService()
      Supplies the simple in-memory UserDetailsService used for admin authentication.
      Returns:
      service backed by SimpleUserService
    • getSuccessHandler

      @Bean public SimpleAuthenticationSuccessHandler getSuccessHandler()
      Returns the authentication success handler.
      Returns:
      success handler
    • getFailureHandler

      @Bean public SimpleAuthenticationFailureHandler getFailureHandler()
      Returns the authentication failure handler.
      Returns:
      failure handler
    • getJWTAuthFilter

      @Bean public JWTRestfulAuthFilter getJWTAuthFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager, FacebookAuthFilter facebookAuth, GoogleAuthFilter googleAuth, GitHubAuthFilter githubAuth, LinkedInAuthFilter linkedinAuth, TwitterAuthFilter twitterAuth, MicrosoftAuthFilter microsoftAuth, SlackAuthFilter slackAuth, AmazonAuthFilter amazonAuth, GenericOAuth2Filter oauth2Auth, LdapAuthFilter ldapAuth, PasswordAuthFilter passwordAuth, PasswordlessAuthFilter passwordlessAuth)
      Returns the JWT restful authentication filter.
      Parameters:
      authenticationManager - auth manager
      facebookAuth - Facebook auth filter
      googleAuth - Google auth filter
      githubAuth - GitHub auth filter
      linkedinAuth - LinkedIn auth filter
      twitterAuth - Twitter auth filter
      microsoftAuth - Microsoft auth filter
      slackAuth - Slack auth filter
      amazonAuth - Amazon auth filter
      oauth2Auth - generic OAuth2 auth filter
      ldapAuth - LDAP auth filter
      passwordAuth - password auth filter
      passwordlessAuth - passwordless auth filter
      Returns:
      filter
    • getPasswordFilter

      @Bean public PasswordAuthFilter getPasswordFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the password authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getPasswordlessFilter

      @Bean public PasswordlessAuthFilter getPasswordlessFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the passwordless authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getFacebookFilter

      @Bean public FacebookAuthFilter getFacebookFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the Facebook authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • setFacebookAuthFilter

      public static void setFacebookAuthFilter(FacebookAuthFilter facebookAuthFilter)
      For testing only.
      Parameters:
      facebookAuthFilter - used for testing
    • getGoogleFilter

      @Bean public GoogleAuthFilter getGoogleFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the Google authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getLinkedinFilter

      @Bean public LinkedInAuthFilter getLinkedinFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the LinkedIn authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getTwitterFilter

      @Bean public TwitterAuthFilter getTwitterFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the Twitter authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getGithubFilter

      @Bean public GitHubAuthFilter getGithubFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the GitHub authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getMicrosoftFilter

      @Bean public MicrosoftAuthFilter getMicrosoftFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the Microsoft authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getSlackFilter

      @Bean public SlackAuthFilter getSlackFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the Slack authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getAmazonFilter

      @Bean public AmazonAuthFilter getAmazonFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the Amazon authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getGenericOAuth2Filter

      @Bean public GenericOAuth2Filter getGenericOAuth2Filter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the generic OAuth2 authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getLdapAuthFilter

      @Bean public LdapAuthFilter getLdapAuthFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the LDAP authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getSamlAuthFilter

      @Bean public SAMLAuthFilter getSamlAuthFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager)
      Returns the SAML authentication filter.
      Parameters:
      authenticationManager - auth manager
      Returns:
      filter
    • getSamlMetadataFilter

      @Bean public SAMLMetadataFilter getSamlMetadataFilter()
      Returns the SAML metadata filter.
      Returns:
      filter