Skip to content

Commit

Permalink
feat(websocket): integrate JWT auth in ws connection and add Go auth API
Browse files Browse the repository at this point in the history
  • Loading branch information
kasugamirai committed Sep 13, 2024
1 parent 7ceef33 commit b2484e9
Show file tree
Hide file tree
Showing 22 changed files with 1,029 additions and 98 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
4 changes: 3 additions & 1 deletion api/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo {
// apis
api := e.Group("/api")
api.GET("/ping", Ping(), privateCache)

apiPrivate := api.Group("", privateCache)
apiPrivate.POST("/graphql", GraphqlAPI(cfg.Config.GraphQL, gqldev))

apiPrivate.POST("/signup", Signup())

apiPrivateWithAuth := apiPrivate.Group("", echo.WrapMiddleware(lo.Must(appx.AuthMiddleware(authConfig, adapter.ContextAuthInfo, false))))
apiPrivateWithAuth.GET("/validate-token", ValidateToken())

if !cfg.Config.AuthSrv.Disabled {
apiPrivate.POST("/signup/verify", StartSignupVerify())
apiPrivate.POST("/signup/verify/:code", SignupVerify())
Expand Down
8 changes: 8 additions & 0 deletions api/internal/app/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ func SignupVerify() echo.HandlerFunc {
return c.JSON(http.StatusOK, output)
}
}

func ValidateToken() echo.HandlerFunc {
return func(c echo.Context) error {
return c.JSON(http.StatusOK, map[string]interface{}{
"status": "authenticated",
})
}
}
Loading

0 comments on commit b2484e9

Please sign in to comment.