250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- AJAX
- MSSQL
- oracle
- Python
- 설정
- JavaScript
- 오픈소스
- myBatis
- Docker
- ubuntu
- Thymeleaf
- STS
- SpringBoot
- Source
- Core Java
- MySQL
- Spring Boot
- Tomcat
- Eclipse
- jpa
- git
- IntelliJ
- JDBC
- PostgreSQL
- Open Source
- 문서
- error
- spring
- Exception
- maven
Archives
- Today
- Total
헤르메스 LIFE
[Spring Boot] Spring Security #01 본문
728x90
개발환경
1. STS 버전 : 4.13.1
2. JDK 버전 : OpenJDK 11.0.14_9_x64
3. Tomcat 버전 : 9.0.56
4. Maven 버전 : 3.8.4
5. Spring 버전 : Spring Boot 2.6.3
6. Database : Docker 에 DB 설치
- primary - PostgreSQL 13.3
7. Spring Security : 5.6.1
8. lombok
개발환경
https://hermeslog.tistory.com/577?category=1078420
https://hermeslog.tistory.com/582?category=1078420
Spring Security 추가
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
pom.xml 전체
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.study</groupId>
<artifactId>springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>springboot</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Multi Upload 테스트 시 사용했던 내용임. https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</dependency>
<!-- 당분간 사용하지 않을 예정임. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mustache</artifactId>
</dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
http://localhost:9090/ 로 접속하면 아래와 같은 Login 화면이 보여지면 정상.
id : user
password 는 Tomcat이 시작하면 아래와 같이 새로운 Password 가 만들어집니다.
복사해서 넣으시면 됩니다.
참고.
application.yml 에 아래의 설정을 추가하면 Password를 1111으로 셋팅할 수 있다고 합니다.
spring:
security:
user:
name: user
password: 1111 # Spring Security Default password 변경
로그인 된 모습
그 다음부터는 http://localhost:9090/ 해서 로그인 화면이 보이지 않습니다.
http://localhost:9090/logout 을 하면 끊깁니다.
http://localhost:9090/login
http://localhost:9090/logout
은 Spring Security의 기본 기능이라고 합니다.
728x90
'Spring Boot Framework' 카테고리의 다른 글
[Spring Boot] Spring Security 에서 antMatchers 를 Array 로 처리 (0) | 2022.03.09 |
---|---|
[Spring Boot] Spring Security #02 (0) | 2022.03.02 |
[Spring Boot] 정적 페이지 로딩 (0) | 2022.02.27 |
[Spring Boot] Multi FileUpload Test (0) | 2022.02.27 |
[Spring Boot] JPA 동시 입력 테스트 (0) | 2022.02.27 |