Fetch the repository succeeded.
This action will force synchronization from 江离/AG-Gate, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
AG-Gate 是一个基于spring cloud的用户资源授权、api管理授权的网关系统,以jwt交互的鉴权token来实施,支持基于Eureka注册中心下的服务鉴权和拦截,同时扩展Eureka下服务失效的通知扩展。
可以根据需要扩展不同的消息通知,也可以做钩子结合实效后自动重启服务。
AG-Gate主要是给服务之间做JWT鉴权和对外api的鉴权。我们平时无状态的api访问方式分为服务之间的互相调用和提供给外部系统的调用。
ace-gate-way下application.yml,会影响认证的相关信息。
具体例子可以参考ace-gate-demo
<dependency>
<groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-gate-agent</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
gate:
client:
# 地址为ace-gate-way所在ip端口
authHost: http://localhost:8765/api/authen
# 鉴权头部标志,与客户端一致
authHeader: access-token
/**
* Created by ace on 2017/7/6.
*/
@Configuration
public class ApiWebAppConfig extends WebMvcConfigurerAdapter {
@Value("${gate.client.authHost}")
private String authHost;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new ApiInterceptor(authHost)).addPathPatterns("/**");
super.addInterceptors(registry);
}
}
@ApiGateSecurity
即可@ApiGateSecurity
@RequestMapping(value = "/user/un/{username}/system", method = RequestMethod.GET)
@ResponseBody
public String getSystemsByUsername(@PathVariable("username") String username){
int userId = userBiz.getUserByUsername(username).getId();
return JSONObject.toJSONString(menuBiz.getUserAuthoritySystemByUserId(userId));
}
<dependency>
<groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-gate-agent</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
gate:
client:
# 页面注册的客户信息
clientId: admin-ui
secret: test
# 与服务端authHeader保持一致
authHeader: access-token
authHost: http://localhost:8765/api/authen
# 与ace-gate-way gate.api.tokenHead保持一致
tokenHead: ApiGateToken
@Configuration
public class FeignApiConfig {
@Value("${gate.client.clientId}")
private String clientId;
@Value("${gate.client.secret}")
private String secret;
@Value("${gate.client.authHeader}")
private String authHeader;
@Value("${gate.client.authHost}")
private String authHost;
@Value("${gate.client.tokenHead}")
private String tokenHead;
@Bean
public FeignInterceptor authenticationInterceptor() {
return new FeignInterceptor(clientId, secret, authHeader, authHost, tokenHead);
}
}
{
"clientId":"gate-demo-client",
"secret":"test"
}
http://[ace-gate-way部署服务器]:[配置端口]/api/authen/auth
以下配置信息来自ace-gate-way的application.yml
[${gate.api.header}]:[${gate.api.tokenHead}][空格][神奇的token]
如默认格式:
access-token:ApiGateToken eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJnYXRlLWRlbW8tY2xpZW50IiwiY3JlYXRlZCI6MTQ5OTk0NzAzNzE1NCwiZXhwIjoxNDk5OTU0MjM3fQ.eL3Ucd2Oh166PDcmHLsKK2A0uJZ6QPxLqRac6enQacBEgQwc2I0qJtkui1V0WjB70VWHpRbHgmzps_dM9jKg0A
带实现
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。