-
Notifications
You must be signed in to change notification settings - Fork 24
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
Refreshtoken lifetime + 0.3.0 version bump #182
Conversation
d6c46f8
to
661f495
Compare
Codecov Report
@@ Coverage Diff @@
## master #182 +/- ##
============================================
+ Coverage 64.27% 64.33% +0.05%
- Complexity 221 226 +5
============================================
Files 34 35 +1
Lines 879 900 +21
============================================
+ Hits 565 579 +14
- Misses 314 321 +7
Continue to review full report at Codecov.
|
unit tests ? |
* @return boolean true if the refresh token has expired, false otherwise. | ||
*/ | ||
public function hasExpired() { | ||
return \time() >= $this->getExpires(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the TimeFactory everywhere so you can mock it in tests
$this->authorizationCodeMapper = $authorizationCodeMapper; | ||
$this->accessTokenMapper = $accessTokenMapper; | ||
$this->refreshTokenMapper = $refreshTokenMapper; | ||
|
||
$this->setInterval(86400); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic number?
/** | ||
* Resets the expiry time to EXPIRATION_DAYS days from now. | ||
*/ | ||
public function resetExpires() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formating of comment is strange
@@ -206,6 +206,7 @@ public function generateToken($grant_type, $code = null, | |||
$refreshToken->setClientId($client->getId()); | |||
$refreshToken->setUserId($userId); | |||
$refreshToken->setAccessTokenId($accessToken->getId()); | |||
$refreshToken->resetExpires(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rationale behind allowing RefreshToken setting expiration, and not Controller?
Argg, applied this on our production environment & now run into a problem here.. When your AccessToken is expired and you retrieving a new one, your RefreshToken is regenerated where the AccessToken is linked too. So, the lifetime of the RefreshToken is automatically extended with the duration of the AccessToken. See this part of the OAuthApiController; |
Ok, have fixed now. There are slightly some more adjustments.
In "oauth2/lib/Controller/OAuthApiController.php" we will update the token when it's still valid & return the JSON.
Now I got only a nasty Exception when there isn't a RefreshToken found in the follow try statement for "oauth2/lib/Controller/OAuthApiController.php";
Maybe you can have a look how this can be fixed in a more cleaner way.
|
Owja, what's also important. Not sure of you have received it from me. Is the follow changes in "oauth2/lib/Db/RefreshTokenMapper.php"
|
Ping, any update on this? |
This is already open for a quite long period. |
Yes please 👍 |
@micbar pinging you so you are aware of this PR that has been here since 2018. |
As of discussion in RC closing this, obsolete. |
Needs reasoning |
@micbar ; From a security point of view, you do not want an infinite session duration. Where we (@ SURF) also use an external Identity Provider (Shibboleth / LDAP), instead of local accounts, |
Reasoning: |
Policies (like expiration) are managed by the IdP with OIDC (OpenID Connect). All ownCloud clients will respect those. |
@DeepDiver1975 , to make the challenge a little bit bigger 😅.. Now we support multiple login methods, both local and Shibboleth accounts (via SSO). Could this still be supported when switching to OIDC? I guess for local account, only the sessions will be handled then via OIDC, like now is done by oAuth2 or is the "Identity Service" part also there to authenticate to a local database or something? |
@T0mWz I'm pretty much aware of the challenges in our setup! We need to have a closer look and discussion on how to get you migrated one day. |
Follow up on #174