1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/**
* SmtpService - smtpservice
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Paolo Lulli <kevwe.com>
* @copyright Paolo Lulli 2026
*/
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func ReadSecret(cfg ConfigServiceConfig) gin.HandlerFunc {
return func(c *gin.Context) {
var secretName = c.Param("secretname")
if secretName == "" {
c.JSONP(http.StatusCreated, gin.H{"error": "missing secret param", "status": "error"})
}
password, ko := GetPassword(cfg.KeepassKeyStoreFile, cfg.KeepassSecretKeyFile, secretName)
if ko {
c.JSONP(http.StatusCreated, gin.H{"error": "secret not found", "status": "error"})
return
}
c.JSONP(http.StatusCreated, gin.H{"secret": secretName, "value": password})
}
}
|