-
Notifications
You must be signed in to change notification settings - Fork 2
feat: support custom auth plugins #16
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
Conversation
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
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.
Pull Request Overview
This PR adds support for user-defined authentication plugins, updates configuration for auth and handler directories (with backward-compatibility), extends the core loader/validator, and updates the runtime to load and invoke custom plugins.
- Update defaults and env mappings to include
auth_plugin_dirand renamehandler_dir→handler_plugin_dir(with sync logic). - Introduce
load_auth_pluginand name-validation helpers, and modifyvalidate_auth!+ API entrypoint to use custom plugins. - Add extensive unit & integration specs and documentation examples.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/unit/lib/hooks/core/config_loader_spec.rb | Tests for auth_plugin_dir and handler-dir backward compatibility |
| spec/unit/lib/hooks/app/auth/custom_auth_plugin_spec.rb | Unit tests for custom plugin loading, failures, and security checks |
| spec/unit/lib/hooks/app/auth/custom_auth_integration_spec.rb | End-to-end integration tests for custom auth plugins |
| lib/hooks/core/config_validator.rb | Schema updated with auth_plugin_dir and backward-compat comment |
| lib/hooks/core/config_loader.rb | Defaults and loading logic extended for plugin dirs |
| lib/hooks/app/helpers.rb | New load_auth_plugin & valid_auth_plugin_class_name? |
| lib/hooks/app/auth/auth.rb | validate_auth! enhanced to handle custom plugins |
| lib/hooks/app/api.rb | Pass global config into auth and use handler_plugin_dir |
| docs/... | Example plugin & config documentation |
| .bundle/config | CI-specific bundle path updated (should be reverted) |
Comments suppressed due to low confidence (1)
.bundle/config:3
- [nitpick] This CI-specific absolute path should not be committed in repo. Revert to the relative vendor path or add this file to .gitignore to avoid environment leaks.
BUNDLE_PATH: "/home/runner/work/hooks/hooks/vendor/bundle"
This PR implements support for custom auth plugins, allowing users to "bring their own" authentication implementations for webhook validation beyond the built-in HMAC and SharedSecret plugins.
New Features
Custom Auth Plugin Support
Hooks::Plugins::Auth::Basesome_cool_auth_plugin→SomeCoolAuthPlugin)Configuration Updates
auth_plugin_dirconfiguration option to specify custom auth plugin directoryhandler_dirtohandler_plugin_dirfor naming consistencyhandler_dirconfigurations continue to workExample Usage
Configuration (
hooks.yaml):Endpoint Configuration:
Custom Auth Plugin (
plugins/auth/some_cool_auth_plugin.rb):Security Features
Hooks::Plugins::Auth::BaseBackward Compatibility
handler_dirconfiguration continues to work unchangedauth_plugin_diris not configured, the system falls back to the original "Custom validators not implemented in POC" errorTesting
Fixes #15.