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

Registration Gating (Proof-of-Work, Terms of Service) #87

Merged
merged 30 commits into from
Jan 17, 2024
Merged

Conversation

finn-block
Copy link
Collaborator

@finn-block finn-block commented Nov 8, 2023

This PR adds optional (disabled by default) authorization to all endpoints. New DIDs wishing to use an instance of dwn-server with registration requirements must complete a proof-of-work challenge, agree to the server's terms of service, or both. Requests for DIDs that have not completed the requirements will be rejected.

POW authorization can be enabled by setting DWN_REGISTRATION_POW=true. Authorized DIDs are tracked in a database, configured by setting DWN_STORAGE_REGISTRATION or DWN_STORAGE. Note that only SQL-based stores are supported.

Copy link

codesandbox bot commented Nov 8, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (c372d25) 80.50% compared to head (b36d176) 91.24%.

Files Patch % Lines
src/http-api.ts 93.10% 6 Missing ⚠️
src/storage.ts 94.73% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #87       +/-   ##
===========================================
+ Coverage   80.50%   91.24%   +10.73%     
===========================================
  Files          15       20        +5     
  Lines         985     1702      +717     
  Branches       97      204      +107     
===========================================
+ Hits          793     1553      +760     
+ Misses        192      149       -43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@finn-block finn-block changed the title Proof-of-Work for Registration Registration Gating (Proof-of-Work, Terms of Service) Nov 17, 2023
…complete some tasks before they may user the server.

proof of work challenge and terms of service challenges are currently available
@finn-block finn-block marked this pull request as ready for review November 17, 2023 23:10
* main:
  Disambiguated the data folder of test-dwn.ts
  Updated `dwn-sdk-js` and `dwn-sql-store` dependencies + v0.1.8 (#95)
  feat: introduce npx
  bump dwn version and release new server version (#93)
  bump dwn sdk to v0.2.7 (#92)
  add Henry to CODEOWNERS
  fix CODEOWNERS formatting, add Liran as code owner
* main:
  bump dwn-sql-store version and dwn-server (#98)
clock.restore();
});

it('should facilitate tenant registration with terms-of-service and proof-or-work turned on', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@shamilovtim, this shows how tenant registration is done!

@LiranCohen
Copy link
Member

I've given it a first pass (minus the tests) and it looks good so far when analyzing the individual pieces. Want to spend a little more time today re-reviewing the PoW calculation pieces and giving it a last pass including tests.

Just a few small nits and questions above.

src/http-api.ts Outdated Show resolved Hide resolved
src/registration/proof-of-work-manager.ts Show resolved Hide resolved
src/registration/proof-of-work-manager.ts Show resolved Hide resolved
src/registration/proof-of-work-manager.ts Outdated Show resolved Hide resolved
src/registration/proof-of-work-manager.ts Outdated Show resolved Hide resolved
src/registration/proof-of-work-manager.ts Outdated Show resolved Hide resolved
src/registration/proof-of-work-manager.ts Outdated Show resolved Hide resolved
src/registration/proof-of-work-manager.ts Show resolved Hide resolved
Copy link
Member

@LiranCohen LiranCohen left a comment

Choose a reason for hiding this comment

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

Just a few small nits in the tests.

This looks good, and the added TODOs will make it even better when necessary. 🚀 🐐

tests/http-api.spec.ts Outdated Show resolved Hide resolved
tests/registration/proof-of-work-manager.spec.ts Outdated Show resolved Hide resolved
tests/registration/proof-of-work-manager.spec.ts Outdated Show resolved Hide resolved
tests/registration/proof-of-work-manager.spec.ts Outdated Show resolved Hide resolved
tests/scenarios/registration.spec.ts Show resolved Hide resolved
Copy link
Member

@LiranCohen LiranCohen left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@thehenrytsai thehenrytsai merged commit 60b0336 into main Jan 17, 2024
8 checks passed
@thehenrytsai thehenrytsai deleted the pow branch January 17, 2024 02:31
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.

4 participants