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

Configuration hot reloading #666

Closed
3 of 6 tasks
aeneasr opened this issue May 4, 2022 · 3 comments · Fixed by #667
Closed
3 of 6 tasks

Configuration hot reloading #666

aeneasr opened this issue May 4, 2022 · 3 comments · Fixed by #667
Assignees
Labels
feat New feature or request.

Comments

@aeneasr
Copy link
Member

aeneasr commented May 4, 2022

Preflight checklist

Describe your problem

Hot reloading of config is not possible.

Describe your ideal solution

We want to support hot reloading for all of Ory Fosite's configuration values.

Workarounds or alternatives

None

Version

master

Additional Context

No response

@aeneasr aeneasr added the feat New feature or request. label May 4, 2022
@aeneasr aeneasr self-assigned this May 4, 2022
aeneasr added a commit that referenced this issue May 4, 2022
BREAKING CHANGES: <ENTERME>\nCloses #666
aeneasr added a commit that referenced this issue May 4, 2022
BREAKING CHANGES: <ENTERME>\nCloses #666
aeneasr added a commit that referenced this issue May 8, 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.

```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`.

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)
```

Closes #666
aeneasr added a commit that referenced this issue May 9, 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.

```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)
```

Closes #666
aeneasr added a commit that referenced this issue May 10, 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.

```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 added a commit that referenced this issue Jun 13, 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.

```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 added a commit that referenced this issue Jun 14, 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.

```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
Copy link
Member Author

aeneasr commented Jun 14, 2022

Done

@james-d-elliott
Copy link
Contributor

Nice work!

@aeneasr
Copy link
Member Author

aeneasr commented Jun 14, 2022

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants