go: add getters for Session{Auth,Encr}IsHex
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2023-08-04 18:13:23 +02:00
parent 172703aab5
commit 2559092231
Signed by: wanderer
SSH Key Fingerprint: SHA256:MdCZyJ2sHLltrLBp0xQO0O1qTW9BT/xl5nXkDvhlMCI
2 changed files with 16 additions and 6 deletions

@ -72,7 +72,7 @@ func (a *App) SetEchoSettings() {
encrSecret []byte
)
if a.setting.SessionAuthIsHex {
if a.setting.SessionAuthIsHex() {
b, err := hex.DecodeString(a.setting.SessionCookieAuthSecret())
if err != nil {
panic(err)
@ -81,7 +81,7 @@ func (a *App) SetEchoSettings() {
authSecret = b
}
if a.setting.SessionEncrIsHex {
if a.setting.SessionEncrIsHex() {
b, err := hex.DecodeString(a.setting.SessionCookieEncrSecret())
if err != nil {
panic(err)

@ -29,8 +29,8 @@ type Settings struct {
sessionCookieName string
sessionCookieAuthSecret string
sessionCookieEncrSecret string
SessionAuthIsHex bool
SessionEncrIsHex bool
sessionAuthIsHex bool
sessionEncrIsHex bool
assetsPath string
templatesPath string
version string
@ -87,11 +87,11 @@ func (s *Settings) Consolidate(conf *config.Config, host *string, port *int, dev
authHex, encrHex := conf.SessionSecretsAreHex()
if authHex {
s.SessionAuthIsHex = true
s.sessionAuthIsHex = true
}
if encrHex {
s.SessionEncrIsHex = true
s.sessionEncrIsHex = true
}
if conf.HTTP.Gzip > 0 {
@ -204,6 +204,16 @@ func (s *Settings) SessionCookieEncrSecret() string {
return s.sessionCookieEncrSecret
}
// SessionAuthIsHex returns whether the session cookie authentication secret is hex.
func (s *Settings) SessionAuthIsHex() bool {
return s.sessionAuthIsHex
}
// SessionEncrIsHex returns whether the session cookie encryption secret is hex.
func (s *Settings) SessionEncrIsHex() bool {
return s.sessionEncrIsHex
}
// HTTPDomain returns the httpDomain.
func (s *Settings) HTTPDomain() string {
return s.httpDomain