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

Add cache-based challenge manager #30

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

Firehed
Copy link
Owner

@Firehed Firehed commented Aug 28, 2023

Thus far, it's been up to library users to manage challenges. This provides flexibility, but risks introducing security vulnerabilities as it's critical that challenges are used once and only once in order to avoid replay attacks.

This adds classes that manage challenges in a way that significantly de-risks this:

  • They're generated with time limits
  • They're "consumed" from their storage system during the verification flows, ensuring read-once behavior.

@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

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

Comparison is base (f63d2a7) 79.37% compared to head (4690a0f) 79.96%.

Files Patch % Lines
src/CacheChallengeManager.php 90.32% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #30      +/-   ##
============================================
+ Coverage     79.37%   79.96%   +0.58%     
- Complexity      170      178       +8     
============================================
  Files            24       25       +1     
  Lines           548      579      +31     
============================================
+ Hits            435      463      +28     
- Misses          113      116       +3     

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

@Firehed Firehed marked this pull request as ready for review August 28, 2023 20:54
Firehed added a commit that referenced this pull request Nov 2, 2023
The examples so far have all used sessions to manage the active
challenges, but not all applications are stateful in this way - namely,
most APIs will not be session-based.

Instead, this creates a new `ChallengeManagerInterface` that handles
this for applications. For now there's a single implementation that's
still session-based, though (via #30 which I'm reworking) other
implementations will be provided (e.g. a cache pool).

The majority of the change here is updating examples and adding tests.
Note that this would be a BC break but since the library is still
pre-1.0 it's not a concern for practical purposes.
@Firehed Firehed changed the title Add tooling to simplify challenge management Add cache-based challenge manager Nov 2, 2023
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.

None yet

1 participant