想要实现的效果是
比如如下两个接口
GET /order/{orderId}
POST /order/{orderId}/abc/{abcId}
想通过不同的角色或用户来分别限制他们能访问接口的某一个,即拥有权限的一个
现在的问题就是,通过什么样的方式能够将URL和上面的接口路径分别匹配上呢?
使用的是SpringMVC。
注:上面写的接口URL只是简单的,还有复杂的里面参数可以是正则表达式,或者两个参数通过特定字符串拼接的(如{param1}-{param2},所以匹配路径不能用正则来做,这块不太了解SpringMVC的底层是如何实现的,求大神解答。
Why do I feel that the content of your question and the title have different meanings. Do you want to ask about permission control or path identification matching?
You must use the implementation WebSecurityConfigurerAdapter
As far as I know, the basic login of Spring security is User and Role.
Each URL can be controlled by implementing configure(WebSecurity web) of WebSecurityConfigurerAdapter.
For example, the following example account is in memory. After logging in, each resource can be restricted by hasRole():
Reference: Official documentation
The poster can go and learn about the shiro framework. For details, you can see here. It is a very good tutorial and easy to get started. This framework can solve your problems. http://jinnianshilongnian.ite...
When used with spring mvc, it is like Like this
You can write a method yourself
Just use laravel
http base certification! ! ! !