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

UI/database cg read role #12111

Merged
merged 10 commits into from Jul 20, 2021
Merged

UI/database cg read role #12111

merged 10 commits into from Jul 20, 2021

Conversation

hashishaw
Copy link
Contributor

@hashishaw hashishaw commented Jul 16, 2021

Since database roles are coming from two different endpoints, we were doing non-typical things with the ajax request that circumvented our typical control group logic. This makes a few changes that make it easier to take advantage of default behavior, and put in control group checks otherwise:

  • Add type parameter to secret/show page when linked from the list view
  • Only call the relevant query when type is provided on the show page
  • Check for control group consistently between GET credentials and GET role
  • Add type parameter to credentials page (and links to them) so that only one call is made when type is known

Example Scenario where education is a static type role, and readonly is a dynamic type role.

BEFORE Control groups on both roles. Notice that I clicked on a static type role, which should have had control group access for database/static-roles/education
before-cg-fix

AFTER Viewing and credentials on role both work correctly when control groups active on those paths
cg-after-dynamic
cg-after-static

AFTER Known behavior: when a developer only has CG read access for both credential paths as wildcards, or just creds/*:

path "/database/creds/*"
path "/database/static-creds/*"

The dynamic role will work as expected but the static role does not.
wildcard-cg-creds

Workaround options:

  • Update the policy to allow read access on /database/static-roles so the developer can traverse to the correct path
  • Update the policy to use specific paths (eg /database/creds/readonly) rather than wildcards
    • link directly with the roleType param (eg. https://my-vault.dev/ui/vault/secrets/database/credentials/education?roleType=static (example below)
      staticrole-creds-cg-workaround

@hashishaw hashishaw added ui backport bug Used to indicate a potential bug labels Jul 16, 2021
@hashishaw hashishaw added this to the 1.7.4 milestone Jul 16, 2021
@vercel vercel bot temporarily deployed to Preview – vault-storybook July 16, 2021 17:32 Inactive
@vercel vercel bot temporarily deployed to Preview – vault July 16, 2021 17:32 Inactive
if (id) {
return {
...resp,
type: 'dynamic',
Copy link
Contributor

Choose a reason for hiding this comment

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

smart move on adding a type.

Copy link
Contributor

@Monkeychip Monkeychip left a comment

Choose a reason for hiding this comment

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

I really like you're approach on this. Nice work!

@hashishaw hashishaw merged commit 6d0d241 into main Jul 20, 2021
@hashishaw hashishaw deleted the ui/database-cg-read-role branch July 20, 2021 16:28
hashishaw added a commit that referenced this pull request Jul 21, 2021
* Add type param to secret show, handle CG in database role show

* If roleType is passed to credential, only make one creds API call

* Clean up db role adapter and serializer

* url param roleType passed to credentials call

* Role list capabilities check for static and dynamic separately

* Add changelog

* Consistent adapter response for single or double call

* Prioritize dynamic response if control group on role/creds
hashishaw added a commit that referenced this pull request Jul 21, 2021
* Add type param to secret show, handle CG in database role show

* If roleType is passed to credential, only make one creds API call

* Clean up db role adapter and serializer

* url param roleType passed to credentials call

* Role list capabilities check for static and dynamic separately

* Add changelog

* Consistent adapter response for single or double call

* Prioritize dynamic response if control group on role/creds
hashishaw added a commit that referenced this pull request Jul 21, 2021
* Add type param to secret show, handle CG in database role show

* If roleType is passed to credential, only make one creds API call

* Clean up db role adapter and serializer

* url param roleType passed to credentials call

* Role list capabilities check for static and dynamic separately

* Add changelog

* Consistent adapter response for single or double call

* Prioritize dynamic response if control group on role/creds
hashishaw added a commit that referenced this pull request Jul 21, 2021
* UI/database cg read role (#12111)

* Add type param to secret show, handle CG in database role show

* If roleType is passed to credential, only make one creds API call

* Clean up db role adapter and serializer

* url param roleType passed to credentials call

* Role list capabilities check for static and dynamic separately

* Add changelog

* Consistent adapter response for single or double call

* Prioritize dynamic response if control group on role/creds

* UI/database cg read role (#12111)

* Add type param to secret show, handle CG in database role show

* If roleType is passed to credential, only make one creds API call

* Clean up db role adapter and serializer

* url param roleType passed to credentials call

* Role list capabilities check for static and dynamic separately

* Add changelog

* Consistent adapter response for single or double call

* Prioritize dynamic response if control group on role/creds
hashishaw added a commit that referenced this pull request Jul 21, 2021
* Add type param to secret show, handle CG in database role show

* If roleType is passed to credential, only make one creds API call

* Clean up db role adapter and serializer

* url param roleType passed to credentials call

* Role list capabilities check for static and dynamic separately

* Add changelog

* Consistent adapter response for single or double call

* Prioritize dynamic response if control group on role/creds
jartek pushed a commit to jartek/vault that referenced this pull request Sep 11, 2021
* Add type param to secret show, handle CG in database role show

* If roleType is passed to credential, only make one creds API call

* Clean up db role adapter and serializer

* url param roleType passed to credentials call

* Role list capabilities check for static and dynamic separately

* Add changelog

* Consistent adapter response for single or double call

* Prioritize dynamic response if control group on role/creds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport bug Used to indicate a potential bug ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants