增加资源服务demo(无网络隔离)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package org.zlt;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
* @date 2022/6/25
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class ResourcesServerApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ResourcesServerApp.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.zlt.config;
|
||||
|
||||
import com.central.oauth2.common.config.DefaultResourceServerConf;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
|
||||
/**
|
||||
* security资源服务器配置
|
||||
*
|
||||
* @author zlt
|
||||
* @version 1.0
|
||||
* @date 2022/6/25
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
public class MyResourceConfig extends DefaultResourceServerConf {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.zlt.config;
|
||||
|
||||
import com.central.common.config.DefaultWebMvcConfig;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* web服务器配置
|
||||
*
|
||||
* @author zlt
|
||||
* @version 1.0
|
||||
* @date 2022/6/25
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig extends DefaultWebMvcConfig {
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.zlt.controller;
|
||||
|
||||
import com.central.common.annotation.LoginUser;
|
||||
import com.central.common.model.SysUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
* @date 2022/6/25
|
||||
* <p>
|
||||
* Blog: https://zlt2000.gitee.io
|
||||
* Github: https://github.com/zlt2000
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class TestController {
|
||||
@GetMapping("/test/auth")
|
||||
public String auth(@LoginUser SysUser user) {
|
||||
return "auth:" + user.getUsername();
|
||||
}
|
||||
|
||||
@GetMapping("/test/notAuth")
|
||||
public String notAuth() {
|
||||
return "notAuth:ok";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user