测试权限控制
This commit is contained in:
@ -0,0 +1,36 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.bizmessage.controller;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1")
|
||||||
|
public class AuthorizeController {
|
||||||
|
|
||||||
|
private @Autowired IBaseCacheUserService service;
|
||||||
|
|
||||||
|
@GetMapping("user")
|
||||||
|
@ResponseStatus(code = HttpStatus.OK)
|
||||||
|
public Object user(Principal principal) {
|
||||||
|
BaseCacheUser cacheUser = service.getCacheUser();
|
||||||
|
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
System.out.println(auth.getName());
|
||||||
|
System.out.println(auth.getAuthorities());
|
||||||
|
System.out.println(principal);
|
||||||
|
|
||||||
|
return cacheUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user