Inklings-io / selfauth

self-hosted auth_endpoint using simple login mechanism
Creative Commons Zero v1.0 Universal
81 stars 15 forks source link

Use HMAC functions for codes #11

Closed Zegnat closed 7 years ago

Zegnat commented 7 years ago

This replaces generate_csrf_code and generate_code with just 1 flexible function. And of course the same for verify_csrf_code and verify_code.

  1. Use HMAC, which is what you want to verify integrity and authentication of a code.
  2. No more “valid for between x and y minutes”, exact time-to-live values are baked into the code.
  3. Can include additional data that has to be included in the code and can’t be part of the message. In our case, scope has to be included because the stateless selfauth can’t verify it otherwise.

Please review before merging so we are sure nothing blows up. I have been able to correctly authenticate to Telegraph with this.