You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
876 B
37 lines
876 B
4 years ago
|
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";
|
||
|
}
|
||
|
}
|