Skip to content

Commit

Permalink
更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
fangp committed Jun 17, 2018
1 parent 5e4e4a9 commit 2645608
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 53 deletions.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# spring-cloud-base
微服务基础框架,基于 SpringCloud 及 SpringBoot 开发。 使用 Oauth2 统一授权、认证, Oauth示例客户端使用 Vue 开发,具有用户管理、 资源管理、 角色管理等模块,后端包括授权中心、 基础数据中心(资源服务器)等应用,可作为微服务快速开发脚手架。 可通过 docker 快速构建部署。

Demo website:http://112.74.60.248:8080/ username: test password: 123456
Demo website:http://112.74.60.248:8080/
username: test password: 123456
phone: 13100000000 verifyCode: 1000


## Model
图片待续

## 相关博文
* consul 注册中心
* auth-center 授权中心
* api-gateway 网关
* main-data 基础数据模块
* common
* db-spring-boot-starter
* auth-spring-boot-starter


## Quick Start
* [api-gateway](https://github.com/fp2952/spring-cloud-base/tree/master/api-gateway):api-gateway网关
* [auth-center](https://github.com/fp2952/spring-cloud-base/tree/master/auth-center):OAuth2授权中心
* [common](https://github.com/fp2952/spring-cloud-base/tree/master/common):通用脚手架
* [config-git](https://github.com/fp2952/spring-cloud-base/tree/master/config-git):git配置中心
* [db-mybatis-pagehelper](https://github.com/fp2952/spring-cloud-base/tree/master/db-mybatis-pagehelper):Mybatis通用Mapper、分页模块
* [docker-compose](https://github.com/fp2952/spring-cloud-base/tree/master/docker-compose):docker-compose编排
* [main-data](https://github.com/fp2952/spring-cloud-base/tree/master/main-data):基础数据模块
* [web-app](https://github.com/fp2952/spring-cloud-base/tree/master/web-app):前端vue项目

### 项目结构
```
├─spring-cloud-base
│ │
│ ├─api-gateway--------------网关负载中心
│ │
│ ├─auth-center-----------------服务授权中心
│ ├─auth-center-----------------OAuth2服务授权中心
│ │ ├─auth-center-api----------------授权中心公共模块
│ │ ├─auth-center-provider----------------授权中心服务端
│ │ ├─auth-spring-boot-autoconfigure----------------授权中心autoconfigure
Expand All @@ -50,6 +50,20 @@ Demo website:http://112.74.60.248:8080/ username: test password: 123456
```



## 相关博文
* consul 注册中心
* [Spring Cloud OAuth2(一) 搭建授权服务](https://fp2952.github.io/jekyll/update/2016/05/13/Spring-cloud-oauth2.html)
* [Spring Cloud OAuth2(二) 扩展登陆方式:账户密码登陆、 手机验证码登陆、 二维码扫码登陆](https://fp2952.github.io/jekyll/update/2018/06/13/Spring-cloud-oauth2-login.html)
* api-gateway 网关
* main-data 基础数据模块
* common
* db-spring-boot-starter
* auth-spring-boot-starter


## Quick Start
### 依赖环境
JDK8、 Maven、 Mysql、 Redis、Consul(暂不支持0.7.3以上)、 Nodejs、 Docker(可选)、 docker-compose(可选)
### 运行步骤
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
public void configure(HttpSecurity http) throws Exception {
http // 配置登陆页/login并允许访问
http
.addFilterAt(getMyLoginAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
// 配置登陆页/login并允许访问
.formLogin().loginPage("/login").permitAll()
// 登出页
.and().logout().logoutUrl("/logout").logoutSuccessUrl("/backReferer")
Expand All @@ -47,7 +48,7 @@ public void configure(HttpSecurity http) throws Exception {
*/
@Override
public void configure(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(daoAuthenticationProvider());
auth.authenticationProvider(myAuthenticationProvider());
}

/*@Bean
Expand All @@ -67,7 +68,7 @@ public DaoAuthenticationProvider daoAuthenticationProvider(){
* @return
*/
@Bean
public MyAuthenticationProvider daoAuthenticationProvider(){
public MyAuthenticationProvider myAuthenticationProvider(){
MyAuthenticationProvider provider = new MyAuthenticationProvider();
// 设置userDetailsService
provider.setUserDetailsService(baseUserDetailService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class MyLoginAuthenticationFilter extends AbstractAuthenticationProcessin
private static final String SPRING_SECURITY_RESTFUL_TYPE_KEY = "type";
// 登陆终端:1:移动端登陆,包括微信公众号、小程序等;0:PC后台登陆
private static final String SPRING_SECURITY_RESTFUL_MOBILE_KEY = "mobile";

private static final String SPRING_SECURITY_RESTFUL_USERNAME_KEY = "username";
private static final String SPRING_SECURITY_RESTFUL_PASSWORD_KEY = "password";
private static final String SPRING_SECURITY_RESTFUL_PHONE_KEY = "phone";
Expand Down Expand Up @@ -69,7 +70,8 @@ else if(SPRING_SECURITY_RESTFUL_TYPE_QR.equals(type)){
else {
principal = obtainParameter(request, SPRING_SECURITY_RESTFUL_USERNAME_KEY);
credentials = obtainParameter(request, SPRING_SECURITY_RESTFUL_PASSWORD_KEY);

if(type == null)
type = SPRING_SECURITY_RESTFUL_TYPE_DEFAULT;
}
if (principal == null) {
principal = "";
Expand Down
24 changes: 9 additions & 15 deletions docker-compose/mysql/schema.sql

Large diffs are not rendered by default.

24 changes: 9 additions & 15 deletions main-data/schema.sql

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions web-app/src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export default {
Vue.prototype.$auth.config.appSecret = 'test'

// 设置后台请求地址前缀
Vue.axios.defaults.baseURL = process.env.SERVER_URL
Vue.prototype.$auth.config.baseUrl = process.env.BASE_URL
Vue.prototype.$auth.config.authUrl = process.env.AUTH_URL
// Vue.axios.defaults.baseURL = process.env.SERVER_URL
// Vue.prototype.$auth.config.baseUrl = process.env.BASE_URL
// Vue.prototype.$auth.config.authUrl = process.env.AUTH_URL

// build后配置
// Vue.axios.defaults.baseURL = window.serverconf[process.env.NODE_ENV]['baseURL']
// Vue.prototype.$auth.config.baseUrl = window.serverconf[process.env.NODE_ENV]['baseUrl']
// Vue.prototype.$auth.config.authUrl = window.serverconf[process.env.NODE_ENV]['authUrl']
Vue.axios.defaults.baseURL = window.serverconf[process.env.NODE_ENV]['baseURL']
Vue.prototype.$auth.config.baseUrl = window.serverconf[process.env.NODE_ENV]['baseUrl']
Vue.prototype.$auth.config.authUrl = window.serverconf[process.env.NODE_ENV]['authUrl']

// 配置认证头
Vue.axios.defaults.headers.common['Authorization'] = 'Bearer ' + Vue.prototype.$auth.token()
Expand Down

0 comments on commit 2645608

Please sign in to comment.