feat: support custom auth plugins#16
Merged
Merged
Conversation
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
Co-authored-by: GrantBirki <23362539+GrantBirki@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] feat: support custom auth plugins
feat: support custom auth plugins
Jun 11, 2025
Contributor
There was a problem hiding this comment.
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.