官术网_书友最值得收藏!

Authorization

Once the user is validated in terms of who they claim to be, the next aspect, what the user has access to, needs to be ascertained. This process of making sure what the user is allowed to do within the application is called authorization.

In line with authentication architecture, as seen earlier, authorization also has a manager, AccessDecisionManager. Spring Security has three built-in implementations for this: AffirmativeBased, ConsensusBased, and UnanimousBasedAccessDecisionManager works by delegating to a chain of AccessDecisionVoter. Authorization-related Spring Security classes/interfaces are shown in the following diagram:

Figure 12: Spring Security Authorization  classes/interfaces

In Spring Security, authorization to a secured resource is granted by invoking voters and then tallying the votes received. The three built-in implementations tally the votes received in different manners:

  • AffirmativeBased: If at least one voter votes, the user is given access to the secured resource
  • ConsensusBased: If a clear consensus is reached between the voters and their votes, then the user is given access to the secured resource
  • UnanimousBased: If all the voters vote, then the user is given access to the secured resource

Spring Security provides two authorization approaches:

  • Web URL: Incoming URL (specific URL or regular expression)-based authorization
  • Method: Method signature based on which access is controlled

If your serving layer exposes only RESTful endpoints and the data in your application is properly categorized as resources (complying with REST principles), using a Web URL approach can be considered. If your application just exposes endpoints (REST-based, I would call) not really complying with REST principles, you can consider using method-based authorization.

主站蜘蛛池模板: 大兴区| 余庆县| 潮安县| 庐江县| 桑日县| 广灵县| 大田县| 建瓯市| 监利县| 鹤山市| 仪陇县| 绥德县| 西吉县| 会理县| 比如县| 贺兰县| 南宫市| 阿克苏市| 托克托县| 报价| 洞头县| 明溪县| 平顺县| 凤翔县| 玉林市| 巴林右旗| 类乌齐县| 京山县| 文山县| 五原县| 腾冲县| 罗源县| 永昌县| 宁德市| 海城市| 电白县| 水富县| 饶阳县| 石首市| 攀枝花市| 沙湾县|