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

contract auth #598

Merged
merged 33 commits into from
Dec 2, 2021
Merged

contract auth #598

merged 33 commits into from
Dec 2, 2021

Conversation

tbfleming
Copy link
Member

@tbfleming tbfleming commented Nov 4, 2021

Add contract auth support

Phase 1 (this PR): Only actions which support session keys are dispatchable through the run action. All actions support the normal dispatch.

Phase 2 (future): All actions will be dispatchable through the run action. Ones which don't support session keys will require account_auth or no_auth; they won't support signature_auth. TBD if this really happens.

Phase 3 (future): Normal dispatch will be disabled for actions other than newsession and run. TBD if this really happens.

@tbfleming tbfleming temporarily deployed to e2e_tests November 4, 2021 00:12 Inactive
@tbfleming tbfleming temporarily deployed to e2e_tests November 5, 2021 23:21 Inactive
@tbfleming tbfleming temporarily deployed to e2e_tests November 6, 2021 17:16 Inactive
@tbfleming tbfleming temporarily deployed to e2e_tests November 6, 2021 18:50 Inactive
@tbfleming tbfleming marked this pull request as ready for review November 16, 2021 14:43
@tbfleming tbfleming temporarily deployed to e2e_tests November 16, 2021 14:50 Inactive
auto& sessions = sc.sessions();
for (auto& session : sessions)
if (session.expiration <= now)
push_event(session_del_event{sc.eden_account(), session.key}, contract);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this excessively exposes implementation details. The contract behaves (or should behave) as if the session key is automatically removed when the expiration passes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm split. It makes sense for the history side to be aware of that, but we were bitten recently by the history side knowing those things.

contracts/eden/src/actions/sessions.cpp Show resolved Hide resolved
eosio::public_key key;
eosio::block_timestamp expiration;
std::string description;
std::vector<eosio::varuint32> sequences;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to document clearly that it is unsafe to reuse session keys. The contract does not prevent reuse.

contracts/eden/src/actions/sessions.cpp Outdated Show resolved Hide resolved
Comment on lines 91 to 94
void execsession(const eosio::signature& signature,
eosio::ignore<eosio::name> eden_account,
eosio::ignore<eosio::varuint32> sequence,
eosio::ignore<std::vector<action>> actions);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like this interface much

  • The requirement of assigning unique sequential integers to the actions is ugly
  • It doesn't allow authorization actions on a different contract, which could become a problem if we do need to put functionality into a separate contract. I'd prefer to see std::vector<eosio::action> or even eosio::transaction
  • The fact that there is one action that can behave the same as many other actions makes filtering harder. Ideally, I'd like to see this run the other actions as inline actions.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we come up with an alternative, I don't want it to sacrifice the ability of existing history tools to create a human-readable decoding of the original request. Right now they can use ABI decoding to show what's in the action vector.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For history purposes,I don't see why it's important that the original request is human readable vs. having a human readable decoding in the trace. Having the original request human readable is normally critical for signing, but that's not an issue here.

Copy link
Collaborator

@sparkplug0025 sparkplug0025 Nov 19, 2021

Choose a reason for hiding this comment

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

a human readable decoding in the trace

I like this too, starting to look good... but still hard to digest in block explorer (needs to open the transactions first and then look for traces)

contracts/eden/src/eden-micro-chain.cpp Outdated Show resolved Hide resolved
libraries/eosiolib/contracts/include/eosio/action.hpp Outdated Show resolved Hide resolved
@tbfleming tbfleming temporarily deployed to e2e_tests November 24, 2021 21:07 Inactive
@tbfleming tbfleming temporarily deployed to e2e_tests November 24, 2021 22:44 Inactive
@tbfleming tbfleming temporarily deployed to e2e_tests November 25, 2021 00:19 Inactive
@tbfleming tbfleming temporarily deployed to e2e_tests November 30, 2021 16:27 Inactive
@tbfleming tbfleming temporarily deployed to e2e_tests November 30, 2021 20:09 Inactive
@tbfleming tbfleming merged commit baf61ee into main Dec 2, 2021
@tbfleming tbfleming deleted the contract-auth branch December 2, 2021 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants