From ae269371da95cd55f94ad8862822a114fe9d166d Mon Sep 17 00:00:00 2001 From: Kyle Mendell Date: Sun, 22 Feb 2026 12:39:19 -0600 Subject: [PATCH] feat: current version api endpoint (#1310) --- backend/internal/bootstrap/router_bootstrap.go | 2 +- .../internal/controller/version_controller.go | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go index 8078b619..6803734d 100644 --- a/backend/internal/bootstrap/router_bootstrap.go +++ b/backend/internal/bootstrap/router_bootstrap.go @@ -85,7 +85,7 @@ func initRouter(db *gorm.DB, svc *services) (utils.Service, error) { controller.NewAuditLogController(apiGroup, svc.auditLogService, authMiddleware) controller.NewUserGroupController(apiGroup, authMiddleware, svc.userGroupService) controller.NewCustomClaimController(apiGroup, authMiddleware, svc.customClaimService) - controller.NewVersionController(apiGroup, svc.versionService) + controller.NewVersionController(apiGroup, authMiddleware, svc.versionService) controller.NewScimController(apiGroup, authMiddleware, svc.scimService) controller.NewUserSignupController(apiGroup, authMiddleware, middleware.NewRateLimitMiddleware(), svc.userSignUpService, svc.appConfigService) diff --git a/backend/internal/controller/version_controller.go b/backend/internal/controller/version_controller.go index c4d9bf07..09679908 100644 --- a/backend/internal/controller/version_controller.go +++ b/backend/internal/controller/version_controller.go @@ -5,14 +5,17 @@ import ( "time" "github.com/gin-gonic/gin" + "github.com/pocket-id/pocket-id/backend/internal/common" + "github.com/pocket-id/pocket-id/backend/internal/middleware" "github.com/pocket-id/pocket-id/backend/internal/service" "github.com/pocket-id/pocket-id/backend/internal/utils" ) // NewVersionController registers version-related routes. -func NewVersionController(group *gin.RouterGroup, versionService *service.VersionService) { +func NewVersionController(group *gin.RouterGroup, authMiddleware *middleware.AuthMiddleware, versionService *service.VersionService) { vc := &VersionController{versionService: versionService} group.GET("/version/latest", vc.getLatestVersionHandler) + group.GET("/version/current", authMiddleware.WithAdminNotRequired().Add(), vc.getCurrentVersionHandler) } type VersionController struct { @@ -38,3 +41,16 @@ func (vc *VersionController) getLatestVersionHandler(c *gin.Context) { "latestVersion": tag, }) } + +// getCurrentVersionHandler godoc +// @Summary Get current deployed version of Pocket ID +// @Tags Version +// @Produce json +// @Success 200 {object} map[string]string "Current version information" +// @Router /api/version/current [get] +func (vc *VersionController) getCurrentVersionHandler(c *gin.Context) { + + c.JSON(http.StatusOK, gin.H{ + "currentVersion": common.Version, + }) +}