You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/references/authentication/hmac.md
+62-1
Original file line number
Diff line number
Diff line change
@@ -97,6 +97,63 @@ You can revoke all HMAC Keys with the `revokeAllHmacTokens()` method.
97
97
$user->revokeAllHmacTokens();
98
98
```
99
99
100
+
## Expiring HMAC Keys
101
+
102
+
By default, the HMAC keys don't expire unless they reach the HMAC keys' lifetime expiration after their last use date.
103
+
104
+
HMAC keys can be set to expire through the `generateHmacToken()` method. This takes the expiration date as the `$expiresAt` argument. To update an existing HMAC key expiration date, use `updateHmacTokenExpiration($hmacTokenID, $expiresAt)`. To remove it, use `removeHmacTokenExpiration($hmacTokenID)`.
`isHmacTokenExpired(AccessToken $hmacToken)` - Checks if the HMAC key is expired. Returns `true` if the HMAC key is expired; otherwise, returns `false`.
`canHmacTokenExpire(AccessToken $hmacToken)` - Checks if HMAC key has an expiration set. Returns `true` if the HMAC key is expired; otherwise, returns `false`.
You can also easily set all existing HMAC keys/tokens as expired with the `spark` command:
149
+
```console
150
+
php spark shield:hmac invalidateAll
151
+
```
152
+
153
+
!!! warning
154
+
155
+
This command invalidates _all_ keys for _all_ users.
156
+
100
157
## Retrieving HMAC Keys
101
158
102
159
The following methods are available to help you retrieve a user's HMAC keys:
@@ -217,7 +274,7 @@ Configure **app/Config/AuthToken.php** for your needs.
217
274
218
275
### HMAC Keys Lifetime
219
276
220
-
HMAC Keys/Tokens will expire after a specified amount of time has passed since they have been used.
277
+
HMAC Keys will expire after a specified amount of time has passed since they have been used.
221
278
222
279
By default, this is set to 1 year. You can change this value by setting the `$unusedTokenLifetime`
223
280
value. This is in seconds so that you can use the
@@ -228,6 +285,10 @@ that CodeIgniter provides.
228
285
public $unusedTokenLifetime = YEAR;
229
286
```
230
287
288
+
### HMAC Keys Expiration vs Lifetime
289
+
290
+
Expiration and lifetime are two different concepts. The lifetime is the maximum time allowed for the HMAC Key to exist since its last use. HMAC Key expiration, on the other hand, is a set date in which the HMAC Key will cease to function.
291
+
231
292
### Login Attempt Logging
232
293
233
294
By default, only failed login attempts are recorded in the `auth_token_logins` table.
Copy file name to clipboardExpand all lines: docs/references/authentication/tokens.md
+56-1
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ Configure **app/Config/AuthToken.php** for your needs.
125
125
126
126
### Access Token Lifetime
127
127
128
-
Tokens will expire after a specified amount of time has passed since they have been used.
128
+
Tokens will expire after a specified amount of time has passed since they have last been used.
129
129
130
130
By default, this is set to 1 year.
131
131
You can change this value by setting the `$unusedTokenLifetime` value. This is
@@ -137,6 +137,61 @@ that CodeIgniter provides.
137
137
public $unusedTokenLifetime = YEAR;
138
138
```
139
139
140
+
141
+
## Expiring Access Tokens
142
+
143
+
By default, the Access Tokens don't expire unless they reach the Access Token's lifetime expiration after their last use date.
144
+
145
+
Access Tokens can be set to expire through the `generateAccessToken()` method. This takes the expiration date as the `$expiresAt` argument. To update an existing HMAC key expiration date, use `updateAcessTokenExpiration($accessTokenID, $expiresAt)`. To remove it, use `removeAccessTokenExpiration($accessTokenID)`.
`isAccessTokenExpired(AccessToken $accessToken)` - Checks if Access Token is expired. Returns `true` if the Access Token is expired; otherwise, returns `false`.
Expiration and lifetime are two different concepts. The lifetime is the maximum time allowed for the token to exist since its last use. Token expiration, on the other hand, is a set date in which the Access Token will cease to function.
194
+
140
195
### Login Attempt Logging
141
196
142
197
By default, only failed login attempts are recorded in the `auth_token_logins` table.
0 commit comments