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

Implements role parameter in check command in API #153

Merged
merged 4 commits into from
Jan 26, 2023

Conversation

juniortaeza
Copy link
Contributor

@juniortaeza juniortaeza commented Jan 10, 2023

Desired Outcome

This pull request implements the API side of adding the role parameter into the 'check' command for the Go CLI.

Implemented Changes

  • Updated API endpoint for 'check'
  • Updated tests for API endpoint

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

Changelog (need a Changelog)

  • 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
  • A follow-up issue to update official docs has been filed here: insert issue ID
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

@juniortaeza juniortaeza requested a review from a team as a code owner January 10, 2023 16:34
conjurapi/client.go Outdated Show resolved Hide resolved
conjurapi/resource_test.go Outdated Show resolved Hide resolved
conjurapi/resource_test.go Outdated Show resolved Hide resolved
@juniortaeza juniortaeza force-pushed the check-role-api-branch branch from dbaae4b to 0186678 Compare January 12, 2023 16:50
conjurapi/client.go Outdated Show resolved Hide resolved
conjurapi/resource_test.go Outdated Show resolved Hide resolved
conjurapi/resource_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@doodlesbykumbi doodlesbykumbi left a comment

Choose a reason for hiding this comment

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

Left a few comments. Otherwise I think this has the behaviour we want

conjurapi/client.go Outdated Show resolved Hide resolved
conjurapi/client.go Outdated Show resolved Hide resolved
@@ -16,8 +16,8 @@ type ResourceFilter struct {

// CheckPermission determines whether the authenticated user has a specified privilege
// on a resource.
func (c *Client) CheckPermission(resourceID, privilege string) (bool, error) {
req, err := c.CheckPermissionRequest(resourceID, privilege)
func (c *Client) CheckPermission(resourceID string, roleID string, privilege string) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking maybe we should retain CheckPermission and introduce CheckPermissionForRole. Something off about giving special meaning to roleId being an empty string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Implemented CheckPermissionForRole and CheckPermissionForRoleRequest

Comment on lines 697 to 699
if tokens[0] != c.config.Account {
return "", "", "", fmt.Errorf("Account of '%s' must match the configured account '%s'", id, c.config.Account)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be too strict and we likely don't have to do this. Mainly because I'm still not 100% sure if it's not possible to make permission queries across accounts.

Copy link
Contributor

@john-odonnell john-odonnell Jan 25, 2023

Choose a reason for hiding this comment

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

I pulled this error case from the RotateApiKeyRequest implementation - is this validation required in that context, or can it be removed all together? (EDIT: pulled out the error either way)

When an account is not specified, the configured
account is used.
@codeclimate
Copy link

codeclimate bot commented Jan 26, 2023

Code Climate has analyzed commit 4d89632 and detected 4 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 4

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

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

View more on Code Climate.

Copy link
Contributor

@szh szh left a comment

Choose a reason for hiding this comment

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

LGTM!

@john-odonnell john-odonnell dismissed their stale review January 26, 2023 16:25

Took on this PR myself and addressed my own suggestions

@john-odonnell john-odonnell merged commit 5da6569 into main Jan 26, 2023
@john-odonnell john-odonnell deleted the check-role-api-branch branch January 26, 2023 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants