package com.kidgrow.web.controller;
|
|
import org.springframework.security.core.Authentication;
|
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
/**
|
* 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
|
*
|
* @Description: Security 配置<br>
|
* @Project: <br>
|
* @CreateDate: Created in 2020/3/04 10:25 <br>
|
* @Author: <a href="4345453@kidgrow.com">liuke</a>
|
*/
|
@Controller
|
public class HomeController {
|
@GetMapping("/")
|
public String home(ModelMap modelMap, Authentication authentication) {
|
OAuth2Authentication oauth2Authentication = (OAuth2Authentication)authentication;
|
modelMap.put("username", oauth2Authentication.getName());
|
modelMap.put("authorities", oauth2Authentication.getAuthorities());
|
modelMap.put("clientId", oauth2Authentication.getOAuth2Request().getClientId());
|
OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails)oauth2Authentication.getDetails();
|
modelMap.put("token", details.getTokenValue());
|
return "index";
|
}
|
}
|