shiro、cas、pac4j 實現單點登陸

前言

上一篇文章介紹了 cas 環境搭建過程 
本文介紹下cas和shiro集成代碼實現及數據流轉過程簡介

先看下實現的效果

訪問 http://localhost:8086/demo1
轉發到認證中心

輸入登陸賬號
回到demo1頁面

再次訪問 http://localhost:8086/demo1 直接會跳轉到 demo1頁面

點擊退出

項目啓動[按照運行順序]

實例化 LifecycleBeanPostProcessor bean生命週期管理類

添加註解支持 並強制使用cglib動態代理

使用 pac4j 的 subjectFactory

初始化cookie

初始化session

初始化 sessionManager 

初始化CasRealm認證與授權 

初始化 securityManager 並設置 sessionManager subjectFacotry和CasRealm

設置cas Server配置

設置cas 客戶端配置

設置session shiro存儲

設置pac4j配置 並設置 cas 客戶端和sessionshiro存儲

shiro 相關配置

加載shiro過濾器的權限規則配置

初始化 AuthorizationAttributeSourceAdvisor  並設置 securityManager

將過濾器註冊

訪問過程數據流轉[按照運行順序]

訪問 http://localhost:8086/demo1

獲取重定向處理的action
然後跳轉到了認證中心的頁面

輸入登陸賬號
登陸成功會回調到demo1項目

解析認證中心返回的信息
然後返回到demo1的首頁

點擊退出
查看demo1的日誌

o.p.cas.logout.DefaultCasLogoutHandler   : No trackable session found for back channel logout. Either the session store does not support to track session or it has expired from the store and the store settings must be updated (expired data)

調用了 casLogout的Handler處理類

代碼資源

https://gitee.com/pingfanrenbiji/cas-shiro-springboot-demo.git

本文使用 mdnice 排版

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章