File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,20 @@ use Rollerworks\Component\SplitToken\Argon2SplitTokenFactory;
60
60
// the FakeSplitTokenFactory instead as cryptographic operations
61
61
// can a little heavy.
62
62
63
- $splitTokenFactory = new Argon2SplitTokenFactory();
63
+ // Default configuration, shown here for clarity.
64
+ $config = [
65
+ 'memory_cost' => \PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
66
+ 'time_cost' => \PASSWORD_ARGON2_DEFAULT_TIME_COST,
67
+ 'threads' => \PASSWORD_ARGON2_DEFAULT_THREADS,
68
+ ];
69
+
70
+ // Either a DateInterval or a DateInterval parsable-string
71
+ $defaultLifeTime = null;
72
+
73
+ $splitTokenFactory = new Argon2SplitTokenFactory(/*config: $config, */ $defaultLifeTime);
74
+
75
+ // Optionally set PSR/Clock compatible instance
76
+ // $splitTokenFactory->setClock();
64
77
65
78
// Step 1. Create a new SplitToken for usage
66
79
@@ -81,6 +94,7 @@ $authToken = $token->token(); // Returns a \ParagonIE\HiddenString\HiddenString
81
94
// Indicate when the token must expire. Note that you need to clear the token from storage yourself.
82
95
// Pass null (or leave this method call absent) to never expire the token (not recommended).
83
96
//
97
+ // If not provided uses "now" + $defaultLifeTime of the factory constructor.
84
98
$authToken->expireAt(new \DateTimeImmutable('+1 hour'));
85
99
86
100
// Now to store the token cast the SplitToken to a SplitTokenValueHolder object.
You can’t perform that action at this time.
0 commit comments