Return to site

🍃🎓 SPRING CERTIFICATION QUESTION: Is security a cross-cutting concern? How is it implemented internally?

January 7, 2023

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