Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'antMatchers' mean?

Tags:

spring-boot

I am learning spring-boot and for my brain, in order to accept some things, it needs to find a meaningful explanation of those things. Could anybody tell me what "ant" in "antMatchers" means? What has an insect like an "ant" got to do with the mapping between a resource and the path of the REST-call?

I know that this is not a language research forum, but I think that developers have also the right to understand or refuse logical/illogical things.

Thank you ;)

like image 800
NicDD4711 Avatar asked Apr 17 '17 11:04

NicDD4711


People also ask

What is difference between antMatchers and Mvcmatchers?

antMatcher(String antPattern) - Allows configuring the HttpSecurity to only be invoked when matching the provided ant pattern. mvcMatcher(String mvcPattern) - Allows configuring the HttpSecurity to only be invoked when matching the provided Spring MVC pattern.

What is difference between hasRole and hasAuthority?

The main difference is that roles have special semantics. Starting with Spring Security 4, the 'ROLE_' prefix is automatically added (if it's not already there) by any role related method. So hasAuthority('ROLE_ADMIN') is similar to hasRole('ADMIN') because the 'ROLE_' prefix gets added automatically.

How does hasRole works in Spring Security?

By default, Spring Security uses a thread-local copy of this class. This means each request in our application has its security context that contains details of the user making the request. To use it, we simply call the static methods in SecurityContextHolder: Authentication auth = SecurityContextHolder.


2 Answers

It comes from Apache Ant Project, which is a java build system that utilises an xml scripting language. Here is the website Apache Ant Home and in Spring Doc for AntPathMatcher it says "Part of this mapping code has been kindly borrowed from Apache Ant." So "antMatchers" means an implementation of Ant-style path patterns in mappings.

like image 100
javasenior Avatar answered Oct 02 '22 15:10

javasenior


The term comes from the archaic build system, Apache Ant. In Ant paths were matched against a simple pattern containing * symbols meaning any string, and ** meaning 'recursive' descending any number of directories/folders. So, an ant-matcher like this: /a/b/*/d/**/z could match: /a/b/w/d/x/y/z because the w bit is matched by * and the /x/y/ bit is matched by **.

like image 24
Software Engineer Avatar answered Oct 02 '22 15:10

Software Engineer