Skip to content

Instantly share code, notes, and snippets.

@ahndmal
Created December 1, 2020 10:26
Show Gist options
  • Save ahndmal/4468faefbb0734ec4170ff72013f3acf to your computer and use it in GitHub Desktop.
Save ahndmal/4468faefbb0734ec4170ff72013f3acf to your computer and use it in GitHub Desktop.
@EnableWebSecurity
public class JdbcSecurityConfiguration extends WebSecurityConfigurerAdapter {
...
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.jdbcAuthentication()
.dataSource(dataSource)
.passwordEncoder(passwordEncoder())
.usersByUsernameQuery(
"SELECT username, password, enabled from users where username = ?")
.authoritiesByUsernameQuery(
"SELECT u.username, a.authority " +
"FROM user_authorities a, users u " +
"WHERE u.username = ? " +
"AND u.id = a.user_id"
);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment