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

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