diff --git a/README.md b/README.md index 9528700..6354701 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Data } ``` -This API call will return a JWT token that must be present for any other API calls to succeed. The validity duration of this token is based on the configured TOKEN_HOUR_LIFESPAN value. +This API call will return a JWT token that must be present for any other API calls to succeed. The validity duration of this token is based on the configured TOKEN_HOUR_LIFESPAN value. JWT token is returned as value of `access_token`. ### Secrets Operations diff --git a/controllers/auth.go b/controllers/auth.go index 167e37e..8bbd36c 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -102,7 +102,7 @@ func Login(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{"token": token}) + c.JSON(http.StatusOK, gin.H{"access_token": token}) } diff --git a/controllers/store_secrets.go b/controllers/store_secrets.go index 9ae6567..54708be 100644 --- a/controllers/store_secrets.go +++ b/controllers/store_secrets.go @@ -27,7 +27,8 @@ func StoreSecret(c *gin.Context) { return } - log.Printf("StoreSecret received JSON input '%v'\n", input) + // Don't log this since it contains plaintext secrets + //log.Printf("StoreSecret received JSON input '%v'\n", input) // Populate fields s := models.Secret{} @@ -39,6 +40,7 @@ func StoreSecret(c *gin.Context) { if input.RoleId != 0 { s.RoleId = input.RoleId } else { + log.Printf("StoreSecret setting default RoleId of 1\n") s.RoleId = 1 } @@ -64,13 +66,13 @@ func StoreSecret(c *gin.Context) { s.Secret = input.SecretValue _, err = s.EncryptSecret() if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"Error encrypting secret": err.Error()}) + c.JSON(http.StatusBadRequest, gin.H{"error": "StoreSecret error encrypting secret : " + err.Error()}) return } _, err = s.SaveSecret() if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"Error saving secret": err.Error()}) + c.JSON(http.StatusBadRequest, gin.H{"error": "StoreSecret error saving secret : " + err.Error()}) return } @@ -82,7 +84,7 @@ func UpdateSecret(c *gin.Context) { var input StoreInput if err := c.ShouldBindJSON(&input); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusBadRequest, gin.H{"error": "UpdateSecret error binding to input JSON : " + err.Error()}) return } @@ -96,7 +98,7 @@ func UpdateSecret(c *gin.Context) { } // Verify that the user role is not readonly if u.ReadOnly { - c.JSON(http.StatusForbidden, gin.H{"error": "user role does not permit updates"}) + c.JSON(http.StatusForbidden, gin.H{"error": "UpdateSecret user role does not permit updates"}) return } @@ -144,13 +146,13 @@ func UpdateSecret(c *gin.Context) { s.Secret = input.SecretValue _, err = s.EncryptSecret() if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"Error encrypting secret": err.Error()}) + c.JSON(http.StatusBadRequest, gin.H{"error": "UpdateSecret error encrypting secret : " + err.Error()}) return } _, err = s.UpdateSecret() if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"Error saving secret": err.Error()}) + c.JSON(http.StatusBadRequest, gin.H{"error": "UpdateSecret error saving secret : " + err.Error()}) return }