본문 바로가기
Dev/SpringBoot

[SpringSecurity] 실습#1

by 컴포넌트설계자 2026. 5. 27.

세팅할때 web, devtools, lombok, security

기본 ID: user
PW: 콘솔창 확인

기본 8080 포트 

This generated password is for development use only. Your security configuration must be updated before running your application in production.

2026-05-27T10:38:31.466+09:00  INFO 37320 --- [step01_security] [  restartedMain] r$InitializeUserDetailsManagerConfigurer : Global AuthenticationManager configured with UserDetailsService bean with name inMemoryUserDetailsManager
2026-05-27T10:38:31.982+09:00  INFO 37320 --- [step01_security] [  restartedMain] o.s.boot.tomcat.TomcatWebServer          : Tomcat started on port 8080 (http) with context path '/'
2026-05-27T10:38:31.999+09:00  INFO 37320 --- [step01_security] [  restartedMain] com.web.Step01SecurityApplication        : Started Step01SecurityApplication in 7.816 seconds (process running for 9.913)
2026-05-27T10:38:49.591+09:00  INFO 37320 --- [step01_security] [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2026-05-27T10:38:49.592+09:00  INFO 37320 --- [step01_security] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2026-05-27T10:38:49.595+09:00  INFO 37320 --- [step01_security] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms

로그아웃

 

CSRF공격을 방어하기 위해 토큰으로표기된다.

CSRF(Cross-Site Request Forgery) 토큰은 웹 애플리케이션에서 CSRF 공격을 방지하기 위해 사 용되는 보안 메커니즘이다. CSRF 공격은 사용자가 의도하지 않은 요청을 공격자가 유도하여 특정 웹 애플리케이션에서 악의적인 작업을 수행하게 하는 공격 방식이다. 예를 들어, 로그인된 사용자 가 공격자의 악성 링크를 클릭하면, 그 사용자(로그인된 사용자)의 권한으로 웹 애플리케이션에서 원하지 않는 작업(예: 계좌 이체, 비밀번호 변경 등)이 수행될 수 있다. CSRF 토큰의 원리 CSRF 토큰은 사용자가 웹 애플리케이션에서 보낼 요청에 대한 인증 정보를 포함한 고유한 문자 열이다. 이 토큰은 서버가 생성하고 클라이언트에게 전달되며, 클라이언트는 요청을 보낼 때마다 이 토큰을 포함해야 한다.
서버는 요청에 포함된 CSRF 토큰을 확인하여, 요청이 실제로 사용자가 보낸 유효한 요청인지 확인한다. CSRF 토큰은 사용자가 요청을 보낼 때마다 서버와 클라이언트 간의 신뢰할 수 있는 상호작용을 보장하는 중요한 보안 수단으로 이를 통해 악의적인 사이트에서 사용자를 속여 웹 애플리케이션 에서 권한 있는 작업을 수행하는 것을 방지할 수 있다.

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webmvc-test</artifactId>
            <scope>test</scope>
        </dependency>

springsecurity 사용하지 않을 때는 주석 처리 해준다.

Spring.security.user properties에서 설정

 

 

'Dev > SpringBoot' 카테고리의 다른 글

[SpringSecurity] 실습#2  (0) 2026.05.27
JSP/Servlet의 3가지 Scope  (0) 2026.05.26