-
Notifications
You must be signed in to change notification settings - Fork 123
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
Add read-only configuration #2893
base: master
Are you sure you want to change the base?
Conversation
Sample output with
Sample output with
|
- When read-only mode is enabled via rails config, controller endpoints that are explicitly enrolled into a `write_protected` list return a HTTP 405 Method Not Allowed when invoked, also throwing Conjur error code: `CONJ00153E` - Implemented using module prepending
@@ -0,0 +1,15 @@ | |||
module ReadOnlyPrepender |
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.
ReadOnlyPrepender has no descriptive comment
def write_protected(*method_names) | ||
method_names.each do |m| | ||
proxy = Module.new do | ||
define_method(m) do |*args| |
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.
ReadOnlyPrepender#write_protected contains iterators nested 2 deep
method_names.each do |m| | ||
proxy = Module.new do | ||
define_method(m) do |*args| | ||
raise ::Errors::Conjur::ReadOnly::ActionNotPermitted unless !Rails.configuration.read_only |
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.
Add empty line after guard clause.
self.prepend proxy | ||
end | ||
end | ||
end |
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.
end
at 15, 2 is not aligned with module ReadOnlyPrepender
at 1, 0.
module ReadOnlyPrepender | ||
# Given a list of method symbols, preempt calls to them using a proxy that | ||
# raises an error if read_only is enabled. | ||
def write_protected(*method_names) |
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.
Use 2 (not 4) spaces for indentation.
Code Climate has analyzed commit 380bb0a and detected 9 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 87.4% (-0.7% change). View more on Code Climate. |
read_safe
list return a HTTP 405 Method Not Allowed when invoked, also throwing Conjur error code:CONJ00153E
Desired Outcome
Please describe the desired outcome for this PR. Said another way, what was
the original request that resulted in these code changes? Feel free to copy
this information from the connected issue.
Implemented Changes
Describe how the desired outcome above has been achieved with this PR. In
particular, consider:
Connected Issue/Story
Resolves #[relevant GitHub issue(s), e.g. 76]
CyberArk internal issue ID: [insert issue ID]
Definition of Done
At least 1 todo must be completed in the sections below for the PR to be
merged.
Changelog
CHANGELOG update
Test coverage
changes, or
Documentation
README
s) were updated in this PRBehavior
Security