<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          UniAuth開源權(quán)限管理框架

          聯(lián)合創(chuàng)作 · 2023-09-30 09:03

          一. 關(guān)于UNIAUTH

          1.1.uniauth干什么的

          它是一個(gè)統(tǒng)一登錄+鑒權(quán)+權(quán)限管理的綜合系統(tǒng);它適用于各系統(tǒng)需要通過(guò)統(tǒng)一認(rèn)證/授權(quán),并能根據(jù)既定的角色和權(quán)限來(lái)規(guī)范業(yè)務(wù)操作的多子系統(tǒng)環(huán)境。

          1.2.uniauth技術(shù)選型

          基于jdk7,使用spring mvc4.2+mybatis3+spring security4+cas+cxf作為基礎(chǔ)框架,數(shù)據(jù)庫(kù)為mysql5.7,配置管理使用zookeeper3.4redis 作為可選項(xiàng)用于保存ticket和session信息,前端使用angularJS 1.x;

          二. 快速開始

          2.1.編譯打包

          在源碼目錄執(zhí)行命令

          gradle warUniAuthServer、 gradle warCas、 gradle warTechopsWebsite,

          分別可以在uniauth-server,cas,techops項(xiàng)目的build路徑下得到uniauth.war 、  cas.war、  techops.war;

          2.2.初始化數(shù)據(jù)庫(kù)

          在mysql中create database uniauth,然后按rt順序執(zhí)行uniauth-server/src/script/sql 中所有的腳本; 管理員賬號(hào): [email protected] ,密碼: $1234qweR

          2.3.配置tomcat7

          • 添加環(huán)境參數(shù) 修改tomcat bin目錄中catalina.sh文件,在正文首行后加入下面環(huán)境參數(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復(fù)制粘貼三份,分別叫做 tomcatuniauth、  tomcatcas、 tomcat_techops,分別修改server.xml中監(jiān)聽端口,假定分別是:8080,8081,8082, 注意:同時(shí)修改其他shutdown,ajp端口

          • uniauth添加jndi數(shù)據(jù)源 在tomcat_uniauth的context.xml


          2.4.配置zookeeper

          在zokeeper中create下面節(jié)點(diǎn)數(shù)據(jù)

          /com/dianrong/cfg/1.0.0/uniauth/cas_server.iscookiesecure false   // 線上環(huán)境一定是true
          /com/dianrong/cfg/1.0.0/uniauth/cas_server http://localhost:8081/cas // cas服務(wù)器的部署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, 該默認(rèn)路徑可通過(guò)在catalina.sh中 export DR_CFG_ZOOKEEPER_BASE_PATH變量來(lái)更改

          2.5.部署啟動(dòng)

          按下面順序啟動(dòng)

          • 1.啟動(dòng)tomcatuniauth 將uniauth.war部署到tomcatuniauth 的webapps目錄,啟動(dòng)tomcat

          • 2.啟動(dòng)tomcatcas 將cas.war部署到tomcatcas 的webapps目錄,啟動(dòng)tomcat

          • 3.啟動(dòng)tomcattechops 將techops.war部署到tomcattechops 的webapps目錄,啟動(dòng)tomcat

          訪問(wèn)管理控制臺(tái)techops

           

          三. 系統(tǒng)結(jié)構(gòu)

          3.1. 模塊組件依賴

          uniauth模塊依賴圖.png 如上圖,uniauth的核心模塊:uniauth-servercommon,share-rw,ss-client,cas,techops。

          • 三個(gè)獨(dú)立應(yīng)用:

          (1)uniauth-server是提供數(shù)據(jù)訪問(wèn)的REST服務(wù);用戶,資源,權(quán)限數(shù)據(jù)通過(guò)它進(jìn)行訪問(wèn); (2)techops是web界面的管理控制臺(tái);通過(guò)techops錄入資源,角色,做權(quán)限分配; (3)cas是單點(diǎn)登錄系統(tǒng);各個(gè)subsystem通過(guò)cas做sso認(rèn)證;

          • 三個(gè)關(guān)鍵模塊: (4)common定義了uniauth-server的接口,接口的數(shù)據(jù)模型以及cxf方式的訪問(wèn)實(shí)現(xiàn);由它定義了數(shù)據(jù)接口,因此各個(gè)模塊必須依賴它; (5)share-rw提供對(duì)uniauth-server功能的訪問(wèn)接口定義 ,cxf方式訪問(wèn)實(shí)現(xiàn),由于牽涉到對(duì)數(shù)據(jù)的修改,因此只有管理系統(tǒng)才能依賴這個(gè)模塊,如techops (6)ss-client是uniauth提供的sdk,各子系統(tǒng)依賴它后只需要少量的配置就可以完成sso,authentication 和 authorization的業(yè)務(wù) (7)subsystem代表各個(gè)子系統(tǒng),也是uniauth的客戶端,各個(gè)需要用到sso,authentication和authorization的系統(tǒng),比如techops

          3.2.系統(tǒng)架構(gòu)

          組件調(diào)用關(guān)系 上圖中分兩條線

          1. step 1-7, include sso and authentication

          Between step 7 and 8,the uniauth client send request to cas server for authentication user with st (get from step 6) then the client can get credentials(* include username *) from response data 。

          1. step 8 , include authorization After got credentials, uniauth client call uniauth-server to get user details and all permissions.

          四. 參數(shù)配置

          配置都是在zookeeper中添加節(jié)點(diǎn)數(shù)據(jù)

          4.1. 核心配置

          (1) cas本身的配置

          /com/dianrong/cfg/1.0.0/uniauth/cas_server.iscookiesecure true #是否采用https的形式寫cookie,生產(chǎn)為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可驗(yàn)證的次數(shù),現(xiàn)在默認(rèn)是2次。其實(shí)正常情況下只驗(yàn)證一次是最安全的。
          /com/dianrong/cfg/1.0.0/uniauth/tenancyIdentity.check.switch   true #配置true 或 false。 用于指定是否強(qiáng)制的驗(yàn)證訪問(wèn)uniauth-server請(qǐng)求是否帶有租戶的驗(yàn)證信息
          /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 ) 郵箱配置 郵箱主要是為了驗(yàn)證碼發(fā)送,密碼重置

          /com/dianrong/cfg/1.0.0/uniauth/internal.mail.smtp.host    郵箱服務(wù)器host,比如:smtp-dev.sl.com(默認(rèn)值)
          /com/dianrong/cfg/1.0.0/uniauth/internal.mail.smtp.port    郵箱服務(wù)器port,比如:25(默認(rèn)值)
          /com/dianrong/cfg/1.0.0/uniauth/internal.mail.smtp.femail   uniauth系統(tǒng)郵件的發(fā)送者,比如:TechOps-Notification(默認(rèn)值)

          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的數(shù)據(jù)庫(kù)index
            /com/dianrong/cfg/1.0.0/uniauth/cas.iscluster true   #true or false  cas是否采用redis存儲(chǔ)登陸的ticket
            /com/dianrong/cfg/1.0.0/uniauth/redis.password ''    #指定redis密碼
            /com/dianrong/cfg/1.0.0/uniauth/redis.master  mymaster  #指定master節(jié)點(diǎn)name
            /com/dianrong/cfg/1.0.0/uniauth/redis.sentinels  10.18.19.51:5000,10.18.19.101:5000    #指定 redis集群節(jié)點(diǎn)列表,例如:10.18.19.67:5000,10.18.19.51:5000,10.18.19.101:5000

          4.3. 集成系統(tǒng)配置

          下面的xxx就是定義好的domain,如techops,crm,pms,cms,etc

          /com/dianrong/cfg/1.0.0/uniauth/domains.xxx    http://localhost:8100/techops/  #xxx系統(tǒng)的地址。比如:http://localhost:8100/techops/
          /com/dianrong/cfg/1.0.0/uniauth/domainx.xxx.loginPage  http://localhost:8100/techops/login.jsp #如果xxx系統(tǒng)采用自定義登陸頁(yè)面,則此處配置其自定義登陸頁(yè)面地址。
          /com/dianrong/cfg/1.0.0/uniauth/domainx.xxx.auth_fail_url    http://localhost:8100/techops/login_fail.jsp  #如果xxx系統(tǒng)在進(jìn)行st認(rèn)證失敗的時(shí)候跳轉(zhuǎn)到失敗頁(yè)面(需要客戶端集成做一些配置)。
          /com/dianrong/cfg/1.0.0/uniauth/domains.xxx.showInHomePage true  #明確指定是否在uniauth登陸頁(yè)能跳轉(zhuǎn)到xxx系統(tǒng)的登陸頁(yè)(是否出現(xiàn)選項(xiàng)框中),例如:true
          瀏覽 22
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  人妻在线播放视频 | 国产精品中文字幕在线观看 | 午夜精品影院 | 日日干视频| 成人午夜精品无码区久久app |