cleanup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-23 12:11:08 +11:00
parent 4bc430633e
commit b801563074
2 changed files with 1 additions and 80 deletions

View File

@@ -31,8 +31,6 @@ type ListSecret struct {
func RetrieveSecret(c *gin.Context) {
var input RetrieveInput
//var results []models.Secret
//var userIsAdmin bool = false
// Validate the input matches our struct
if err := c.ShouldBindJSON(&input); err != nil {
@@ -41,15 +39,6 @@ func RetrieveSecret(c *gin.Context) {
}
log.Printf("RetrieveSecret received JSON input '%v'\n", input)
/*
// Get the user and role id of the requestor
u, err := models.UserGetRoleFromToken(c)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
*/
// Populate fields
s := models.Secret{}
s.DeviceName = input.DeviceName
@@ -161,36 +150,13 @@ func retrieveSpecifiedSecret(s *models.Secret, c *gin.Context) {
UserId: UserId,
SecretId: results[i].SecretId,
IpAddress: c.ClientIP(),
EventText: fmt.Sprintf("User %s retrieved SecretId %d", safeList[0].User.UserName, results[i].SecretId),
EventText: fmt.Sprintf("User '%s' retrieved SecretId %d", safeList[0].User.UserName, results[i].SecretId),
}
a.AuditLogAdd()
}
// output results as json
c.JSON(http.StatusOK, gin.H{"message": "success", "data": results, "count": len(results)})
/*
if len(results) == 1 {
// Create audit record
a := models.Audit{
UserId: UserId,
SecretId: results[0].SecretId,
IpAddress: c.ClientIP(),
EventText: fmt.Sprintf("Retrieved Secret Id %d", results[0].SecretId),
}
a.AuditLogAdd()
// output results as json
c.JSON(http.StatusOK, gin.H{"message": "success", "data": results})
} else if len(results) > 1 {
c.JSON(http.StatusBadRequest, gin.H{"error": "found multiple matching secrets"})
return
} else {
c.JSON(http.StatusBadRequest, gin.H{"error": "found no matching secrets"})
return
}
*/
}
func ListSecrets(c *gin.Context) {
@@ -233,47 +199,3 @@ func ListSecrets(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "success", "data": output})
}
func RetrieveMultpleSecrets(c *gin.Context) {
// TODO implement with new schema
/*
var input RetrieveInput
// Validate the input matches our struct
if err := c.ShouldBindJSON(&input); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
log.Printf("StoreSecret received JSON input '%v'\n", input)
// Get the user and role id of the requestor
user_id, err := token.ExtractTokenID(c)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
u, err := models.GetUserRoleByID(user_id)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// Populate fields
s := models.Secret{}
s.RoleId = u.RoleId
s.DeviceName = input.DeviceName
s.DeviceCategory = input.DeviceCategory
results, err := models.GetSecrets(&s, false)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// output results as json
c.JSON(http.StatusOK, gin.H{"message": "success", "data": results})
*/
}