RestTemplate实现远程调用
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user