Skip to content
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 message to whoami command #2061

Merged
merged 1 commit into from
Mar 10, 2021
Merged

Conversation

amosmintzcyberark
Copy link
Contributor

@amosmintzcyberark amosmintzcyberark commented Mar 7, 2021

What does this PR do?

adding audit for whoami REST command.

What ticket does this PR close?

Resolves #2052

Checklists

Change log

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR, and/or there is a follow-on issue to update docs, or
  • This PR does not require updating any documentation

API Changes

  • The OpenAPI spec has been updated to meet new API changes (or an issue has been opened), or
  • The changes in this PR do not affect the Conjur API

Copy link
Contributor

@egvili egvili left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good!
I left some comments.
2 more general comments:

  1. The ticket to use for the PR should be Git ticket. You can use Rspec Unit Tests are Present for Existing Audit Events #1987
  2. Please pay attention to Code Climate comments and fix wherever possible

client_ip: request.ip,
user_agent: request.user_agent,
account: token_user.account,
username: token_user.login,
token_issued_at: Time.at(token_user.token.claims["iat"])
}
end

def audit_success
@role = ::Role.by_login(token_user.login, account: token_user.account)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to define role as class member (with @)? Maybe it can be a simple variable?

end

def message
"#{@role_id.role_id} checked identity using WhoAmI"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ask from @shulifink to review this text

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding @egvili 's comment:

  1. The ticket to use for the PR should be Git ticket. You can use Rspec Unit Tests are Present for Existing Audit Events #1987

There's a dedicated ticket for this: #2052

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ask from @shulifink to review this text
she already did.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wouldn't write WhoAmI but whoami as this is the command. Also - checked its identity seems better.
In summary, i think we should write #{@role_id.role_id} checked its identity using the whoami command

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text was already reviewed and changed by Chuli, so, I'm not sure about changing it again.

@amosmintzcyberark
Copy link
Contributor Author

amosmintzcyberark commented Mar 7, 2021 via email

@amosmintzcyberark amosmintzcyberark changed the title Onyx 7549 whoami audit Add audit message to whoami command Mar 8, 2021
Copy link
Member

@orenbm orenbm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments

end

def role_id
return nil if @role.nil?
Copy link

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this

end

def role_id
return nil if @role.nil?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audit::Event::Whoami#role_id performs a nil-check

Copy link
Member

@orenbm orenbm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments

CHANGELOG.md Outdated
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- `/whoami` API endpoint now produce audit events.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shulifink please review

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this change be placed in Appliance repo CHANGELOG.md? @netacoral

uCatu
uCatu previously approved these changes Mar 9, 2021
CHANGELOG.md Outdated
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- `/whoami` API endpoint now produce audit events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `/whoami` API endpoint now produce audit events.
- `/whoami` API endpoint now produces audit events.

orenbm
orenbm previously approved these changes Mar 9, 2021
@amosmintzcyberark amosmintzcyberark requested a review from orenbm March 9, 2021 15:45
@amosmintzcyberark amosmintzcyberark force-pushed the ONYX-7549-whoami-audit branch 2 times, most recently from cc61029 to 38ce372 Compare March 9, 2021 16:20
@codeclimate
Copy link

codeclimate bot commented Mar 9, 2021

Code Climate has analyzed commit f71c65d and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

The test coverage on the diff in this pull request is 94.2% (50% is the threshold).

This pull request will bring the total coverage in the repository to 89.3% (0.0% change).

View more on Code Climate.

@amosmintzcyberark amosmintzcyberark merged commit 7caefeb into master Mar 10, 2021
@amosmintzcyberark amosmintzcyberark deleted the ONYX-7549-whoami-audit branch March 10, 2021 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audit log for WhoAmI request
6 participants