How to secure association resources?

后端 未结 2 688
悲哀的现实
悲哀的现实 2021-01-18 17:33

The problem can be defined by the following example:

I have a class MainClass which is related with another class called AssociatedClass by

2条回答
  •  情书的邮戳
    2021-01-18 18:06

    One option is to secure Spring Data REST endpoints at the URL level. For example:

            @Override
            public void configure(HttpSecurity http) throws Exception {
                http.authorizeRequests()
               .antMatchers("/entity/{[0-9]+}/{[A-Za-z][A-Za-z0-9]+}").hasRole("ADMIN").
               and().csrf().disable();
                }
            }
    

    Public access:

    • /entities
    • /entities/entityId

    Admin access:

    • /entities/entityId/associated entity

提交回复
热议问题