GithubHelp home page GithubHelp logo

leecho / cola-cloud Goto Github PK

View Code? Open in Web Editor NEW
341.0 30.0 196.0 3.69 MB

Cola Cloud 基于 Spring Boot, Spring Cloud 构建微服务架构企业级开发平台,集成OAuth2认证、集成短信验证码登录、微信小程序登录、FlyWay数据库版本管理、网关集成Swagger聚合所有服务API文档。基于SpringBootAdmin集成Hystrix、Turbine监控。开发用户中心、权限管理、组织架构、数据字典、消息中心、通知中心等模块。基于MyBatisPlus Generator 开发代码生成器

License: MIT License

Java 70.80% JavaScript 13.39% HTML 5.43% CSS 10.38%
java spring-boot spring-cloud oauth2 microservice

cola-cloud's Introduction

Build Status Coverage Status Downloads

Cola Cloud

Cola Cloud 基于 Spring Boot, Spring Cloud 构建微服务架构企业级开发平台,集成OAuth2认证、集成短信验证码登录、FlyWay数据库版本管理、网关集成Swagger聚合所有服务API文档。基于SpringBootAdmin集成Hystrix、Turbine监控。开发用户中心、权限管理、组织架构、数据字典、消息中心、通知中心等模块。

服务介绍

项目名称 编号 名称 说明
cola-cloud-auth auth-service 认证服务 基于SpringSecurity进行安全认证,采用OAuth2.0认证体系,对客户端、用户进行认证及授权,支持账号密码登录,短信验证码登录
cola-cloud-config config 配置服务 基于Spring Cloud构建统一配置服务,负责管理所有服务的配置文件
cola-cloud-devtools 开发工具 Cola 代码生成器
cola-cloud-gateway gateway 服务网关 基于Zuul构建服务网关,并对服务进行负载,前只实现静态路由
cola-cloud-monitor monitor 服务监控 基于Spring Boot Admin集成Turbine,Hystrix,对应用状态进行监控,对服务调用进行追踪和对熔断进行监测
cola-cloud-message message 通知中心 公共基础通知服务,支持系统消息、短信、邮件、推送通知
cola-cloud-registry registry 服务注册 基于Euraka构建服务注册中心,负责服务注册于发现
cola-cloud-common common-service 基础服务 聚合Cola平台所有公共服务
cola-cloud-organization organization-service 组织架构 提供组织架构、员工、岗位等服务
cola-cloud-tenancy tenancy-service 租户服务 提供租户以及租户成员服务
cola-cloud-uc uc-service 租户服务 用户中心
cola-cloud-upm upm-service 权限服务 提供角色、资源、授权服务
cola-cloud-notification notification-service 通知中心 基于RabbitMQ异步通知发送短信、邮件、WebSocket消息

快速启动

下载代码

 git clone https://gitee.com/leecho/cola-cloud.git

配置HOST

Spring Cloud中的每个服务都是独立部署,所有在进行服务之间调用的时候需要确定对方服务的IP,为了规避IP变化带来代码修改的风险,所以需要配置host

# 注册中心 配置中心
127.0.0.1 registry api-gateway
# reids rabbitmq mysql
127.0.0.1 cola-redis cola-rabbitmq cola-mysql

环境变量

环境变量主要是配置服务的访问用户名和密码:

//配置服务器用户名
CONFIG_SERVER_USERNAME
//配置服务器密码
CONFIG_SERVER_PASSWORD
//注册服务器用户名
REGISTRY_SERVER_USERNAME
//注册服务器密码
REGISTRY_SERVER_PASSWORD
//监控服务器用户名
MONITOR_SERVER_USERNAME
//监控服务器密码
MONITOR_SERVER_PASSWORD
//MYSQL用户名
MYSQL_SERVER_USERNAME
//MYSQL密码
MYSQL_SERVER_PASSWORD
//RabbitMQ用户名
RABBITMQ_SERVER_USERNAME
//RabbitMQ密码
RABBITMQ_SERVER_PASSWORD
//Redis用户名
REDIS_SERVER_USERNAME
//Redis密码
REDIS_SERVER_PASSWORD

启动服务

启动顺序如下:registry config auth-service uc-serivce upm-service organization-service gateway monitor

registry必须要最先启动,registry启动之后提供接口以供其他服务进行注册

config在registry之后启动,config负责提供给其他服务配置信息,如果config没有启动,其他服务则无法启动

其他service在config之后启动,如果是第一次运行项目,启动config之后先启动uc-service进行数据初始化

gateway在最后启动,如果gateway先于其他服务启动,可能无法代理到其他服务,不过会在一段时间后重新代理

monitor,在config启动之后即可启动

访问

http://localhost:80/ 服务网关,已经聚合了所有服务的Swagger
http://localhost:8761/ 注册中心,可以查看服务注册情况
http://localhost:8080/ 监控中心,可以查看服务运行状态

获取ACCESS_TOKEN

curl -X POST \
  http://api-gateway/uaa/oauth/token \
  -H 'Cache-Control: no-cache' \
  -H 'Postman-Token: 40aa591e-8518-4c1f-9e2d-f0c0e6151a40' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F username=admin \
  -F password=111111 \
  -F grant_type=password \
  -F scope=ui

基础服务

配置服务

Spring Cloud Config 负责所有服务的配置,可以使用本地文件、GIT等方式存储分发配置文件

客户端配置

需要在POM中引入spring-cloud-starter-config 依赖, 根据约定自动状态

在项目中需要设置配置服务的信息,例如配置服务器的地址,访问的用户名和密码等信息,在resources目录下 bootstrap.yml 文件配置

spring:
  application:
    name: message-service
  cloud:
    config:
      uri: http://config:8888
      fail-fast: true

认证服务

Spring Security OAuth2 客户端配置

security:
  oauth2:
    client:
      clientId: server
      clientSecret: server
      accessTokenUri: http://auth-service:5000/uaa/oauth/token
      grant-type: client_credentials
      scope: server
@PreAuthorize("#oauth2.hasScope('server')")
@RequestMapping(value = "accounts/{name}", method = RequestMethod.GET)
public List<DataPoint> getStatisticsByAccountName(@PathVariable String name) {
	return statisticsService.findByAccountName(name);
}

服务网关

zuul:
  routes:
    message-service:
        path: /notifications/**
        serviceId: message-service
        stripPrefix: false

注册中心

spring:
  application:
    name: message-service

配置

短信配置

cola:
  sms:  #短信配置
    type: aliyun
    aliyun:
      access-key-id: 
      access-key-secret: 

存储配置

cola:
  storage:
    type: aliyun
    oss:
      access-key-id: 
      access-key-secret: 
      bucket-name: 
      endpoint: 

系统截图

获取Token

注册中心

API文档

监控中心

监控详细信息

链路追踪

代码生成器

QQ交流群:736697444

cola-cloud's People

Contributors

leecho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cola-cloud's Issues

请问自定义认证怎么返回自定义异常信息?

请问继承自AbstractPreparableIntegrationAuthenticator的自定义认证,比如短信认证,按照你的代码在prepare里进行验证码校验,不匹配则抛出OAuth2Exception异常,不过这个异常信息并不能返回给前端,response的结果为:
{
"error": "unauthorized",
"error_description": "Full authentication is required to access this resource"
}

web项目如何使用这个微服务?

web系统每次请求service接口都要带上token吗?是在header请求头里面加入token吗? 或许是新手的原因,虽然使用postmain可以获取到token,但不知道web项目怎么去使用

环境变量怎么配置呢?在哪里配置?什么时候配置?

环境变量怎么配置呢?在哪里配置?什么时候配置?以下能否举个例子?

环境变量主要是配置服务的访问用户名和密码:

//配置服务器用户名
CONFIG_SERVER_USERNAME
//配置服务器密码
CONFIG_SERVER_PASSWORD
//注册服务器用户名
REGISTRY_SERVER_USERNA

uc启动不了,不知道为啥找不到数据库配置

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

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.