protect unlock api endpoint
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-03 17:18:23 +11:00
parent 85bea202f0
commit f7168d465a
4 changed files with 19 additions and 5 deletions

View File

@@ -24,6 +24,11 @@ func Unlock(c *gin.Context) {
}
log.Println("Unlock received JSON input")
if models.CheckKeyProvided() {
c.JSON(http.StatusBadRequest, gin.H{"error": "secret key can only be provided once after service start"})
return
}
// check that the key is 32 bytes long
if len(input.SecretKey) != 32 {
c.JSON(http.StatusBadRequest, gin.H{"error": "secret key provided is invalid, must be exactly 32 bytes long"})