Mapa mental
Spring security
Conteúdo do mapa
Spring security
Portable
Beyond specification (Java EE)
customizable
Protect from knowledge attacks
Authentication
- @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/spitters/me").authenticated() .antMatchers(HttpMethod.POST, "/spittles").authenticated() .anyRequest().permitAll(); }
- .antMatchers("/spitters/**").authenticated()
- .antMatchers("/spitters/**", "/spittles/mine").authenticated();
- .regexMatchers("/spitters/.*").authenticated()
- .antMatchers("/spitters/**", "/spittles/mine").authenticated();
- .antMatchers("/spitters/**").authenticated()
- is the process of establishing a principal is who they claim to be
- First
- @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/spitters/me").authenticated() .antMatchers(HttpMethod.POST, "/spittles").authenticated() .anyRequest().permitAll(); }
Authorization
- Method Nivel
- Object instance nivel
- SPEL as a authorization mechanism
- Process of deciding whether a principal is allowed to perform an action
- Second
Principal
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String currentPrincipalName = authentication.getName();
- Its just a object
- Most of the time this can be cast into a UserDetails
- UserDetails is core Interface in Spring security
- Adapter between your own user database and what Spring Security needs inside the SecurityContextHolder
- A user, device or some other system which can perform an action in your application
To store user details
- JAAS
- Database
- LDAP
- Properties File
Spring in a controller
- @Secured({ "ROLE_USER", "ROLE_ADMIN" })
- Spring security only
- @RolesAllowed("ROLE_MEMBER")
- JSR 250
- IN XML
- @PreAuthorize
- can work with SPEL
- @PreAuthorize("#contact.name == principal.name")
- Verify authorization before entre into method
- @PostAuthorize
- after method have been executed
- verifying authorization on returned values
- @PostAuthorize ("returnObject.type == authentication.name")
- Spring EL provides returnObject
- reflects the actual object returned from method.
- Spring EL provides returnObject
- @PostAuthorize ("returnObject.type == authentication.name")
- verifying authorization on returned values
- after method have been executed
- @Secured({ "ROLE_USER", "ROLE_ADMIN" })
DelegatingFilterProxy
- Instead of a multiple filter declaration, you can declare only it. It will delegate responsability to another spring bean
@EnableWebSecurity
- Must be configured in a bean that implements WebSecurityConfigurer or extends WebSecurityConfigurerAdapter
- Has method configure(httpSecurity)
- @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/spitters/me").authenticated() .antMatchers(HttpMethod.POST, "/spittles").authenticated() .anyRequest().permitAll(); }
- <http use-expressions="true"> <intercept-url pattern="/**" access="authenticated"/> <form-login /> <http-basic /> </http>
- @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/spitters/me").authenticated() .antMatchers(HttpMethod.POST, "/spittles").authenticated() .anyRequest().permitAll(); }
- Has method configure(httpSecurity)
- Must be configured in a bean that implements WebSecurityConfigurer or extends WebSecurityConfigurerAdapter
@EnableWebMvcSecurity
Is based entirely on standard servlet filters.
- Has no strong links to any particular web technology
@EnableGlobalMethodSecurity
- on any @Configuration instance
- jsr250Enabled = true (Attribute)
- <global-method-security secured-annotations="enabled">
Informações
- Descrição
- Mapa Mental sobre Spring security, criado por Felipe Malfatti em 11-04-2018.
- Criado por
- Felipe Malfatti
- Visualizações
- 0
- Avaliação