November 2017
Intermediate to advanced
542 pages
14h 24m
English
You may have noticed that granting access to everyone was not nearly as concise as we may have liked. Fortunately, Spring Security can leverage Spring Expression Language (SpEL) to determine whether a user has authorization. In the following code snippet, you can see the updates when using SpEL with Spring Security:
//src/main/java/com/packtpub/springsecurity/configuration/ SecurityConfig.java http.authorizeRequests() .antMatchers("/").access("hasAnyRole('ANONYMOUS', 'USER')") .antMatchers("/login/*").access("hasAnyRole('ANONYMOUS', 'USER')") .antMatchers("/logout/*").access("hasAnyRole('ANONYMOUS', 'USER')") .antMatchers("/admin/*").access("hasRole('ADMIN')") .antMatchers("/events/").access("hasRole('ADMIN')") ...Read now
Unlock full access