Skip to content

Commit 267f9ff

Browse files
committed
fix docs and comments.
fix updateHmacTokenExpiration() token refresh.
1 parent 97615b5 commit 267f9ff

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

docs/references/authentication/hmac.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ $user->revokeAllHmacTokens();
9999

100100
## Expiring HMAC Keys
101101

102-
By default, the HMAC keys don't expire unless they meet the HMAC Keys lifetime expiration after their last used date.
102+
By default, the HMAC keys don't expire unless they reach the HMAC keys' lifetime expiration after their last use date.
103103

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)` and to remove `removeHmacTokenExpiration($hmacTokenID)`.
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)`.
105105

106106
`$expiresAt` [Time](https://codeigniter.com/user_guide/libraries/time.html) object
107107

@@ -124,7 +124,7 @@ $user->removeHmacTokenExpiration($token->id);
124124

125125
The following support methods are also available:
126126

127-
`isHmacTokenExpired(AccessToken $HmacToken)` - Checks if the HMAC key is expired. Returns `true` if the HMAC key is expired, `false` if not.
127+
`isHmacTokenExpired(AccessToken $hmacToken)` - Checks if the HMAC key is expired. Returns `true` if the HMAC key is expired; otherwise, returns `false`.
128128

129129
```php
130130
$expiresAt = Time::parse('2024-11-03 12:00:00');
@@ -133,7 +133,7 @@ $token = $this->user->generateHmacToken('foo', ['foo.bar'], $expiresAt);
133133
$this->user->isHmacTokenExpired($token); // Returns true
134134
```
135135

136-
`hasHmacTokenExpiry(AccessToken $HmacToken)` - Checks if HMAC key has an expiration set. Returns `true` or `false` accordingly.
136+
`hasHmacTokenExpiry(AccessToken $hmacToken)` - Checks if HMAC key has an expiration set. Returns `true` if the HMAC key is expired; otherwise, returns `false`.
137137

138138
```php
139139
$expiresAt = Time::parse('2024-11-03 12:00:00');
@@ -287,7 +287,7 @@ public $unusedTokenLifetime = YEAR;
287287

288288
### HMAC Keys Expiration vs Lifetime
289289

290-
Expiration and Lifetime are 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.
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.
291291

292292
### Login Attempt Logging
293293

docs/references/authentication/tokens.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ public $unusedTokenLifetime = YEAR;
140140

141141
## Expiring Access Tokens
142142

143-
By default, the Access Tokens don't expire unless they meet the Access Token lifetime expiration after their last used date.
143+
By default, the Access Tokens don't expire unless they reach the Access Token's lifetime expiration after their last use date.
144144

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($hmacTokenID, $expiresAt)` and to remove `removeAccessTokenExpiration($hmacTokenID)`.
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)`.
146146

147147
`$expiresAt` [Time](https://codeigniter.com/user_guide/libraries/time.html) object
148148

@@ -165,7 +165,7 @@ $user->removeAccessTokenExpiration($token->id);
165165

166166
The following support methods are also available:
167167

168-
`isAccessTokenExpired(AccessToken $accessToken)` - Checks if Access Token is expired. Returns `true` if the Access Token is expired, `false` if not.
168+
`isAccessTokenExpired(AccessToken $accessToken)` - Checks if Access Token is expired. Returns `true` if the Access Token is expired; otherwise, returns `false`.
169169

170170
```php
171171
$expiresAt = Time::parse('2024-11-03 12:00:00');
@@ -175,7 +175,7 @@ $token = $this->user->generateAccessToken('foo', ['foo.bar'], $expiresAt);
175175
$this->user->isAccessTokenExpired($token); // Returns true
176176
```
177177

178-
`hasAccessTokenExpiry(AccessToken $HmacToken)` - Checks if Access Token has an expiration set. Returns `true` or `false` accordingly.
178+
`hasAccessTokenExpiry(AccessToken $accessToken)` - Returns `true` if the Access Token has a set expiration date; otherwise, returns `false`.
179179

180180
```php
181181
$expiresAt = Time::parse('2024-11-03 12:00:00');
@@ -190,7 +190,7 @@ $this->user->hasAccessTokenExpiry($token); // Returns true
190190

191191
### Access Token Expiration vs Lifetime
192192

193-
Expiration and Lifetime are 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.
193+
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.
194194

195195
### Login Attempt Logging
196196

src/Authentication/Traits/HasHmacTokens.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@ public function setHmacToken(?AccessToken $accessToken): self
162162
}
163163

164164
/**
165-
* Checks if the provided Access Token is expired.
165+
* Checks if the provided HMAC Token is expired.
166166
*/
167-
public function isHmacTokenExpired(AccessToken $accessToken): bool
167+
public function isHmacTokenExpired(AccessToken $hmacToken): bool
168168
{
169-
return $accessToken->expires !== null && $accessToken->expires->isBefore(Time::now());
169+
return $hmacToken->expires !== null && $hmacToken->expires->isBefore(Time::now());
170170
}
171171

172172
/**
173173
* Sets an expiration for HMAC token by ID.
174174
*
175-
* @param int $id AccessToken ID
175+
* @param int $id HMAC Token ID
176176
* @param Time $expiresAt Expiration date
177177
*
178178
* @return bool Returns true if expiration date is set or updated.
@@ -184,8 +184,8 @@ public function updateHmacTokenExpiration(int $id, Time $expiresAt): bool
184184
$result = $identityModel->setIdentityExpirationById($id, $this, $expiresAt);
185185

186186
if ($result) {
187-
// refresh currentAccessToken with updated data
188-
$this->currentAccessToken = $identityModel->getHmacTokenById($id, $this);
187+
// refresh currentHmacToken with updated data
188+
$this->currentHmacToken = $identityModel->getHmacTokenById($id, $this);
189189
}
190190

191191
return $result;
@@ -194,7 +194,7 @@ public function updateHmacTokenExpiration(int $id, Time $expiresAt): bool
194194
/**
195195
* Removes the expiration date for HMAC token by ID.
196196
*
197-
* @param int $id AccessToken ID
197+
* @param int $id HMAC Token ID
198198
*
199199
* @return bool Returns true if expiration date is removed
200200
*/
@@ -205,7 +205,7 @@ public function removeHmacTokenExpiration(int $id): bool
205205
$result = $identityModel->setIdentityExpirationById($id, $this);
206206

207207
if ($result) {
208-
// refresh currentAccessToken with updated data
208+
// refresh currentHmacToken with updated data
209209
$this->currentHmacToken = $identityModel->getHmacTokenById($id, $this);
210210
}
211211

@@ -215,8 +215,8 @@ public function removeHmacTokenExpiration(int $id): bool
215215
/**
216216
* Checks if the current HMAC token has a set expiration date
217217
*/
218-
public function hasHmacTokenExpiry(AccessToken $accessToken): bool
218+
public function hasHmacTokenExpiry(AccessToken $hmacToken): bool
219219
{
220-
return $accessToken->expires !== null;
220+
return $hmacToken->expires !== null;
221221
}
222222
}

0 commit comments

Comments
 (0)