mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 12:45:47 +00:00
feat: add support for using secret files for basic auth password
This commit is contained in:
@@ -154,9 +154,9 @@ func (h *Handlers) AuthHandler(c *gin.Context) {
|
|||||||
log.Debug().Str("key", key).Msg("Setting header")
|
log.Debug().Str("key", key).Msg("Setting header")
|
||||||
c.Header(key, value)
|
c.Header(key, value)
|
||||||
}
|
}
|
||||||
if labels.Basic.Username != "" && labels.Basic.Password != "" {
|
if labels.Basic.Username != "" && utils.GetSecret(labels.Basic.Password.Plain, labels.Basic.Password.File) != "" {
|
||||||
log.Debug().Str("username", labels.Basic.Username).Msg("Setting basic auth headers")
|
log.Debug().Str("username", labels.Basic.Username).Msg("Setting basic auth headers")
|
||||||
c.Header("Authorization", fmt.Sprintf("Basic %s", utils.GetBasicAuth(labels.Basic.Username, labels.Basic.Password)))
|
c.Header("Authorization", fmt.Sprintf("Basic %s", utils.GetBasicAuth(labels.Basic.Username, utils.GetSecret(labels.Basic.Password.Plain, labels.Basic.Password.File))))
|
||||||
}
|
}
|
||||||
c.JSON(200, gin.H{
|
c.JSON(200, gin.H{
|
||||||
"status": 200,
|
"status": 200,
|
||||||
@@ -283,9 +283,9 @@ func (h *Handlers) AuthHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set basic auth headers if configured
|
// Set basic auth headers if configured
|
||||||
if labels.Basic.Username != "" && labels.Basic.Password != "" {
|
if labels.Basic.Username != "" && utils.GetSecret(labels.Basic.Password.Plain, labels.Basic.Password.File) != "" {
|
||||||
log.Debug().Str("username", labels.Basic.Username).Msg("Setting basic auth headers")
|
log.Debug().Str("username", labels.Basic.Username).Msg("Setting basic auth headers")
|
||||||
c.Header("Authorization", fmt.Sprintf("Basic %s", utils.GetBasicAuth(labels.Basic.Username, labels.Basic.Password)))
|
c.Header("Authorization", fmt.Sprintf("Basic %s", utils.GetBasicAuth(labels.Basic.Username, utils.GetSecret(labels.Basic.Password.Plain, labels.Basic.Password.File))))
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user is allowed to access the app
|
// The user is allowed to access the app
|
||||||
|
|||||||
@@ -109,7 +109,13 @@ type OAuthLabels struct {
|
|||||||
// Basic auth labels for a tinyauth protected container
|
// Basic auth labels for a tinyauth protected container
|
||||||
type BasicLabels struct {
|
type BasicLabels struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password PassowrdLabels
|
||||||
|
}
|
||||||
|
|
||||||
|
// PassowrdLabels is a struct that contains the password labels for a tinyauth protected container
|
||||||
|
type PassowrdLabels struct {
|
||||||
|
Plain string
|
||||||
|
File string
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP labels for a tinyauth protected container
|
// IP labels for a tinyauth protected container
|
||||||
|
|||||||
Reference in New Issue
Block a user