-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
x/authz: audit updates #9042
Merged
Merged
x/authz: audit updates #9042
Changes from 39 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
7833410
x/authz: audit updates
robert-zaremba 45a9ee3
audit with Aaron
robert-zaremba 83780d3
authz: Update Authorization.Accept method
robert-zaremba d258480
authz: add event proto definitions
robert-zaremba 8de54d0
update query service
robert-zaremba a721a97
authz: use typed events
robert-zaremba 0f6158f
refactore and rename query authorizations
robert-zaremba 5e029a8
remve Authorization infix from proto services
robert-zaremba 424af8f
renames wip
robert-zaremba 3876db2
refactoring
robert-zaremba c85574b
update tests
robert-zaremba 55ce5b8
fix compilation
robert-zaremba 385205a
fixing gRPC query tests
robert-zaremba 94776a9
Merge branch 'master' into robert/authz-audit
robert-zaremba 90da7b6
fix simulation tests
robert-zaremba bf42888
few renames
robert-zaremba afb9e8f
more refactore
robert-zaremba 46d547d
add missing file
robert-zaremba 7e9e325
moving export genesis to keeper
robert-zaremba 2d5b037
Update docs
robert-zaremba 5639620
update tests
robert-zaremba fc048d0
rename event Msg attribute to MsgTypeURL
robert-zaremba 155913e
Upate Authorization interface
robert-zaremba c1b077c
rollback Makefile changes
robert-zaremba 3ca0a98
fix tests
robert-zaremba a14a0c8
Apply suggestions from code review
robert-zaremba eda3fc4
Merge branch 'master' into robert/authz-audit
robert-zaremba 46635db
renames
robert-zaremba f73ab9e
refactore authz/exported
robert-zaremba 90329fc
lint fix
robert-zaremba 2465221
authz/types refactore
robert-zaremba 51b5e12
Merge remote-tracking branch 'origin/master' into robert/authz-audit
robert-zaremba 79a69d3
comment update
robert-zaremba d6e9708
Merge branch 'master' into robert/authz-audit
robert-zaremba 8320e4e
conflict updates
robert-zaremba b589571
Apply suggestions from code review
robert-zaremba a813d40
authz: move storage keys to keeper
robert-zaremba b5209b6
review updates
robert-zaremba ead0ee8
docs update
robert-zaremba a4bd3d9
Update x/authz/client/cli/query.go
robert-zaremba 6050e1e
move codec to the root package
robert-zaremba 2708696
Merge remote-tracking branch 'origin/master' into robert/authz-audit
robert-zaremba b7403e8
authz CMD info update
robert-zaremba 52bc0b1
comment update
robert-zaremba 059982c
update imports and build flags
robert-zaremba 4218389
fix functional tests
robert-zaremba 2e8caf5
update proto comment
robert-zaremba 94b6c9f
fix tests
robert-zaremba e64b659
Merge branch 'master' into robert/authz-audit
robert-zaremba 47324d4
fix test
robert-zaremba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
syntax = "proto3"; | ||
package cosmos.authz.v1beta1; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; | ||
|
||
// EventGrant is emitted on Msg/Grant | ||
message EventGrant { | ||
// Msg type URL for which an autorization is granted | ||
string msg_type_url = 2; | ||
// Granter account address | ||
string granter = 3; | ||
// Grantee account address | ||
string grantee = 4; | ||
} | ||
|
||
// EventRevoke is emitted on Msg/Revoke | ||
message EventRevoke { | ||
// Msg type URL for which an autorization is revoked | ||
string msg_type_url = 2; | ||
// Granter account address | ||
string granter = 3; | ||
// Grantee account address | ||
string grantee = 4; | ||
} |
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
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
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
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
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,49 @@ | ||
package authz | ||
|
||
import ( | ||
"time" | ||
|
||
proto "github.com/gogo/protobuf/proto" | ||
|
||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
// NewGrant returns new AuthrizationGrant | ||
func NewGrant(authorization Authorization, expiration time.Time) (Grant, error) { | ||
auth := Grant{ | ||
Expiration: expiration, | ||
} | ||
msg, ok := authorization.(proto.Message) | ||
if !ok { | ||
return Grant{}, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", authorization) | ||
} | ||
|
||
any, err := cdctypes.NewAnyWithValue(msg) | ||
if err != nil { | ||
return Grant{}, err | ||
} | ||
|
||
auth.Authorization = any | ||
|
||
return auth, nil | ||
} | ||
|
||
var ( | ||
_ cdctypes.UnpackInterfacesMessage = &Grant{} | ||
) | ||
|
||
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces | ||
func (auth Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { | ||
var authorization Authorization | ||
return unpacker.UnpackAny(auth.Authorization, &authorization) | ||
} | ||
|
||
// GetAuthorization returns the cached value from the Grant.Authorization if present. | ||
func (auth Grant) GetAuthorization() Authorization { | ||
authorization, ok := auth.Authorization.GetCachedValue().(Authorization) | ||
if !ok { | ||
return nil | ||
} | ||
return authorization | ||
} |
Oops, something went wrong.
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.
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.
Or... we could alternatively consider this approach if we wanted to go with this https://github.com/cosmos/cosmos-sdk/pull/9042/files#r619348288
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.
The first suggestion won't work - see #9042 (comment)
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.
If we use
google.protobuf.Any msg = 1;
, what should its value hold? asaict, only the type_url is needed, so in order to store minimum stuff (and also not to confuse users), I prefer to keep string.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.
Let's just use
string msg_type_url
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 using
msg
because it allows to useMsgTypeURL
as method name in theAuthorization
interface (which, imho is more in Go style and more "straight"). Amaury suggested to useGetMsgTypeURL
as an alternative. If you have a preference then let me know.