shiro 實現認證授權

2021-07-14 16:36:02 字數 694 閱讀 8384

一.認證和授權的概念

認證(authentication):show it,you are you;

授權(authoriziation):through it,you can do sth;

二.shiro中的認證與授權

authenticatingrealm:shiro中的用於進行認證的領域,實現dogetauthentcationinfo方法實現使用者登入時的認證邏輯;

authorizingrealm:shiro中用於授權的領域,實現dogetauthrozitioninfo方法實現使用者的授權邏輯,authorizingrealm繼承了authenticatingrealm,所以在實際使用中主要用到的就是這個authenticatingrealm類;

authenticatingrealm、authorizingrealm這兩個類都是shiro中提供了一些執行緒的realm介面

在與spring

整合專案中,shiro的securitymanager會自動呼叫這兩個方法,從而實現認證和授權,可以結合shiro的cachemanager將認證和授權資訊儲存在快取中,這樣可以提高系統的處理效率。    

三.subject

subject.login會將登入驗證處理委託給securitymanager,securitymanager會找到注入進來的認證realm介面的實現類,然後進行認證邏輯處理,並返回乙個認證結果

shiro認證授權

1.shiro配置類 1.1需要配置什麼?建立乙個shirofilte ctorybean物件,檢測認證 向bean中傳入securitymanager物件 沒有認證的時候應該訪問哪個url位址 setloginurl 哪些資源是可以被匿名訪問的 setfilterchaindefinitionma...

Shiro 認證和授權流程實現

新增shiro框架依賴 org.apache.shiro shiro spring 1.3.2 configuration bean securitymanager public defaultwebsecuritymanager newdefaultwebsecuritymanager bean ...

shiro認證授權過程

nclick formsubmit login.action self public string login throws exception subject.login token 當這一 執行時,就會自動跳入到authrealm中認證方法 protected authenticationinf...