x/macaroon
The Macaroon module is responsible for providing decentralized access control and service authorization for the Sonr ecosystem. It implements macaroon-based authentication and authorization mechanisms.
Concepts
Macaroons are a type of bearer credential that allow for decentralized delegation, attenuation, and third-party caveats. This module implements the core functionality for creating, validating, and managing macaroons within the Sonr ecosystem.
State
The module maintains the following state:
Grant
Represents a permission grant with the following fields:
id
: Unique identifier (auto-incremented)controller
: Address of the controllersubject
: Subject of the grantorigin
: Origin of the grantexpiry_height
: Block height at which the grant expires
Macaroon
Represents a macaroon token with the following fields:
id
: Unique identifier (auto-incremented)controller
: Address of the controllersubject
: Subject of the macaroonorigin
: Origin of the macaroonexpiry_height
: Block height at which the macaroon expiresmacaroon
: The actual macaroon token
State Transitions
State transitions occur through the following messages:
MsgUpdateParams
: Updates the module parametersMsgIssueMacaroon
: Issues a new macaroon
Messages
MsgUpdateParams
Updates the module parameters. Can only be executed by the governance account.
Fields:
authority
: Address of the governance accountparams
: New parameter values
MsgIssueMacaroon
Issues a new macaroon for a given controller and origin.
Fields:
controller
: Address of the controllerorigin
: Origin of the request in wildcard formpermissions
: Map of permissionstoken
: Macaroon token to authenticate the operation
Queries
The module provides the following queries:
Params
: Retrieves the current module parametersRefreshToken
: Refreshes a macaroon token (post-authentication)ValidateToken
: Validates a macaroon token (pre-authentication)
Parameters
The module has the following parameters:
methods
: Defines the available DID methodsdefault
: Default methodsupported
: List of supported methods
scopes
: Defines the set of scopesbase
: Base scopesupported
: List of supported scopes
caveats
: Defines the available caveatssupported_first_party
: List of supported first-party caveatssupported_third_party
: List of supported third-party caveats
transactions
: Defines the allowlist and denylist for transactionsallowlist
: List of allowed transactionsdenylist
: List of denied transactions
Events
The module may emit events related to macaroon issuance, validation, and refreshing. (Specific event details to be implemented)
Client
The module provides gRPC endpoints for all queries and message types defined in the protobuf files.
Future Improvements
- Implement more advanced caveat types
- Add support for third-party caveats
- Enhance macaroon revocation mechanisms
- Implement additional security features and checks
Tests
(To be implemented: Acceptance tests for the module's functionality)
Appendix
For more information on macaroons and their implementation, refer to the original macaroon paper: "Macaroons: Cookies with Contextual Caveats for Decentralized Authorization in the Cloud" by Arnar Birgisson, et al.