java - Is there a point to use method level security in spring if we secured the REST API from the configuration -


i ask if there point secure methods call in rest controller pre , post annotations. have configured security through java configuration this:

@override protected void configure(httpsecurity http) throws exception { http     .and()         .formlogin()      (...)      .and()         .authorizerequests()         .antmatchers("/api/**").hasauthority("role_user"); } 

so every request under /api should authorized role_user. tried find information in internet thing find this: https://coderanch.com/t/549265/spring/method-security-spring-security

however can't think of use case hacker access somehow methods in service layer.

url security , method security in service layer aims @ different use cases.

if need control users role can call url given prefix (here api) url security need full stop.

if have complex application service methods can called different controllers , want make sure did not fail restrict access, method security can come ensuring valid users can business actions.

if have complex security model, example several officse 1 manager in each has read and/or write access own employees data, method security on service layer directly using business model objects way go.

btw, using method security in controller or worse on rest controller design smell: if can inside controller better use url security. if seems make sense, have imported business logic fat ugly controller. not speaking method security being implemented spring aop using default jdk proxies, when controllers not implement interfaces.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -