I have OAuth2(AuthorizationServer) enabled on my spring boot application
I wanna authenticate facebook users using REST request when they pass their access token from mobile app.
i have controller that receives facebook token
@RequestMapping(value = "/login-with-fb", method = RequestMethod.POST)
public boolean fb(@RequestParam String token) {
System.out.ptintln("Yay i have the token"+token);
return true;
}
This is as much as this controller should do, I guess all the magic should happen in filter, which is injected by my Resource Server here:
@Override
protected void configure(HttpSecurity http) throws Exception {
.antMatcher("/**").authorizeRequests()//All request are protected by default
.antMatchers("/abc/**").permitAll()
.antMatchers("/xyz/**").hasAuthority("ROLE_USER")
//We plugin facebook filter here
.and().addFilterBefore(facebookFilter(), BasicAuthenticationFilter.class);
}
And finally how would the filter look like?
private Filter facebookFilter() {
// What goes here? I assume we need to get the token,
// pass it to FB to validate it again then retrieve/create user
// and then somehow generate and return an OAuth2 token
// So that user can use that token instead of FB token
// to access secure content on my server
}
Or is there a better way to achieve the same?