Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(config): support hot reloading #667

Merged
merged 6 commits into from
Jun 14, 2022
Merged

refactor(config): support hot reloading #667

merged 6 commits into from
Jun 14, 2022

Conversation

aeneasr
Copy link
Member

@aeneasr aeneasr commented May 4, 2022

This patch updates the config system to be replacable and uses functions instead of struct fields. This allows implementing hot reloading mechanisms easily.

BREAKING CHANGES: Please be aware that several internal APIs have changed, as well as public methods. Most notably, we added the context to all Write* metods.

 type OAuth2Provider interface {
-    WriteAuthorizeError(rw http.ResponseWriter, requester AuthorizeRequester, err error)
+    WriteAuthorizeError(ctx context.Context, rw http.ResponseWriter, requester AuthorizeRequester, err error)

-    WriteAuthorizeResponse(rw http.ResponseWriter, requester AuthorizeRequester, responder AuthorizeResponder)
+    WriteAuthorizeResponse(ctx context.Context, rw http.ResponseWriter, requester AuthorizeRequester, responder AuthorizeResponder)

-    WriteAccessError(rw http.ResponseWriter, requester AccessRequester, err error)
+    WriteAccessError(ctx context.Context, rw http.ResponseWriter, requester AccessRequester, err error)

-    WriteAccessResponse(rw http.ResponseWriter, requester AccessRequester, responder AccessResponder)
+    WriteAccessResponse(ctx context.Context, rw http.ResponseWriter, requester AccessRequester, responder AccessResponder)

-    WriteRevocationResponse(rw http.ResponseWriter, err error)
+    WriteRevocationResponse(ctx context.Context, rw http.ResponseWriter, err error)

-    WriteIntrospectionError(rw http.ResponseWriter, err error)
+    WriteIntrospectionError(ctx context.Context, rw http.ResponseWriter, err error)

-    WriteIntrospectionResponse(rw http.ResponseWriter, r IntrospectionResponder)
+    WriteIntrospectionResponse(ctx context.Context, rw http.ResponseWriter, r IntrospectionResponder)
 }

The default config struct has moved from package github.com/ory/fosite/compose.Config to github.com/ory/fosite.Config.

Please note that the HMAC / global secret has to be set no longer in the compose call, but in the config initialization:

-compose.ComposeAllEnabled(&compose.Config{}, store, secret, privateKey)
+compose.ComposeAllEnabled(&fosite.Config{GlobalSecret: secret}, store, privateKey)

Closes #666

@aeneasr aeneasr force-pushed the reload branch 10 times, most recently from 3a0c952 to fe64ab0 Compare May 9, 2022 07:25
@aeneasr aeneasr self-assigned this May 9, 2022
@aeneasr aeneasr force-pushed the reload branch 3 times, most recently from 0899ea3 to 5f156bd Compare May 13, 2022 18:16
This patch updates the config system to be replacable and uses functions instead of struct fields. This allows implementing hot reloading mechanisms easily.

BREAKING CHANGES: Please be aware that several internal APIs have changed, as well as public methods. Most notably, we added the context to all `Write*` metods.

```patch
 type OAuth2Provider interface {
-    WriteAuthorizeError(rw http.ResponseWriter, requester AuthorizeRequester, err error)
+    WriteAuthorizeError(ctx context.Context, rw http.ResponseWriter, requester AuthorizeRequester, err error)

-    WriteAuthorizeResponse(rw http.ResponseWriter, requester AuthorizeRequester, responder AuthorizeResponder)
+    WriteAuthorizeResponse(ctx context.Context, rw http.ResponseWriter, requester AuthorizeRequester, responder AuthorizeResponder)

-    WriteAccessError(rw http.ResponseWriter, requester AccessRequester, err error)
+    WriteAccessError(ctx context.Context, rw http.ResponseWriter, requester AccessRequester, err error)

-    WriteAccessResponse(rw http.ResponseWriter, requester AccessRequester, responder AccessResponder)
+    WriteAccessResponse(ctx context.Context, rw http.ResponseWriter, requester AccessRequester, responder AccessResponder)

-    WriteRevocationResponse(rw http.ResponseWriter, err error)
+    WriteRevocationResponse(ctx context.Context, rw http.ResponseWriter, err error)

-    WriteIntrospectionError(rw http.ResponseWriter, err error)
+    WriteIntrospectionError(ctx context.Context, rw http.ResponseWriter, err error)

-    WriteIntrospectionResponse(rw http.ResponseWriter, r IntrospectionResponder)
+    WriteIntrospectionResponse(ctx context.Context, rw http.ResponseWriter, r IntrospectionResponder)
 }
```

The default config struct has moved from package `github.com/ory/fosite/compose.Config` to `github.com/ory/fosite.Config`. Struct `github.com/ory/fosite.Fosite` no longer has any configuration parameters
itself.

Please note that the HMAC / global secret has to be set no longer in the compose call, but in the config initialization:

```patch
-compose.ComposeAllEnabled(&compose.Config{}, store, secret, privateKey)
+compose.ComposeAllEnabled(&fosite.Config{GlobalSecret: secret}, store, privateKey)
```

Many internal interfaces have been changed, usually adding `ctx context.Context` as the first parameter.

Closes #666
@aeneasr aeneasr merged commit 93e31ed into master Jun 14, 2022
@aeneasr aeneasr deleted the reload branch June 14, 2022 07:49
cfryanr added a commit to vmware-tanzu/pinniped that referenced this pull request Dec 14, 2022
Most of the changes in this commit are because of these fosite PRs
which changed behavior and/or APIs in fosite:
- ory/fosite#667
- ory/fosite#679 (from me!)
- ory/fosite#675
- ory/fosite#688

Due to the changes in fosite PR #688, we need to bump our storage
version for anything which stores the DefaultSession struct as JSON.
cfryanr added a commit to vmware-tanzu/pinniped that referenced this pull request Dec 14, 2022
Most of the changes in this commit are because of these fosite PRs
which changed behavior and/or APIs in fosite:
- ory/fosite#667
- ory/fosite#679 (from me!)
- ory/fosite#675
- ory/fosite#688

Due to the changes in fosite PR #688, we need to bump our storage
version for anything which stores the DefaultSession struct as JSON.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration hot reloading
1 participant