Spring Security Learning Summary (2) ongoing updates

Source: Internet
Author: User
Tags http strict transport security

From one of the simplest spring Security Java Configuration looks
@Configuration @enablewebsecuritypublic class Securityconfig extends Websecurityconfigureradapter {@Autowired public void Configureglobal (Authenticationmanagerbuilder auth) throws Exception {auth. inmemoryauthentication    (). Withuser ("user"). Password ("password"). Roles ("User"); }}

Configglobal The name is not important, it is important to annotate the @EnableWebSecurity or @enablewebmvcsecurity or

Configure Authenticationmanagerbuilder in a class @EnableGlobalMethodSecurity or @EnableGlobalAuthentication.

It seems that this code does not do a lot of configuration, actually doing a lot:

    • Require authentication for access to each URL

    • Generate a login form

    • Allow user, password password login as user

    • Allow users to log out

    • Prevent CSRF attacks

    • Integrated Security Header (HTTP Strict Transport Security, X_content-type-options, Cache-control, X-xss-protection, X-frame-options)

    • Integration with Servlet API methods (Getremoteuser (), Getuserprincipal (), etc.)


A talk about Httpsecurity

The securityconfig contains how to authenticate the user. But how does spring Security know that we need to authenticate all of our users? How does Spring Security know that we need to support form-based authentication?

The answer is that spring Security's Websecurityconfigureradapter provides a default configuration method: Configure (Httpsecurity http)

protected void Configure (Httpsecurity http) throws Exception {http. authorizerequests (). Anyrequest ( ). Authenticated (). and (). Formlogin (). and (). Httpbasic ();




Spring Security Learning Summary (2) ongoing updates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.