Return to site

๐Ÿƒ๐ŸŽ“ SPRING CERTIFICATION QUESTION: Is security a cross-cutting concern? How is it implemented internally?

ยท spring,vcp

Answer:

Security concern pertains to lots of layers of an application and therefore is considered to be a cross-cutting.

 

Depending on what is secured, Spring Security framework internals differ:

  1. Method invocation is declarative and is implemented using AOP proxies (proxy object wraps secured one and applies implemented advices at particular join-points).
  2. Web-layer security is implemented using a hierarchy of ๐…๐ข๐ฅ๐ญ๐ž๐ซ instances.

 

Web-layer filter security hierarchy is the following:

A single instance of ๐ƒ๐ž๐ฅ๐ž๐ ๐š๐ญ๐ข๐ง๐ ๐…๐ข๐ฅ๐ญ๐ž๐ซ๐๐ซ๐จ๐ฑ๐ฒ is installed into the servlet container's filter chain.

This filter is ๐ง๐จ๐ญ a Spring bean, its lifecycle is managed by the servlet container.

Usually, this filter is created by the Spring Security framework itself.

๐ƒ๐ž๐ฅ๐ž๐ ๐š๐ญ๐ข๐ง๐ ๐…๐ข๐ฅ๐ญ๐ž๐ซ๐๐ซ๐จ๐ฑ๐ฒ delegates filtering functionality to a single instance of ๐…๐ข๐ฅ๐ญ๐ž๐ซ๐‚๐ก๐š๐ข๐ง๐๐ซ๐จ๐ฑ๐ฒ which ๐ข๐ฌ a Spring bean,

thus lifecycle of it is managed by ๐€๐ฉ๐ฉ๐ฅ๐ข๐œ๐š๐ญ๐ข๐จ๐ง๐‚๐จ๐ง๐ญ๐ž๐ฑ๐ญ.

๐…๐ข๐ฅ๐ญ๐ž๐ซ๐‚๐ก๐š๐ข๐ง๐๐ซ๐จ๐ฑ๐ฒ holds a list of ๐’๐ž๐œ๐ฎ๐ซ๐ข๐ญ๐ฒ๐…๐ข๐ฅ๐ญ๐ž๐ซ๐‚๐ก๐š๐ข๐ง which contain all security logic.

Only ๐จ๐ง๐ž security filter chain can process a single web request.

 

#spring #certificationquestion #vcp