JDBC-basedUser Store Example: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Spring Security Concepts =Example= <syntaxhighlight lang='java'> @Configuration @EnableWebSecurity public cl...")
 
 
(3 intermediate revisions by the same user not shown)
Line 20: Line 20:
         auth.
         auth.
           jdbcAuthentication().
           jdbcAuthentication().
           dataSource(dataSource);
           dataSource(dataSource).
          passwordEncoder(NoOpPasswordEncoder.getInstance()); // apparently it needs a password encoder otherwise it throws
                                                              // java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id
                                                                   
     }
     }
}
}
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 03:12, 26 October 2018

Internal

Example

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    private DataSource dataSource;

    public SecurityConfiguration(@Autowired DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.
          jdbcAuthentication().
           dataSource(dataSource).
           passwordEncoder(NoOpPasswordEncoder.getInstance()); // apparently it needs a password encoder otherwise it throws 
                                                               // java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id
                                                                     
    }
}