-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from YangSiJun528/renew/to-2.0.0
2.0.0 버전 개발
- Loading branch information
Showing
33 changed files
with
620 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
plugins { | ||
java | ||
`java-library` | ||
`maven-publish` | ||
id("org.springframework.boot") version "2.7.14" | ||
id("io.spring.dependency-management") version "1.0.15.RELEASE" | ||
} | ||
|
||
tasks { | ||
named<Jar>("bootJar") { | ||
enabled = false | ||
} | ||
|
||
named<Jar>("jar") { | ||
enabled = true | ||
archiveClassifier.set("") | ||
duplicatesStrategy = DuplicatesStrategy.WARN | ||
} | ||
} | ||
|
||
|
||
group = "dev.yangsijun" | ||
version = "2.0.0-alpha-3" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url = uri("https://jitpack.io") } | ||
} | ||
|
||
dependencies { | ||
api("com.github.GSM-MSG:GAuth-SDK-Java:v2.0.1") | ||
implementation("org.springframework.boot:spring-boot-starter-security") | ||
implementation("org.springframework.boot:spring-boot-starter-web") | ||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation("org.springframework.security:spring-security-test") | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
groupId = group.toString() | ||
artifactId = rootProject.name | ||
version = version | ||
|
||
from(components["java"]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Guide - ver. 2.0.0 | ||
|
||
* [Guide - ver. 2.0.0](#guide---ver-200) | ||
* [시작하기 전에...](#시작하기-전에) | ||
* [시작하기](#시작하기) | ||
* [1. 프로젝트 만들기](#1-프로젝트-만들기) | ||
* [2. 모듈 가져오기](#2-모듈-가져오기) | ||
* [3. 환경 설정하기](#3-환경-설정하기) | ||
* [Properties 정의하기](#properties-정의하기) | ||
* [예시](#예시) | ||
* [4. Security Configuration에 적용하기](#4-security-configuration에-적용하기) | ||
* [GAuthLoginConfigurer 옵션](#GAuthLoginConfigurer-옵션) | ||
* [예시 1](#예시-1) | ||
* [예시 2](#예시-2) | ||
|
||
<!-- TOC --> | ||
|
||
## 시작하기 전에... | ||
|
||
1. GAuth-spring-boot-starter 모듈은 2가지 의존성을 필요로 합니다. | ||
- `spring-boot-starter-security` | ||
- `spring-boot-starter-web` | ||
|
||
2. GAuth 인증을 사용하기 위해 서비스를 등록하야 합니다. | ||
[GAuth.co.kr](GAuth.co.kr)에 접속하여 서비스를 등록할 수 있습니다. | ||
|
||
## 시작하기 | ||
|
||
### 1. 프로젝트 만들기 | ||
|
||
`spring-boot-starter-security`, `spring-boot-starter-web` 의존성을 가지는 Spring Boot 프로젝트를 준비합니다. | ||
|
||
### 2. 모듈 가져오기 | ||
|
||
모듈을 가져옵니다. 자세한 내용은 [README.md의 모듈 불러오기](../../../README.md#모듈-불러오기)를 확인하세요. | ||
|
||
### 3. 환경 설정하기 | ||
|
||
#### Properties 정의하기 | ||
|
||
`application.properties` 혹은 `application.yml`에 GAuth 관련 설정을 정의해야 합니다. | ||
|
||
- gauth.client-id | ||
- gauth.client-secret | ||
- gauth.redirect-uri | ||
|
||
##### 예시 | ||
|
||
application.properties | ||
|
||
```properties | ||
gauth.security.client-id:1234567890qwertyuiop | ||
gauth.security.client-secret:1234567890qwertyuiop1234567890qwertyuiop | ||
gauth.security.redirect-uri:http://localhost:8080/login/gauth/code | ||
``` | ||
|
||
### 4. Security Configuration에 적용하기 | ||
|
||
Spring Security의 Configuration에 관한 내용은 [공식문서](https://docs.spring.io/spring-security/reference/index.html)를 참고하세요. | ||
|
||
Spring Security의 SecurityFilterChain에 Gauth 설정을 위한 `GAuthLoginConfigurer`를 등록해야 합니다. | ||
|
||
#### GAuthLoginConfigurer 옵션 | ||
|
||
- `loginPageUrl(String loginPageUrl)` | ||
- GAuth 로그인 페이지로 리다이렉트되는 주소를 설정합니다. | ||
- default: `/gauth/authorization` | ||
- `loginProcessingUrl(String loginProcessingUrl)` | ||
- GAuth 인증 코드를 받아 처리하는 필터에 접근하는 주소를 설정합니다. | ||
- default: `/login/code/gauth` | ||
- `successHandler(AuthenticationSuccessHandler successHandler)` | ||
- GAuth 인증을 성공했을 때, 실행되는 `AuthenticationSuccessHandler`를 정의합니다. | ||
- default: 서버의 root 주소로 리다이렉트 됩니다. | ||
- `failureHandler(AuthenticationFailureHandler failureHandler)` | ||
- GAuth 인증을 실패했을 때, 실행되는 `AuthenticationFailureHandler`를 정의합니다. | ||
- default: 인증이 실패했다는 json과 함께 401 HTTP Status를 반환합니다. | ||
- `disable()` | ||
- GAuth 인증을 사용하지 않도록 설정합니다. | ||
|
||
#### 예시 1 | ||
|
||
간단한 등록만으로 GAuth 인증을 사용할 수 있습니다. | ||
|
||
```java | ||
|
||
@Configuration | ||
public class SecurityConfig { | ||
private final GAuthLoginConfigurer gatuh; | ||
|
||
public SecurityConfig(GAuthLoginConfigurer gAuthLoginConfigurer) { | ||
this.gatuh = gAuthLoginConfigurer; | ||
} | ||
// ... | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||
http | ||
// ... | ||
.apply(gatuh); | ||
return http.build(); | ||
} | ||
} | ||
``` | ||
|
||
#### 예시 2 | ||
|
||
Endpoint나 Handler를 Custom 할 수 있습니다. | ||
|
||
```java | ||
|
||
@Configuration | ||
public class SecurityConfig { | ||
private final GAuthLoginConfigurer gatuh; | ||
|
||
public SecurityConfig(GAuthLoginConfigurer gAuthLoginConfigurer) { | ||
this.gatuh = gAuthLoginConfigurer; | ||
} | ||
// ... | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||
http | ||
// ... | ||
.apply(gatuh | ||
.loginPageUrl("/to-gauth-login-page") | ||
.loginProcessingUrl("/login/code/gauth") | ||
.successHandler( | ||
new SimpleUrlAuthenticationSuccessHandler("/success")) | ||
.failureHandler( | ||
new SimpleUrlAuthenticationFailureHandler("/failure"))); | ||
return http.build(); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
jdk: | ||
- openjdk17 | ||
- openjdk11 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "GAuth-spring-boot-starter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.