# tangram-framework **Repository Path**: insky2005/tangram-framework ## Basic Information - **Project Name**: tangram-framework - **Description**: 七巧板 - APP项目快速开发框架 - **Primary Language**: Java - **License**: MIT - **Default Branch**: 3.0.x - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-07-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Platform Framework ## 基本Maven操作 - 修改项目版本号 ```bash $ mvn versions:set -DnewVersion=2.0.0-SNAPSHOT ``` - 上传到maven仓库 ```bash $ mvn deploy ``` ## 项目说明 ### Core platform-core-common 通用的工具类 platform-core-cache 缓存实现(支持内存、EhCache、Redis) platform-core-framework 基础框架(annotation、缓存工具类、异常处理、过滤器、分页拦截器、监听、上传下载servlet、实体抽象类、DAO抽象类、控制器抽象类) ### Module platform-module-domain 通用实体(日志表,用户表、角色表、功能表等) platform-module-interface 通用实体的DAO操作类的接口定义 platform-module-log 日志模块,日志的收集、入库功能的实现 platform-module-authority-db 用户、角色、功能模块,实现了基于独立数据表的用户、角色、功能数据的获取 platform-module-authority-uniauth 用户、角色、功能模块,实现了基于认证视图的用户、角色、功能数据的获取(即相关数据的维护在认证中) platform-module-authority 用户、角色、功能模块,相关 API 接口 platform-module-security-oauth2 安全模块,OAuth2 的整合,基于 Spring Securiy OAuth2 的配置,可集成 CAS platform-module-security 安全模块,基于角色的访问控制实现 platform-module-resources 资源模块,暂无(不知道怎么用) ### Examples platform-examples-web-admin-authserver WebAuth,OAuth认证中心,同时提供用户、角色、功能相关数据的API接口,持久层采用 mybatis,基于数据表的权限控制 platform-examples-web-admin-dashboard WebAdmin,管理中心,采用前后端分离模式开发(但前后端代码在一个web项目下),与 WebAuth 整合,持久层采用 mybatis,基于数据表的权限控制 ~~废弃 platform-examples-web-api WebAPI,又可称为后端接口,主要是以 restful 的方式提供接口,由前端调用,访问控制权限由 OAuth2 控制~~ ~~废弃 platform-examples-web-client WebClient,为前端UI,主要是 html + js(ajax),调用后 WebAPI 获取数据或提交数据~~ platform-examples-web-app WebAPP,采用前后端分离模式开发(但前后端代码在一个web项目下),持久层采用 mybatis,基于认证视图的权限控制 platform-examples-web-mvc WebMVC,采用传统MVC实现,freemarker 视图解析,持久层采用 hibernate,基于数据表的权限控制 ,整合CAS ## 流程说明 以 platform-examples-web-admin-authserver、platform-examples-web-admin-dashboard 为例 项目 platform-examples-web-admin-authserver(简称:web-admin-authserver) 为 OAuth认证中心,主要提供登录,资源授权,颁发token,提供用户、角色、功能相关数据的API接口 项目 platform-examples-web-admin-dashboard(简称:web-admin-dashboard) 为 管理中心,主要实现各个功能的UI展现,同时,也可以实现业务功能的API接口实现 ### 本地登录模式 #### 登录流程 1、用户访问 web-admin-dashboard ,访问需要登录的功能时,系统会跳转到 web-admin-authserver 进行登录 2、用户在 web-admin-authserver 登录后,生成 code,并跳转返回到 web-admin-dashboard, 3、web-admin-dashboard 会调用 web-admin-authserver 的接口验证 code,并获取到 access_token,保存到浏览器 Cookie 请求跳转: http://localhost:10008/web-admin-dashboard/ http://localhost:10008/web-admin-dashboard/html/admin/index.html?t=1497512356108 http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login http://localhost:10008/web-admin-authserver/oauth/authorize?client_id=client-api-resource&redirect_uri=http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login&response_type=code&scope=read%20write%20trust&state=o3UKFQ http://localhost:10008/web-admin-authserver/login.jsp # 用户输入用户名、密码,提交登录 http://localhost:10008/web-admin-authserver/oauth/login http://localhost:10008/web-admin-authserver/oauth/authorize?client_id=client-api-resource&redirect_uri=http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login&response_type=code&scope=read%20write%20trust&state=o3UKFQ http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login?code=84er1o&state=o3UKFQ # OAuth2ClientAuthenticationProcessingFilter 根据 code 可以获取到 access_token http://localhost:10008/web-admin-dashboard/html/admin/index.html?t=1497512356108 #### 注销流程 1、用户登录 web-admin-dashboard 后,点击 web-admin-dashboard 的注销,系统先将本地 session 清理后,跳转到 web-admin-authserver 进行注销 2、web-admin-authserver 注销后,web-admin-authserver 会跳转回到 web-admin-dashboard 的系统首页 请求跳转: http://localhost:10008/web-admin-dashboard/html/logout http://localhost:10008/web-admin-authserver/oauth/logout?targetUrl=http%3A%2F%2Flocalhost%3A10008%2Fweb-admin-dashboard%2Findex.jsp http://localhost:10008/web-admin-authserver/oauth/logout?returnUrl=http%3A%2F%2Flocalhost%3A10008%2Fweb-admin-dashboard%2Findex.jsp # 注销成功后,跳转到 returnUrl http://localhost:10008/web-admin-dashboard/index.jsp http://localhost:10008/web-admin-dashboard/html/hall/index.html?t=1497515043155 ### 认证集成模式 #### 登录流程 1、用户访问 web-admin-dashboard ,访问需要登录的功能时,系统会跳转到 web-admin-authserver 进行登录 2、web-admin-authserver 会跳转到 casserver 进行登录 3、用户在 casserver 登录后,生成 ticket,并返回到 web-admin-authserver 4、web-admin-authserver 验证票据成功后,生成 code,并跳转返回到 web-admin-dashboard 5、web-admin-dashboard 会调用 web-admin-authserver 的接口验证 code,并获取到 access_token,保存到浏览器 Cookie 请求跳转: http://localhost:10008/web-admin-dashboard/ http://localhost:10008/web-admin-dashboard/html/admin/index.html?t=1497512356108 http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login http://localhost:10008/web-admin-authserver/oauth/authorize?client_id=client-api-resource&redirect_uri=http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login&response_type=code&scope=read%20write%20trust&state=o3UKFQ http://app.supwisdom.com:9080/cas/login?service=http%3A%2F%2Flocalhost%3A10008%2Fweb-admin-authserver%2Fj_spring_cas_security_check # 用户输入用户名、密码,提交登录 http://app.supwisdom.com:9080/cas/login?service=http%3A%2F%2Flocalhost%3A10008%2Fweb-admin-authserver%2Fj_spring_cas_security_check http://localhost:10008/web-admin-authserver/j_spring_cas_security_check?ticket=ST-119-WgMe16Jd6Qngqc3diW5r-cas http://localhost:10008/web-admin-authserver/oauth/authorize?client_id=client-api-resource&redirect_uri=http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login&response_type=code&scope=read%20write%20trust&state=o3UKFQ http://localhost:10008/web-admin-dashboard/html/oauth2client/oauth2login?code=84er1o&state=o3UKFQ # OAuth2ClientAuthenticationProcessingFilter 根据 code 可以获取到 access_token http://localhost:10008/web-admin-dashboard/html/admin/index.html?t=1497512356108 #### 注销流程 1、用户登录 web-admin-dashboard 后,点击 web-admin-dashboard 的注销,系统先将本地 session 清理后,跳转到 web-admin-authserver 进行注销 2、web-admin-authserver 注销后,会跳转到 casserver 进行注销 3、casserver 注销后,用户选择返回系统,则跳转返回到 web-admin-authserver 2、web-admin-authserver 会跳转回到 web-admin-dashboard 的系统首页 请求跳转: http://localhost:10008/web-admin-dashboard/html/logout http://localhost:10008/web-admin-authserver/oauth/logout?targetUrl=http%3A%2F%2Flocalhost%3A10008%2Fweb-admin-dashboard%2Findex.jsp http://localhost:10008/web-admin-authserver/cas/logout?targetUrl=http://localhost:10008/web-admin-authserver/cas/logout?returnUrl=http%3A%2F%2Flocalhost%3A10008%2Fweb-admin-dashboard%2Findex.jsp http://app.supwisdom.com:9080/cas/logout?service=http%3A%2F%2Flocalhost%3A10008%2Fweb-admin-authserver%2Fcas%2Flogout%3FreturnUrl%3Dhttp%3A%2F%2Flocalhost%3A10008%2Fweb-admin-dashboard%2Findex.jsp http://app.supwisdom.com:9080/cas/singlesignout/singlesignout.jsp?service=http://localhost:10008/web-admin-authserver/cas/logout?returnUrl=http://localhost:10008/web-admin-dashboard/index.jsp # 用户点击 返回系统 http://localhost:10008/web-admin-authserver/cas/logout?returnUrl=http://localhost:10008/web-admin-dashboard/index.jsp # 注销成功后,跳转到 returnUrl http://localhost:10008/web-admin-dashboard/index.jsp http://localhost:10008/web-admin-dashboard/html/hall/index.html?t=1497515043155