Class DefaultSecurityConfiguration


  • @Configuration
    @Lazy
    @Import(JwtConfiguration.class)
    @EnableConfigurationProperties(yakworks.security.PasswordConfig.class)
    public class DefaultSecurityConfiguration
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void addJsonAuthenticationFilter​(org.springframework.security.config.annotation.web.builders.HttpSecurity http, yakworks.security.spring.token.store.TokenStore tokenStore)
      Legacy, Helper to setup a Filter to pick up POST to /api/login to it can be a REST call instead of just form post.
      static void addOpaqueTokenSupport​(org.springframework.security.config.annotation.web.builders.HttpSecurity http, yakworks.security.spring.token.store.TokenStore tokenStore)
      Adds the OpaqueTokenStoreAuthProvider that will look for Bearer tokens that start with opq_ prefix will look them up in tokenStore (DB).
      static void applyBasicDefaults​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
      Helper to set up HttpSecurity builder with default requestMatchers and forms.
      static void applyOauthJwt​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
      Sets up the JWT
      static void applySamlSecurity​(org.springframework.security.config.annotation.web.builders.HttpSecurity http, org.springframework.security.web.authentication.AuthenticationSuccessHandler successHandler)
      Example for simple Saml setup.
      org.springframework.security.authentication.AuthenticationManager authenticationManager​(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration authConfig)  
      yakworks.security.spring.user.AuthSuccessUserInfoListener authSuccessUserInfoListener()  
      yakworks.security.user.CurrentUser currentUser()  
      yakworks.security.user.CurrentUserHolder CurrentUserHolder()  
      yakworks.security.spring.token.generator.OpaqueTokenGenerator opaqueTokenGenerator()  
      org.springframework.security.crypto.password.PasswordEncoder passwordEncoder()  
      yakworks.security.services.PasswordValidator passwordValidator()  
      yakworks.security.SecService secService()  
      org.springframework.security.web.SecurityFilterChain securityFilterChain​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
      Default securityFilterChain.
      yakworks.security.spring.token.generator.StoreTokenGenerator storeTokenGenerator()  
      • Methods inherited from class java.lang.Object

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

      • DefaultSecurityConfiguration

        public DefaultSecurityConfiguration()
    • Method Detail

      • applyBasicDefaults

        public static void applyBasicDefaults​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
                                       throws java.lang.Exception
        Helper to set up HttpSecurity builder with default requestMatchers and forms. NOTE: this is more of an example and common place for smoke test apps to use. In your production app you would set this up for its specifc security needs
        Throws:
        java.lang.Exception
      • applySamlSecurity

        public static void applySamlSecurity​(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
                                             org.springframework.security.web.authentication.AuthenticationSuccessHandler successHandler)
                                      throws java.lang.Exception
        Example for simple Saml setup. Its largely dealt with in the configuration.
        Throws:
        java.lang.Exception
      • addJsonAuthenticationFilter

        public static void addJsonAuthenticationFilter​(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
                                                       yakworks.security.spring.token.store.TokenStore tokenStore)
                                                throws java.lang.Exception
        Legacy, Helper to setup a Filter to pick up POST to /api/login to it can be a REST call instead of just form post. adds JsonUsernamePasswordLoginFilter under /api/login and forwards it to api/tokenLegacy
        Throws:
        java.lang.Exception
      • addOpaqueTokenSupport

        public static void addOpaqueTokenSupport​(org.springframework.security.config.annotation.web.builders.HttpSecurity http,
                                                 yakworks.security.spring.token.store.TokenStore tokenStore)
        Adds the OpaqueTokenStoreAuthProvider that will look for Bearer tokens that start with opq_ prefix will look them up in tokenStore (DB).
      • applyOauthJwt

        public static void applyOauthJwt​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
                                  throws java.lang.Exception
        Sets up the JWT
        Throws:
        java.lang.Exception
      • securityFilterChain

        @Bean
        @ConditionalOnMissingBean(org.springframework.security.web.SecurityFilterChain.class)
        public org.springframework.security.web.SecurityFilterChain securityFilterChain​(org.springframework.security.config.annotation.web.builders.HttpSecurity http)
                                                                                 throws java.lang.Exception
        Default securityFilterChain. Helper to set up HttpSecurity builder with default requestMatchers and forms. NOTE: this is more of an example and a common simple setup for smoke test apps to use. In your production app you would set this up and replace for its specifc security needs
        Throws:
        java.lang.Exception
      • authenticationManager

        @Bean
        public org.springframework.security.authentication.AuthenticationManager authenticationManager​(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration authConfig)
                                                                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • authSuccessUserInfoListener

        @Bean
        @Lazy(false)
        public yakworks.security.spring.user.AuthSuccessUserInfoListener authSuccessUserInfoListener()
      • secService

        @Bean
        @ConditionalOnMissingBean
        public yakworks.security.SecService secService()
      • CurrentUserHolder

        @Bean("${CurrentUserHolder.name}")
        @Lazy(false)
        @Role(2)
        public yakworks.security.user.CurrentUserHolder CurrentUserHolder()
      • currentUser

        @Bean
        @ConditionalOnMissingBean
        public yakworks.security.user.CurrentUser currentUser()
      • passwordValidator

        @Bean
        @ConditionalOnMissingBean
        public yakworks.security.services.PasswordValidator passwordValidator()
      • passwordEncoder

        @Bean
        @ConditionalOnMissingBean
        public org.springframework.security.crypto.password.PasswordEncoder passwordEncoder()
      • opaqueTokenGenerator

        @Bean
        @ConditionalOnMissingBean
        public yakworks.security.spring.token.generator.OpaqueTokenGenerator opaqueTokenGenerator()
      • storeTokenGenerator

        @Bean
        @ConditionalOnMissingBean
        public yakworks.security.spring.token.generator.StoreTokenGenerator storeTokenGenerator()