TBD54566975 / dwn-server

DWN server - host anywhere publicly accessible for DIDs to use
Apache License 2.0
40 stars 41 forks source link

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

Closed finn-tbd closed 9 months ago

finn-tbd commented 11 months ago

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.

codesandbox[bot] commented 11 months ago

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview

codecov-commenter commented 11 months ago

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 :warning:
src/storage.ts 94.73% 1 Missing :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

LiranCohen commented 9 months ago

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.