Prevent nil pointer when reloading in single service mode

This commit is contained in:
Travis Groth 2019-08-01 22:07:17 -04:00
parent e8b0bcead6
commit 30243097d2
5 changed files with 15 additions and 0 deletions

View file

@ -36,6 +36,7 @@
### FIXED ### FIXED
- Fixed potential race condition when signing requests. [GH-240] - Fixed potential race condition when signing requests. [GH-240]
- Fixed panic when reloading configuration in single service mode [GH-247]
## v0.1.0 ## v0.1.0

View file

@ -61,6 +61,9 @@ func (a *Authorize) ValidIdentity(route string, identity *Identity) bool {
// UpdateOptions updates internal structures based on config.Options // UpdateOptions updates internal structures based on config.Options
func (a *Authorize) UpdateOptions(o config.Options) error { func (a *Authorize) UpdateOptions(o config.Options) error {
log.Info().Msg("authorize: updating options") log.Info().Msg("authorize: updating options")
if a == nil {
return nil
}
a.identityAccess = NewIdentityWhitelist(o.Policies, o.Administrators) a.identityAccess = NewIdentityWhitelist(o.Policies, o.Administrators)
return nil return nil
} }

View file

@ -94,4 +94,8 @@ func Test_UpdateOptions(t *testing.T) {
} }
}) })
} }
// Test nil
var a *Authorize
a.UpdateOptions(config.Options{})
} }

View file

@ -321,5 +321,8 @@ func (p *Proxy) newReverseProxyHandler(rp *httputil.ReverseProxy, route *config.
// UpdateOptions updates internal structures based on config.Options // UpdateOptions updates internal structures based on config.Options
func (p *Proxy) UpdateOptions(o config.Options) error { func (p *Proxy) UpdateOptions(o config.Options) error {
if p == nil {
return nil
}
return p.UpdatePolicies(&o) return p.UpdatePolicies(&o)
} }

View file

@ -329,4 +329,8 @@ func Test_UpdateOptions(t *testing.T) {
} }
}) })
} }
// Test nil
var p *Proxy
p.UpdateOptions(config.Options{})
} }