SpringBoot 401 UnAuthorized even with out security

We Are Going To Discuss About SpringBoot 401 UnAuthorized even with out security. So lets Start this Java Article.

SpringBoot 401 UnAuthorized even with out security

  1. SpringBoot 401 UnAuthorized even with out security

    Try to add below lines in your application.properties file
    security.basic.enable: false security.ignored=/**
    According to spring doc, use security.ignored=

  2. SpringBoot 401 UnAuthorized even with out security

    Try to add below lines in your application.properties file
    security.basic.enable: false security.ignored=/**
    According to spring doc, use security.ignored=

Solution 1

In the current version of Spring Boot (v2.1.0.RELEASE), the easiest way to get rid of the security issues is to add “WebSecurityConfig.java” to your project as follows:

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
    }

}

Note of course that this removes protection against cross-site request forgery, so this is really only appropriate for simple read-only endpoints.

Original Author trevorsky Of This Content

Solution 2

Try to add below lines in your application.properties file

security.basic.enable: false
security.ignored=/**

According to spring doc, use security.ignored=

Comma-separated list of paths to exclude from the default secured
paths

Original Author Afridi Of This Content

Solution 3

Just remove the the spring security dependency from pom.xml file.
Worked for me :)..

Original Author Harshit Sharma Of This Content

Solution 4

if we use CXF security & Spring boot security it gives this issues.
Comment out dependency i.e disable the spring boot security then it allows.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>       
</dependency>

To enable this we have to write custom security or add below config

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().permitAll();
    }
}

Original Author Palla Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment