- 授权协议: Apache
- 开发语言: Java HTML/CSS
- 操作系统: Linux
- 软件首页: https://git.oschina.net/dianrong/UniAuth
- 软件文档: https://git.oschina.net/dianrong/UniAuth
软件介绍
一. 关于UNIAUTH
1.1.uniauth干什么的
它是一个统一登录+鉴权+权限管理的综合系统;它适用于各系统需要通过统一认证/授权,并能根据既定的角色和权限来规范业务操作的多子系统环境。
1.2.uniauth技术选型
基于
jdk7,使用spring mvc4.2+mybatis3+spring security4+cas+cxf作为基础框架,数据库为mysql5.7,配置管理使用zookeeper3.4,redis作为可选项用于保存ticket和session信息,前端使用angularJS 1.x;
二. 快速开始
2.1.编译打包
在源码目录执行命令
gradle warUniAuthServer、 gradle warCas、 gradle warTechopsWebsite,
分别可以在uniauth-server,cas,techops项目的build路径下得到uniauth.war 、 cas.war、 techops.war;
2.2.初始化数据库
在mysql中create database uniauth,然后按rt顺序执行uniauth-server/src/script/sql 中所有的脚本; 管理员账号: shuanggui.fan@dianrong.com ,密码: $1234qweR
2.3.配置tomcat7
添加环境参数 修改tomcat bin目录中
catalina.sh文件,在正文首行后加入下面环境参数:
JAVA_OPTS="$JAVA_OPTS -Dcatalina.logs=/var/lib/tomcat/logs" # log output DR_CFG_ZOOKEEPER_ENV_URL="10.8.12.85:2181,10.8.12.85:2182,10.8.12.85:2183" # zookeeper cluster address export DR_CFG_ZOOKEEPER_ENV_URL
修改端口 将上面tomcat复制粘贴三份,分别叫做 tomcatuniauth、 tomcatcas、 tomcat_techops,分别修改
server.xml中监听端口,假定分别是:8080,8081,8082, 注意:同时修改其他shutdown,ajp端口uniauth添加jndi数据源 在tomcat_uniauth的
context.xml中
2.4.配置zookeeper
在zokeeper中create下面节点数据
/com/dianrong/cfg/1.0.0/uniauth/cas_server.iscookiesecure false // 线上环境一定是true /com/dianrong/cfg/1.0.0/uniauth/cas_server http://localhost:8081/cas // cas服务器的部署base地址 /com/dianrong/cfg/1.0.0/uniauth/domains.techops http://localhost:8082/techops // techops的部署base地址 /com/dianrong/cfg/1.0.0/uniauth/uniauth_ws_endpoint http://localhost:8080/uniauth/ws/rs // uniauth的webservice endpoint地址, base+/ws/rs
zookeeper的配置根路径为/com/dianrong/cfg/1.0.0, 该默认路径可通过在catalina.sh中 export DR_CFG_ZOOKEEPER_BASE_PATH变量来更改
2.5.部署启动
按下面顺序启动
1.启动tomcatuniauth 将
uniauth.war部署到tomcatuniauth 的webapps目录,启动tomcat2.启动tomcatcas 将
cas.war部署到tomcatcas 的webapps目录,启动tomcat3.启动tomcattechops 将
techops.war部署到tomcattechops 的webapps目录,启动tomcat
三. 系统结构
3.1. 模块组件依赖
如上图,uniauth的核心模块:
uniauth-server,common,share-rw,ss-client,cas,techops。
三个独立应用:
(1)
uniauth-server是提供数据访问的REST服务;用户,资源,权限数据通过它进行访问; (2)techops是web界面的管理控制台;通过techops录入资源,角色,做权限分配; (3)cas是单点登录系统;各个subsystem通过cas做sso认证;
三个关键模块: (4)
common定义了读uniauth-server的接口,接口的数据模型以及cxf方式的访问实现;由它定义了数据接口,因此各个模块必须依赖它; (5)share-rw提供对uniauth-server中写功能的访问接口定义 ,cxf方式访问实现,由于牵涉到对数据的修改,因此只有管理系统才能依赖这个模块,如techops(6)ss-client是uniauth提供的sdk,各子系统依赖它后只需要少量的配置就可以完成sso,authentication 和 authorization的业务 (7)subsystem代表各个子系统,也是uniauth的客户端,各个需要用到sso,authentication和authorization的系统,比如techops。
3.2.系统架构
上图中分两条线
step 1-7, include sso and authentication
Between step 7 and 8,the
uniauth clientsend request to cas server for authentication user withst(get from step 6) then the client can getcredentials(* includeusername*) from response data 。
step 8 , include authorization After got
credentials,uniauth clientcalluniauth-serverto get user details and all permissions.
四. 参数配置
配置都是在zookeeper中添加节点数据
4.1. 核心配置
(1) cas本身的配置
/com/dianrong/cfg/1.0.0/uniauth/cas_server.iscookiesecure true #是否采用https的形式写cookie,生产为true /com/dianrong/cfg/1.0.0/uniauth/cas_server http://localhost:8081/cas #cas的地址 。比如:http://localhost:8080/cas /com/dianrong/cfg/1.0.0/uniauth/cas.st_use_times 2 #配置cas的service ticket可验证的次数,现在默认是2次。其实正常情况下只验证一次是最安全的。 /com/dianrong/cfg/1.0.0/uniauth/tenancyIdentity.check.switch true #配置true 或 false。 用于指定是否强制的验证访问uniauth-server请求是否带有租户的验证信息 /com/dianrong/cfg/1.0.0/uniauth/uniauth_ws_endpoint http://localhost:8090/uniauth/ws/rs #配置的uniauth-server的地址。比如:http://localhost:8090/uniauth/ws/rs
( 2 ) 邮箱配置 邮箱主要是为了验证码发送,密码重置
/com/dianrong/cfg/1.0.0/uniauth/internal.mail.smtp.host 邮箱服务器host,比如:smtp-dev.sl.com(默认值) /com/dianrong/cfg/1.0.0/uniauth/internal.mail.smtp.port 邮箱服务器port,比如:25(默认值) /com/dianrong/cfg/1.0.0/uniauth/internal.mail.smtp.femail uniauth系统邮件的发送者,比如:TechOps-Notification(默认值)
4.2. redis配置
a 普通模式 /com/dianrong/cfg/1.0.0/uniauth/redis.host localhost #cas采用的redis的host /com/dianrong/cfg/1.0.0/uniauth/redis.port 6379 #redis的port b 哨兵模式 /com/dianrong/cfg/1.0.0/uniauth/redis.database 0 #redis的数据库index /com/dianrong/cfg/1.0.0/uniauth/cas.iscluster true #true or false cas是否采用redis存储登陆的ticket /com/dianrong/cfg/1.0.0/uniauth/redis.password '' #指定redis密码 /com/dianrong/cfg/1.0.0/uniauth/redis.master mymaster #指定master节点name /com/dianrong/cfg/1.0.0/uniauth/redis.sentinels 10.18.19.51:5000,10.18.19.101:5000 #指定 redis集群节点列表,例如:10.18.19.67:5000,10.18.19.51:5000,10.18.19.101:5000
4.3. 集成系统配置
下面的xxx就是定义好的domain,如techops,crm,pms,cms,etc
/com/dianrong/cfg/1.0.0/uniauth/domains.xxx http://localhost:8100/techops/ #xxx系统的地址。比如:http://localhost:8100/techops/ /com/dianrong/cfg/1.0.0/uniauth/domainx.xxx.loginPage http://localhost:8100/techops/login.jsp #如果xxx系统采用自定义登陆页面,则此处配置其自定义登陆页面地址。 /com/dianrong/cfg/1.0.0/uniauth/domainx.xxx.auth_fail_url http://localhost:8100/techops/login_fail.jsp #如果xxx系统在进行st认证失败的时候跳转到失败页面(需要客户端集成做一些配置)。 /com/dianrong/cfg/1.0.0/uniauth/domains.xxx.showInHomePage true #明确指定是否在uniauth登陆页能跳转到xxx系统的登陆页(是否出现选项框中),例如:true
Masterminds of Programming
Federico Biancuzzi、Chromatic / O'Reilly Media / 2009-03-27 / USD 39.99
Description Masterminds of Programming features exclusive interviews with the creators of several historic and highly influential programming languages. Think along with Adin D. Falkoff (APL), Jame......一起来看看 《Masterminds of Programming》 这本书的介绍吧!
