RestTemplate实现远程调用
This commit is contained in:
parent
4d461f43bb
commit
31acc77362
15
.run/BorrowApplication.run.xml
Normal file
15
.run/BorrowApplication.run.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="BorrowApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" folderName="OAuth2" nameIsGenerated="true">
|
||||
<module name="borrow-service" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.test.BorrowApplication" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="com.test.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
17
.run/Nacos.run.xml
Normal file
17
.run/Nacos.run.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Nacos" type="ShConfigurationType">
|
||||
<option name="SCRIPT_TEXT" value="" />
|
||||
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
||||
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/nacos/bin/startup.sh" />
|
||||
<option name="SCRIPT_OPTIONS" value="-m standalone" />
|
||||
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
||||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/nacos" />
|
||||
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
||||
<option name="INTERPRETER_PATH" value="/bin/bash" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="EXECUTE_IN_TERMINAL" value="true" />
|
||||
<option name="EXECUTE_SCRIPT_FILE" value="true" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
15
.run/UserApplication.run.xml
Normal file
15
.run/UserApplication.run.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="UserApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" folderName="OAuth2" nameIsGenerated="true">
|
||||
<module name="user-service" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.test.UserApplication" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="com.test.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -5,3 +5,6 @@ server:
|
||||
#这里修改一下context-path,这样保存的Cookie会使用指定的路径,就不会和其他服务打架了
|
||||
#但是注意之后的请求都得在最前面加上这个路径
|
||||
context-path: /sso
|
||||
spring:
|
||||
application:
|
||||
name: authservice
|
||||
|
@ -2,7 +2,6 @@ package com.test;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
|
||||
/**
|
||||
|
@ -5,11 +5,11 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
|
||||
/**
|
||||
* ClassName: con
|
||||
* ClassName: cong
|
||||
* Package: com.test.config
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2023/8/21 10:23
|
||||
* @Create 2023/8/21 20:10
|
||||
*/
|
||||
@Configuration
|
||||
public class ResourceConfiguration extends ResourceServerConfigurerAdapter { //继承此类进行高度自定义
|
||||
@ -18,7 +18,7 @@ public class ResourceConfiguration extends ResourceServerConfigurerAdapter { //
|
||||
public void configure(HttpSecurity http) throws Exception { //这里也有HttpSecurity对象,方便我们配置SpringSecurity
|
||||
http
|
||||
.authorizeRequests()
|
||||
.anyRequest().access("#oauth2.hasScope('lbwnb')"); //添加自定义规则
|
||||
.anyRequest().access("#oauth2.hasScope('book')"); //添加自定义规则
|
||||
//Token必须要有我们自定义scope授权才可以访问此资源
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.test.service.impl;
|
||||
|
||||
import com.test.entity.Book;
|
||||
import com.test.mapper.BookMapper;
|
||||
import com.test.service.BookService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import com.test.entity.Book;
|
||||
|
||||
/**
|
||||
* ClassName: BookServiceImpl
|
||||
|
@ -6,6 +6,8 @@ spring:
|
||||
url: jdbc:mysql://43.143.164.194:3306/mac
|
||||
username: mac
|
||||
password: mactest
|
||||
application:
|
||||
name: bookservice
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.test.config;
|
||||
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.oauth2.client.OAuth2ClientContext;
|
||||
|
@ -6,6 +6,8 @@ spring:
|
||||
url: jdbc:mysql://43.143.164.194:3306/mac
|
||||
username: mac
|
||||
password: mactest
|
||||
application:
|
||||
name: borrowservice
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
|
@ -2,7 +2,6 @@ package com.test;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,8 @@ spring:
|
||||
url: jdbc:mysql://43.143.164.194:3306/mac
|
||||
username: mac
|
||||
password: mactest
|
||||
application:
|
||||
name: userservice
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
|
Loading…
Reference in New Issue
Block a user