Skip to content

Commit b7831c7

Browse files
committed
Merge branch 'pu/pm/SsoRpAccessTokenTtlCfg' into 'main'
tweak(SSO) add access token ttl to RP config See merge request tine20/tine20!7203
2 parents 7a6ae80 + 32815d4 commit b7831c7

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

tine20/SSO/Controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ protected static function getOpenIdConnectServer(): \League\OAuth2\Server\Author
924924
);
925925

926926
$grant->setIssuer(static::getOAuthIssuer());
927-
$grant->setRefreshTokenTTL(new \DateInterval('P1M')); // refresh tokens will expire after 1 month
927+
$grant->setRefreshTokenTTL(new \DateInterval('P1D')); // refresh tokens will expire after 1 day
928928

929929
// Enable the authentication code grant on the server
930930
$server->enableGrantType(
@@ -942,7 +942,7 @@ protected static function getOpenIdConnectServer(): \League\OAuth2\Server\Author
942942
);
943943

944944
$grant->setIssuer(static::getOAuthIssuer());
945-
$grant->setRefreshTokenTTL(new \DateInterval('P1M')); // refresh tokens will expire after 1 month
945+
$grant->setRefreshTokenTTL(new \DateInterval('P1D')); // refresh tokens will expire after 1 day
946946

947947
// Enable the authentication code grant on the server
948948
$server->enableGrantType(

tine20/SSO/Facade/OpenIdConnect/AuthCodeGrant.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @subpackage Facade
77
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
88
* @author Paul Mehrer <[email protected]>
9-
* @copyright Copyright (c) 2023-2024 Metaways Infosystems GmbH (http://www.metaways.de)
9+
* @copyright Copyright (c) 2023-2025 Metaways Infosystems GmbH (http://www.metaways.de)
1010
*
1111
*/
1212

@@ -22,6 +22,14 @@ public function respondToAccessTokenRequest(
2222
ResponseTypeInterface $responseType,
2323
\DateInterval $accessTokenTTL
2424
): ResponseTypeInterface {
25+
26+
list($clientId) = $this->getClientCredentials($request);
27+
/** @var SSO_Facade_OAuth2_ClientEntity $client */
28+
$client = $this->getClientEntityOrFail($clientId, $request);
29+
if ($ttl = $client->getRelyingPart()->{SSO_Model_RelyingParty::FLD_ACCESS_TOKEN_TTL}) {
30+
$this->idTokenTTL = $accessTokenTTL = new DateInterval('PT' . $ttl . 'M');
31+
}
32+
2533
/** @var \Idaas\OpenID\ResponseTypes\BearerTokenResponse $result */
2634
$result = parent::respondToAccessTokenRequest($request, $responseType, $accessTokenTTL);
2735

tine20/SSO/Model/RelyingParty.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class SSO_Model_RelyingParty extends Tinebase_Record_NewAbstract
2929
public const FLD_LOGO_DARK = 'logo_dark';
3030
public const FLD_LOGO_LIGHT = 'logo_light';
3131
public const FLD_NAME = 'name';
32+
public const FLD_ACCESS_TOKEN_TTL = 'access_token_ttl';
3233

3334
/**
3435
* holds the configuration object (must be declared in the concrete class)
@@ -43,7 +44,7 @@ class SSO_Model_RelyingParty extends Tinebase_Record_NewAbstract
4344
* @var array
4445
*/
4546
protected static $_modelConfiguration = [
46-
self::VERSION => 4,
47+
self::VERSION => 5,
4748
self::RECORD_NAME => 'Relying Party',
4849
self::RECORDS_NAME => 'Relying Parties', // ngettext('Relying Party', 'Relying Parties', n)
4950
self::TITLE_PROPERTY => self::FLD_NAME,
@@ -128,6 +129,12 @@ class SSO_Model_RelyingParty extends Tinebase_Record_NewAbstract
128129
[Tinebase_Record_Validator_SubValidate::class],
129130
],
130131
],
132+
self::FLD_ACCESS_TOKEN_TTL => [
133+
self::TYPE => self::TYPE_INTEGER,
134+
self::SPECIAL_TYPE => self::SPECIAL_TYPE_MINUTES,
135+
self::NULLABLE => true,
136+
self::LABEL => 'Access Token TTL',
137+
],
131138
]
132139
];
133140

tine20/SSO/Setup/Update/18.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class SSO_Setup_Update_18 extends Setup_Update_Abstract
1717
protected const RELEASE018_UPDATE001 = __CLASS__ . '::update001';
1818
protected const RELEASE018_UPDATE002 = __CLASS__ . '::update002';
1919
protected const RELEASE018_UPDATE003 = __CLASS__ . '::update003';
20+
protected const RELEASE018_UPDATE004 = __CLASS__ . '::update004';
2021

2122
static protected $_allUpdates = [
2223
self::PRIO_NORMAL_APP_STRUCTURE => [
@@ -28,6 +29,10 @@ class SSO_Setup_Update_18 extends Setup_Update_Abstract
2829
self::CLASS_CONST => self::class,
2930
self::FUNCTION_CONST => 'update002',
3031
],
32+
self::RELEASE018_UPDATE004 => [
33+
self::CLASS_CONST => self::class,
34+
self::FUNCTION_CONST => 'update004',
35+
],
3136
],
3237
self::PRIO_NORMAL_APP_UPDATE => [
3338
self::RELEASE018_UPDATE000 => [
@@ -80,4 +85,13 @@ public function update003()
8085

8186
$this->addApplicationUpdate(SSO_Config::APP_NAME, '18.3', self::RELEASE018_UPDATE003);
8287
}
88+
89+
public function update004()
90+
{
91+
Setup_SchemaTool::updateSchema([
92+
SSO_Model_RelyingParty::class,
93+
]);
94+
95+
$this->addApplicationUpdate(SSO_Config::APP_NAME, '18.4', self::RELEASE018_UPDATE004);
96+
}
8397
}

tine20/SSO/Setup/setup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<application>
33
<name>SSO</name>
4-
<version>18.3</version>
4+
<version>18.4</version>
55
<order>100</order>
66
<status>enabled</status>
77
</application>

tine20/Tinebase/ModelConfiguration/Const.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class Tinebase_ModelConfiguration_Const {
246246
public const SPECIAL_TYPE_URL = 'url';
247247
public const SPECIAL_TYPE_COUNTRY = 'country';
248248
public const SPECIAL_TYPE_CURRENCY = 'currency';
249-
249+
public const SPECIAL_TYPE_MINUTES = 'minutes';
250250
public const SPECIAL_TYPE_MONTH = 'month';
251251
public const STORAGE = 'storage';
252252
public const SUPPORTED_FORMATS = 'supportedFormats';

0 commit comments

Comments
 (0)