in Technology by
How Is Spring Security Implemented In a Spring Boot Application?

1 Answer

0 votes
by
Minimal configuration is needed for implementation. All you need to do is add thespring-boot-starter-securitystarter in the pom.xml file. You will also need to create a Spring config class that will override the required method while extending the WebSecurityConfigurerAdapter to achieve security in the application. Here is some example code: 1 package com.gkatzioura.security.securityendpoints.config; 2 import org.springframework.context.annotation.Configuration; 3 import org.springframework.security.config.annotation.web.builders.HttpSecurity; 4 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 5 @Configuration 6 public class SecurityConfig extends WebSecurityConfigurerAdapter { 7 @Override 8 protected void configure(HttpSecurity http) throws Exception { 9 http.authorizeRequests() 10 .antMatchers("/welcome").permitAll() 11 .anyRequest().authenticated() 12 .and() 13 .formLogin() 14 .permitAll() 15 .and() 16 .logout() 17 .permitAll(); 18 } 19

Related questions

0 votes
    I am using spring boot command line runner app, it hangs at PostGIS dialect, the below stack trace contains ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    How to create a non-web application in Spring Boot?...
asked Jul 7, 2021 in Technology by JackTerrance
0 votes
    How does a spring boot application get started?...
asked Jul 7, 2021 in Technology by JackTerrance
0 votes
    Which of the following enables production-ready features to the spring boot application? 1. Endpoint 2. Actuators 3. Boot 4. None of the above...
asked Jul 25, 2021 in Technology by JackTerrance
0 votes
    The embedded server that starts up with the Spring boot application is ____________. A. Tomcat server B. Weblogic server C. None of the options D. Server has to be configured...
asked Nov 8, 2022 in Education by JackTerrance
0 votes
    Starting points of Spring Boot Application? 1. @Controller 2. @SpringBootApplication 3. @Service 4. None of the Above...
asked Jul 8, 2021 in Education by JackTerrance
0 votes
    Is Dependency needed to create a Spring Boot web application? 1. Spring-boot-starter-web 2. Spring-boot-starter-test 3. Spring-boot-html 4. None of the Above...
asked Jul 8, 2021 in Education by JackTerrance
0 votes
    How can we override the default properties of Spring boot projects?...
asked Jul 23, 2021 in Technology by JackTerrance
0 votes
    How to override or replace the Embedded tomcat server in Spring Boot?...
asked Jul 7, 2021 in Technology by JackTerrance
0 votes
    How Do You Override a Spring Boot Project’s Default Properties?...
asked Nov 15, 2020 in Technology by Editorial Staff
0 votes
    How does Spring Boot works?...
asked Jul 5, 2021 in Education by JackTerrance
0 votes
    Spring Boot is example of __________. A. Service Deployment B. Service registry C. Chassis Framework D. API Gateway...
asked Jan 11, 2023 in Technology by JackTerrance
0 votes
    What is the role of actuator in spring boot?...
asked Jul 23, 2021 in Technology by JackTerrance
0 votes
    Explain about the spring cloud and spring boot?...
asked Jul 23, 2021 in Technology by JackTerrance
0 votes
    What is the default port of tomcat in spring boot?...
asked Jul 7, 2021 in Technology by JackTerrance
...