Skip to content

Commit

Permalink
improve: api require app sign move into /v1/app router group
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 committed Apr 5, 2024
1 parent c18148d commit 54cd487
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions internal/api/router/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"github.com/gin-gonic/gin"
controllers "github.com/ncuhome/GeniusAuthoritarian/internal/api/controllers/app"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/middlewares"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/app/token"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/app/user"
)

func Router(G *gin.RouterGroup) {
Expand All @@ -12,4 +14,7 @@ func Router(G *gin.RouterGroup) {
keypair := G.Group("keypair")
keypair.GET("server", controllers.ServerPublicKeys)
keypair.POST("rpc", controllers.RpcClientCredential)

user.Router(G.Group("user"))
token.Router(G.Group("token"))
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package public
package token

import (
"github.com/gin-gonic/gin"
controllers "github.com/ncuhome/GeniusAuthoritarian/internal/api/controllers/public"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/controllers/app"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/middlewares"
)

func routerToken(G *gin.RouterGroup) {
G.Use(middlewares.RequireAppSignature)

func Router(G *gin.RouterGroup) {
refresh := G.Group("refresh")
refresh.POST("/", controllers.RefreshToken)
refresh.PATCH("/", controllers.ModifyRefreshPayload)
Expand Down
10 changes: 10 additions & 0 deletions internal/api/router/app/user/user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package user

import (
"github.com/gin-gonic/gin"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/controllers/app"
)

func Router(G *gin.RouterGroup) {
G.GET("info", controllers.GetUserPublicInfo)
}
9 changes: 7 additions & 2 deletions internal/api/router/public/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package public

import (
"github.com/gin-gonic/gin"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/middlewares"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/app/token"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/app/user"
"github.com/ncuhome/GeniusAuthoritarian/internal/api/router/public/login"
)

func Router(G *gin.RouterGroup) {
routerApp(G.Group("app"))
routerToken(G.Group("token"))
routerUser(G.Group("user"))
login.Router(G.Group("login"))

// Deprecated, keep for compatibility
token.Router(G.Group("token", middlewares.RequireAppSignature))
user.Router(G.Group("user", middlewares.RequireAppSignature))
}
13 changes: 0 additions & 13 deletions internal/api/router/public/user.go

This file was deleted.

0 comments on commit 54cd487

Please sign in to comment.