29 lines
711 B
Go
29 lines
711 B
Go
package server
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/dhao2001/mygo/internal/app"
|
|
"github.com/dhao2001/mygo/internal/handler"
|
|
"github.com/dhao2001/mygo/internal/middleware"
|
|
)
|
|
|
|
func setupProtectedRoutes(rg *gin.RouterGroup, webApp *app.WebApp) {
|
|
jwtSecret := []byte(webApp.Config.JWT.Secret)
|
|
accountHandler := handler.NewAccountHandler(webApp.AuthService)
|
|
|
|
rg.Use(middleware.AuthRequired(jwtSecret))
|
|
|
|
account := rg.Group("/account")
|
|
{
|
|
account.GET("", accountHandler.GetAccount)
|
|
|
|
passkeys := account.Group("/passkeys")
|
|
{
|
|
passkeys.GET("", accountHandler.ListPasskeys)
|
|
passkeys.POST("", accountHandler.CreatePasskey)
|
|
passkeys.DELETE("/:id", accountHandler.RevokePasskey)
|
|
}
|
|
}
|
|
}
|