initial safes handler
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-10 11:29:21 +11:00
parent 8143470b5a
commit 50f078db7a
4 changed files with 141 additions and 11 deletions

26
main.go
View File

@@ -259,26 +259,32 @@ func main() {
// Other functions for admin
adminOnly.POST("/unlock", controllers.Unlock)
adminOnly.POST("/safes/listall", controllers.GetAllSafesHandler)
// Deprecated
//adminOnly.GET("/roles", controllers.GetRoles)
//adminOnly.POST("/role/add", controllers.AddRole)
// Get secrets
protected := router.Group("/api/secret")
protected.Use(middlewares.JwtAuthMiddleware())
protected.POST("/retrieve", controllers.RetrieveSecret)
protected.GET("/list", controllers.ListSecrets)
protected.POST("/retrieveMultiple", controllers.RetrieveMultpleSecrets) // TODO is this still required?
protected.POST("/store", controllers.StoreSecret)
protected.POST("/update", controllers.UpdateSecret)
secretRoutes := router.Group("/api/secret")
secretRoutes.Use(middlewares.JwtAuthMiddleware())
secretRoutes.POST("/retrieve", controllers.RetrieveSecret)
secretRoutes.GET("/list", controllers.ListSecrets)
secretRoutes.POST("/retrieveMultiple", controllers.RetrieveMultpleSecrets) // TODO is this still required?
secretRoutes.POST("/store", controllers.StoreSecret)
secretRoutes.POST("/update", controllers.UpdateSecret)
// TODO
protected.POST("/delete", controllers.DeleteSecret)
secretRoutes.POST("/delete", controllers.DeleteSecret)
// Get Safes (only those user allowed to access)
safeRoutes := router.Group("/api/safe")
safeRoutes.Use(middlewares.JwtAuthMiddleware())
safeRoutes.GET("/list", controllers.GetSafesHandler)
// Support parameters in path
// See https://gin-gonic.com/docs/examples/param-in-path/
protected.GET("/retrieve/name/:devicename", controllers.RetrieveSecretByDevicename)
protected.GET("/retrieve/category/:devicecategory", controllers.RetrieveSecretByDevicecategory)
secretRoutes.GET("/retrieve/name/:devicename", controllers.RetrieveSecretByDevicename)
secretRoutes.GET("/retrieve/category/:devicecategory", controllers.RetrieveSecretByDevicecategory)
// Initializing the server in a goroutine so that
// it won't block the graceful shutdown handling below