ory / hydra

The most scalable and customizable OpenID Certified™ OpenID Connect and OAuth Provider on the market. Become an OpenID Connect and OAuth2 Provider over night. Broad support for related RFCs. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=hydra
Apache License 2.0
15.68k stars 1.5k forks source link

Support hot-reloading for all configuration values #3054

Closed aeneasr closed 2 years ago

aeneasr commented 2 years ago

Preflight checklist

Describe your problem

Currently, many configuration values can not be changed on the fly. This is because in a lot of places, the configuration is set on struct / service initialization and can then never be changed afterwards.

A big problem here is that Ory Fosite ( https://github.com/ory/fosite ) is using a static config system (which can only be changed on initialization) and also provides most of the configuration options.

Describe your ideal solution

Ideally, all configuration values would be consumed as functions GetSomeValue() string and not as values c.SomeValue. We have established a pattern in Ory Kratos and other projects already. The main concept is that every function which requires a configuration value is calling the service locator to find the right config struct this.Config(ctx) to then call the required config value.

As part of this change and to support full contextualization, we need to:

  1. [ ] Do away with any context.TODO() or context.Background() that are used in non-tests
  2. [ ] Ensure we never call the config struct directly in the registry (remove any references to m.C)
  3. [ ] Contextualize Fosite's config which will require API changes

Workarounds or alternatives

none

Version

master

Additional Context

Implementing this effectively implements full Contextualization.

aeneasr commented 2 years ago

For fosite the easiest way to do it would probably be to define an interface for https://github.com/ory/fosite/blob/master/compose/config.go#L33 and go from there

aeneasr commented 2 years ago

done