Refactor JWT auth and remove DB dependency from config

This commit is contained in:
2025-05-17 20:28:18 +03:30
parent f9d896bf72
commit 81adfa1ad9
3 changed files with 21 additions and 29 deletions
+5 -4
View File
@@ -1,7 +1,7 @@
package server
import (
"CatsOfMastodonBotGo/internal"
"CatsOfMastodonBotGo/internal/auth"
"CatsOfMastodonBotGo/internal/web/handlers"
"github.com/gin-contrib/cors"
@@ -20,14 +20,15 @@ func SetupRouter() *gin.Engine {
handlers.InitAdminDashboardHandler()
handlers.InitApiEndpointHandler()
auth.InitJwtTokenGenerator()
admin := r.Group("/admin")
// My man, this is done way more efficient and fast in .NET, specially the authentication part
admin.POST("/login", handlers.AdminDashboardHandlerInstance.Login)
admin.GET("/getmedia", appContext.Jwt.GinMiddleware(), handlers.AdminDashboardHandlerInstance.GetMedia)
admin.POST("/approve", appContext.Jwt.GinMiddleware(), handlers.AdminDashboardHandlerInstance.ApproveMedia)
admin.POST("/reject", appContext.Jwt.GinMiddleware(), handlers.AdminDashboardHandlerInstance.RejectMedia)
admin.GET("/getmedia", auth.JwtTokenGeneratorInstance.GinMiddleware(), handlers.AdminDashboardHandlerInstance.GetMedia)
admin.POST("/approve", auth.JwtTokenGeneratorInstance.GinMiddleware(), handlers.AdminDashboardHandlerInstance.ApproveMedia)
admin.POST("/reject", auth.JwtTokenGeneratorInstance.GinMiddleware(), handlers.AdminDashboardHandlerInstance.RejectMedia)
api := r.Group("/api")