- Spring 5.0 By Example
- Claudio Eduardo de Oliveira
- 338字
- 2021-06-24 19:17:26
Spring Security
Security for Java applications was always a pain for developers, especially in Java Enterprise Edition. There was a lot of boilerplate code to look up objects in the application servers, and the security layer was often heavily customized for the application.
In that chaotic scenario, the Spring Team decided to create a Spring Security project to help developers handle the security layer on the Java application.
In the beginning, the project had extensive support for Java Enterprise Edition and integration with EJB 3 security annotations. Nowadays, the project supports many different ways to handle authorization and authentication for Java applications.
Spring Security provides a comprehensive model to add authorization and authentication for Java applications. The framework can be configured with a couple of annotations, which makes the task of adding a security layer extremely easy. The other important characteristics concern how the framework can be extended. There are some interfaces that enable developers to customize the default framework behaviors, and it makes the framework customized for different application requirements.
It is an umbrella project, and it is subdivided into these modules:
- spring-security-core
- spring-security-remoting
- spring-security-web
- spring-security-config
- spring-security-ldap
- spring-security-acl
- spring-security-cas
- spring-security-openid
- spring-security-test
These are the main modules, and there are many other projects to support a wide range of types of authentication. The module covers the following authentication and authorization types:
- LDAP
- HTTP Basic
- OAuth
- OAuth2
- OpenID
- CAAS
- JAAS
The module also offers a domain-specific language (DSL) to provide an easy configuration. Let's see a simple example:
http
.formLogin()
.loginPage("/login")
.failureUrl("/login?error")
.and()
.authorizeRequests()
.antMatchers("/signup","/about").permitAll()
.antMatchers("/admin/**").hasRole("ADMIN")
.anyRequest().authenticated();
As we can see, the DSL makes the configuration task extremely easy and very understandable.
Spring Security's main features are as follows:
- Session management
- Protection against attacks (CSRF, session fixation, and others)
- Servlet API integration
- Authentication and authorization
We will learn more about Spring Security in Chapter 8, Circuit Breakers and Security. We will also put it into practice.
- Building Mapping Applications with QGIS
- jQuery開發基礎教程
- SharePoint Development with the SharePoint Framework
- Expert Data Visualization
- Asynchronous Android Programming(Second Edition)
- Multithreading in C# 5.0 Cookbook
- Mastering ArcGIS Enterprise Administration
- HTML+CSS+JavaScript編程入門指南(全2冊)
- Java Web應用開發給力起飛
- Flink技術內幕:架構設計與實現原理
- Docker:容器與容器云(第2版)
- Java高級程序設計
- Android編程權威指南(第4版)
- Python Social Media Analytics
- Extending Docker