-
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.
* up: 의존성 * add: 테스트로 토큰 검사할 수 있는 컨트롤러 * add: api spec * up: 로그인 사용자 반환값 변경 * add: 토큰 값을 검사하는 res 추가 * fix: 항상 이미지 pull 하도록 수정 (#4) * up: 사용하지 않는 의존성을 제거 * add: 프로그램 버전 명 추가 * up: 안내메시지 친화적으로 변경 * up: 리소스 리미트 추가 * docs: 설명 추가 * up: 웹 서버 상태를 알 수 있는 기본 컨트롤러 추가
- Loading branch information
Showing
10 changed files
with
97 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
# oauth-server | ||
|
||
gin을 이용하여 인증서버를 구축합니다. | ||
redis와 의존됩니다. | ||
OAuth 인증서버를 구축합니다. | ||
|
||
1. JWT Token을 사용합니다. | ||
|
||
# Stack | ||
|
||
1. go:1.16.3 | ||
1. vscode | ||
1. gin | ||
1. redis | ||
1. docker | ||
|
||
# 시퀀스 다이어그램 | ||
|
||
# History | ||
> 추가 예정 | ||
## 프로젝트 생성 방법 | ||
# 빠른 시작 | ||
|
||
1. `go mod init oauth-server` | ||
1. `go get -u github.com/gin-gonic/gin` | ||
1. `.vscode/launch.json` 에 `Launch Package` 템플릿으로 디버깅 환경 구축 | ||
1. vscode에서 `F5` 혹은 `go run main.go` 으로 시작합니다. |
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,8 @@ | ||
|
||
@Host = http://localhost:3000 | ||
|
||
### 로그인 | ||
GET {{Host}}/login | ||
|
||
### 토큰 검사 | ||
GET {{Host}}/token/valid |
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 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,20 @@ | ||
package token | ||
|
||
import ( | ||
"net/http" | ||
"time" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func Valid(c *gin.Context) { | ||
var msg struct { | ||
Id int `json:"id"` | ||
Message string `json:"message"` | ||
DateTime time.Time `json:"dateTime"` | ||
} | ||
msg.Id = 1 | ||
msg.Message = "토큰이 유효합니다." | ||
msg.DateTime = time.Now() | ||
c.JSON(http.StatusOK, msg) | ||
} |
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 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 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 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 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 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,18 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"oauth-server/controller" | ||
"oauth-server/controller/token" | ||
"os" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
const ( | ||
name = "oauth-server" | ||
version = "0.1.0" | ||
) | ||
|
||
func init() { | ||
fmt.Printf("version: %s\n", version) | ||
} | ||
|
||
func main() { | ||
r := gin.Default() | ||
|
||
r.GET("/", func(c *gin.Context) { | ||
resData := []byte(name) | ||
c.Data(http.StatusOK, "text/html; charset=utf-8", resData) | ||
}) | ||
r.GET("/ping", func(c *gin.Context) { | ||
c.JSON(200, gin.H{ | ||
"message": "pong", | ||
}) | ||
resData := []byte(`OK`) | ||
c.Data(http.StatusOK, "text/html; charset=utf-8", resData) | ||
}) | ||
r.GET("/version", func(c *gin.Context) { | ||
resData := []byte(version) | ||
c.Data(http.StatusOK, "text/html; charset=utf-8", resData) | ||
}) | ||
r.GET("/env", func(c *gin.Context) { | ||
resData := os.Environ() | ||
c.JSON(http.StatusOK, resData) | ||
}) | ||
|
||
r.GET("/login", controller.Login) | ||
r.GET("/token/valid", token.Valid) | ||
|
||
r.Run(":3000") | ||
} |