change some error messages
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -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})
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user