Giter Club home page Giter Club logo

microservice-integration's Introduction

整合项目

consul的版本为0.8.5版本 下载链接

整合的项目包括网关、auth权限服务和backend服务。提供了一套微服务架构下,网关服务路由、鉴权和授权认证的项目案例。整个项目的架构图如下:

ms

欲了解更多,见博客《微服务架构中整合网关、权限服务

你的star是对我最好的鼓励^_^

change log

2018.9.25

增加了Spring Cloud Gateway作为网关实现的模块,详见:微服务网关Zuul迁移到Spring Cloud Gateway

新增功能:

  • 全局断路器
  • 限流过滤器
  • ...

项目使用方法

如果你的GitHub网络有问题,请移步码云:https://gitee.com/keets/microservice-integration

涉及到的组件与服务

微服务架构基于Spring Cloud,用到了部分Spring Cloud提供的组件。

  • consul 服务发现组件,所有的服务注册到该组件,类似zk
  • feign 声明式的http调用组件,Spring Cloud通过该组件实现服务之间的通信
  • 存储主要是mysql和redis,auth的初始化sql脚本已经提供
  • auth-server:端口9091 安全权限服务
  • gateway:端口10101 网关,提供路由转发等
  • backend-server:端口9092 实例的后端服务,提供接口级别的权限校验

端点测试

  1. 安装一下,mvn clean install -DskipTests,包括三个模块。
  2. 登录端点

head form

{
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTMwOTEzMzEsIlgtQU9ITy1Vc2VySWQiOiJjNjIxY2ZlMy02ZjUzLTQ1ZDYtODRiYi0wNzEyMTE5NDZiMjQiLCJ1c2VyX25hbWUiOiJrZWV0cyIsImp0aSI6ImEwODZmMWIyLWEzOTQtNDUwZS1iMDVlLTEzNmE0ZjdlOTEyZiIsImNsaWVudF9pZCI6ImZyb250ZW5kIiwic2NvcGUiOlsiYWxsIl19.MQP8l_RhmZ-rpxAg8Cguq6X6IA1PaKtrwlxZoMjMTLQ",
    "token_type": "bearer",
    "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJrZWV0cyIsInNjb3BlIjpbImFsbCJdLCJhdGkiOiJhMDg2ZjFiMi1hMzk0LTQ1MGUtYjA1ZS0xMzZhNGY3ZTkxMmYiLCJleHAiOjE1MTU2NDAxMzEsIlgtQU9ITy1Vc2VySWQiOiJjNjIxY2ZlMy02ZjUzLTQ1ZDYtODRiYi0wNzEyMTE5NDZiMjQiLCJqdGkiOiJlZTNhOThlOS0zOThhLTQwYTctOGI0YS1jYzRlOGY4ZmVmNDkiLCJjbGllbnRfaWQiOiJmcm9udGVuZCJ9.k2lVqFfJ0xNkly_10O1u3QQGTHMGp0kxVAEDMjdUgbo",
    "expires_in": 43199,
    "scope": "all",
    "X-AOHO-UserId": "c621cfe3-6f53-45d6-84bb-071211946b24",
    "jti": "a086f1b2-a394-450e-b05e-136a4f7e912f",
    "X-AOHO-ClientId": "frontend"
}

3.刷新端点 refresh

返回结果与上面登录类似。

4.登出端点

out

5.backend后端接口 test

上述请求到达backend被拒绝,因为auth服务使用的userId是随机生成,如果你要真是使用,请修改那部分user服务的实现。

写在后面

感谢黄同学@CANGWU 对Spring EL部分做的修改。 项目整合如果遇到问题,可以加入qq群649932629,最好大家都能自行搞定。。

推荐阅读

  1. 微服务网关netflix-zuul
  2. 认证鉴权与API权限控制在微服务架构中的设计与实现(一)
  3. 认证鉴权与API权限控制在微服务架构中的设计与实现(二)
  4. 认证鉴权与API权限控制在微服务架构中的设计与实现(三)
  5. 认证鉴权与API权限控制在微服务架构中的设计与实现(四)
  6. 微服务架构中整合网关、权限服务

订阅最新文章,欢迎关注我的公众号

微信公众号

microservice-integration's People

Contributors

keets2012 avatar cangwu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.