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
VAULT-6433: Add namespace path to MFA read/list endpoints #16911
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
api/mfa: Add namespace path to the MFA read/list endpoint | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1361,6 +1361,10 @@ func (b *LoginMFABackend) mfaLoginEnforcementConfigByNameAndNamespace(name, name | |
func (b *LoginMFABackend) mfaLoginEnforcementConfigToMap(eConfig *mfa.MFAEnforcementConfig) (map[string]interface{}, error) { | ||
resp := make(map[string]interface{}) | ||
resp["name"] = eConfig.Name | ||
ns, err := b.namespacer.NamespaceByID(context.Background(), eConfig.NamespaceID) | ||
if ns != nil && err == nil { | ||
resp["namespace_path"] = ns.Path | ||
} | ||
resp["namespace_id"] = eConfig.NamespaceID | ||
resp["mfa_method_ids"] = append([]string{}, eConfig.MFAMethodIDs...) | ||
resp["auth_method_accessors"] = append([]string{}, eConfig.AuthMethodAccessors...) | ||
|
@@ -1417,6 +1421,10 @@ func (b *MFABackend) mfaConfigToMap(mConfig *mfa.Config) (map[string]interface{} | |
respData["id"] = mConfig.ID | ||
respData["name"] = mConfig.Name | ||
respData["namespace_id"] = mConfig.NamespaceID | ||
ns, err := b.namespacer.NamespaceByID(context.Background(), mConfig.NamespaceID) | ||
if ns != nil && err == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comment about error handling here |
||
respData["namespace_path"] = ns.Path | ||
} | ||
|
||
return respData, nil | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we handle the error if it is not nil?
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.
I'm not really sure - I don't like failing silently but similarly, the endpoint wouldn't have complained before and would have e.g. returned error, so I thought it best to keep the previous behaviour somewhat consistent (i.e. not introducing ways it could fail now where it wouldn't before).
I'm happy to change to e.g. returning the error if you feel it's appropriate!
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.
Yeah, this check is done all over the place. My preference would be to do it here as well. But, I don't have a strong feeling about it.
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.
Updated!
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.
How do you feel about changing this logic to the following instead?
It's a bit more concise, but the same logic, so feel free to ignore :).
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.
Good suggestion, changed!