Skip to content

Instantly share code, notes, and snippets.

@osgafarov
osgafarov / gist:ef432de739f0e8dd2eb595c0c75aff1d
Last active November 9, 2018 22:08
Spring Boot OAuth2 implementation.
// ---- SAMPLE ENDPOINT ---- //
@RequestMapping(method = RequestMethod.GET, value = "users/{userId}")
Bookmark readUser(Principal principal, @PathVariable Long userId) {
return this.usersRepository.findOne(userId);
}
}
// ---- Configuration ---- //
@Configuration
@Configuration
class WebSecurityConfiguration extends GlobalAuthenticationConfigurerAdapter {
@Autowired
AccountRepository accountRepository;
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService());
}