It is Spring and VueJs application I am learning how to use OAuth google(sorry for bad explain), in application.properites i am adding my 'security.oauth2.client.clientId' and 'security.oauth2.client.clientSecret'
No problems with compilation and no exceptions. I starting localhost:9000 as written in my properties, and its 404 Error with warning in console: Cross-Origin Read Blocking (CORB) blocked cross-origin response {here link of google.account... + with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details }
To check if its working, I open localhost:9000/country and its shows my json formatted data as it have to be. So i think its problem not about my code excatly, but I am not sure.
After I checked my index.html - there was no "http-equiv="Content-Type" content="text/html;". I was sure its about that. But no... It still shows that Warning.
@Configuration
@EnableWebSecurity
@EnableOAuth2Sso
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/login**", "/js/**", "/error**").permitAll()
.anyRequest().authenticated()
.and().logout().logoutSuccessUrl("/").permitAll()
.and()
.csrf().disable();
}
@Bean
public PrincipalExtractor principalExtractor(UserDetailsRepo userDetailsRepo) {
return map -> {
String id = (String) map.get("sub");
User user = userDetailsRepo.findById(id).orElseGet(() -> {
User newUser = new User();
newUser.setId(id);
newUser.setName((String) map.get("name"));
newUser.setEmail((String) map.get("email"));
newUser.setGender((String) map.get("gender"));
newUser.setLocale((String) map.get("locale"));
newUser.setUserpic((String) map.get("picture"));
return newUser;
});
user.setLastVisit(LocalDateTime.now());
return userDetailsRepo.save(user);
};
}
}
@Controller
@RequestMapping("/")
public class MainController {
@GetMapping
public String main(Model model, @AuthenticationPrincipal User user){
HashMap<Object, Object> data = new HashMap<>();
data.put("profile", user);
data.put("messages", null);
model.addAttribute("frontendData", data);
return "index";
}
@Entity
@Table(name = "usr")
@Data
public class User {
@Id
// @GeneratedValue(strategy = GenerationType.AUTO)
private String id;
private String name;
private String userpic;
private String email;
private String gender;
private String locale;
private LocalDateTime lastVisit;
}
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://accounts.google.{etc} with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.