Ви не можете вибрати більше 25 тем
Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
36 рядки
876 B
36 рядки
876 B
package com.aiprose.scauth.controller;
|
|
|
|
import org.springframework.security.access.annotation.Secured;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import javax.annotation.security.RolesAllowed;
|
|
|
|
/**
|
|
* @author nelson
|
|
* @desc TODO
|
|
* @company 北京中经网软件有限公司
|
|
* @date 2020/11/27 16:42
|
|
* @since 1.0
|
|
*/
|
|
@RestController
|
|
public class TestAuthController {
|
|
|
|
@Secured("ROLE_root") //需要加前缀
|
|
@GetMapping("root")
|
|
public String root(){
|
|
return "root";
|
|
}
|
|
@PreAuthorize("hasAnyRole('root','admin')")
|
|
@GetMapping("admin")
|
|
public String gest(){
|
|
return "admin";
|
|
}
|
|
|
|
@RolesAllowed("user")
|
|
@GetMapping("user")
|
|
public String user(){
|
|
return "user";
|
|
}
|
|
}
|
|
|