-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat: fetch secret from IOptionsMonitor
if defined
#550
Conversation
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add a little example in the docs of how one could update the secret?
@justinmchase I think the official documentation does a better job than I could ever do it. I could link to something like this instead? |
fe684d5
to
d0e478f
Compare
@@ -0,0 +1,6 @@ | |||
namespace Octokit.Webhooks.AspNetCore; | |||
|
|||
public sealed record GitHubWebhookOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be sealed? I can imagine a use case (at least personally) where I would like to be able to also lump unrelated configuration to webhooks (like my client secret or app id) and not have to create a separate class for webhooks and GitHub app configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sealed it mostly because I seal all of the classes in this library. The performance benefits of the webhook object classes is probably more important than this object. Webhook objects will be constructed on each event, whereas this will be constructed once, on startup.
I can send a follow-up PR to unseal it. I'm still waiting on #568 to be merged before I cut a release.
Currently, the secret is statically defined when registering the GitHub webhooks endpoint with
MapGitHubWebhooks
. But this means that thesecret
used to validate the webhooks signature is static for the lifetime of the application.If, instead, we attempt to fetch the secret from
IOptionsMonitor<GitHubWebhookOptions>
it allows us to rotate the secret without restarting the application.This is also implemented in a backwards compatible manner. If the
secret
parameter passed toMapGitHubWebhooks
isnull
, but anIOptionsMonitor<GitHubWebhookOptions>
instance has been registered, the secret will be fetched from there instead.Closes #486
Before the change?
After the change?
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!