-
Notifications
You must be signed in to change notification settings - Fork 125
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 Audit Event for Password Change #1600
Conversation
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.
This looks terrific. All comments minor.
c7d95d2
to
d79dcdf
Compare
39f482e
to
c6dc923
Compare
778457d
to
2097a84
Compare
c6dc923
to
e21b0f7
Compare
2097a84
to
c03026f
Compare
20183c8
to
c72245a
Compare
455b52b
to
e2569b8
Compare
2991100
to
087643f
Compare
99c9b02
to
abf59b4
Compare
893a2af
to
b2625a1
Compare
2369fad
to
b1b4e90
Compare
fce8b5d
to
c752227
Compare
ce31fcc
to
eb2622c
Compare
module Credentials | ||
|
||
ChangePassword ||= CommandClass.new( | ||
dependencies: {}, |
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.
Two problems here:
- A CommandClass with no dependencies doesn't make any sense, conceptually.
- We actually do have dependencies here, but they sneak in implicitly via our input, namely the
role
. Specifically,credentials.save(raise_on_save_failure: true)
is a database interaction.
Unfortunately, I think fixing this would require completely reworking the credentials controller, which will be too big of a sidetrack right now.
I recommend instead that we keep your code mostly as is, but just make it an ordinary object rather than a CommandClass
, and add a comment to a placeholder issue for refactoring the controller. This will allow your test code to remain unchanged, or close to it as well.
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.
So the way this is set up, with factoring out the command class first, and then adding audit to it, it only appears to have no dependencies in this step.
The audit log is added in the next commit as a dependency to this command class.
Does this change your assessment at all?
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.
Could you share, hypothetically, what your ideal command class for this would look like (even in just pseudocode)? If you could have exactly what you wanted as inputs from the CredentialsController?
That would help me better grasp what the desired end state would be from your perspective.
# Expect the command to raise the original exception | ||
expect { subject.call(role: role, password: password) }.to raise_error(err_message) | ||
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.
Given the existing code, and our decision to delay changing it, these tests look perfect.
dependencies: {}, | ||
dependencies: { | ||
audit_log: ::Audit.logger | ||
}, |
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.
Ok so this somewhat changes my comment on previous commit, but it remains the case that one of our dependencies is still sneaking in through the input.
My recommendation might change now to:
- Keep the command class.
- Add a comment stating the problem above dependencies and inputs and link to issue.
de62ac8
to
866a567
Compare
This provides a better base for adding audit to password change events.
866a567
to
29dede2
Compare
Code Climate has analyzed commit 29dede2 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 97.7% (50% is the threshold). This pull request will bring the total coverage in the repository to 85.8% (0.0% change). View more on Code Climate. |
NOTE: This PR is blocked until the parent branch is merged.
What does this PR do?
This PR adds an audit log message for password changes events using the API endpoint
PUT /authn/:account/password
The container image
registry.tld/conjur-appliance:5.9.0-20200610203923-d5e10a1
may be used to evaluate this change manually, for example in dap-intro.Successful Password Change:
Failed Password Change:
https://jenkins.conjur.net/job/conjurinc--appliance/job/1548-audit-password-change/
What ticket does this PR close?
Connected to #1548
Checklists
Change log
Test coverage
Documentation
README
s) were updated in this PR, and/or there is a follow-on issue to update docsR&D Docs (
dap-wiki
) PR: cyberark/dap-wiki#29