Skip to content

Commit 3ce4e4a

Browse files
authored
Merge pull request #171 from codebar-ag/fix-oauth
Fixed OAuth-Bug resolves #170
2 parents fecfb38 + 1837987 commit 3ce4e4a

File tree

8 files changed

+55
-99
lines changed

8 files changed

+55
-99
lines changed

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

phpunit.xml.dist

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
7-
bootstrap="vendor/autoload.php"
8-
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
12-
processIsolation="false"
13-
stopOnFailure="false"
14-
executionOrder="random"
15-
failOnWarning="true"
16-
failOnRisky="true"
17-
failOnEmptyTestSuite="true"
18-
beStrictAboutOutputDuringTests="true"
19-
verbose="true"
20-
>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" backupGlobals="false"
4+
bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false"
5+
executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true"
6+
beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
217
<testsuites>
228
<testsuite name="codebar Test Suite">
239
<directory>tests</directory>
2410
</testsuite>
2511
</testsuites>
2612
<coverage>
27-
<include>
28-
<directory suffix=".php">./src</directory>
29-
</include>
3013
<report>
3114
<html outputDirectory="build/coverage"/>
3215
<text outputFile="build/coverage.txt"/>
@@ -38,19 +21,23 @@
3821
</logging>
3922
<php>
4023
<env name="APP_KEY" value="base64:F+mHMDBbavrsp/I3WYA5lDSwDJJI/0wQG4eM3csq/lo="/>
41-
<env name="DOCUWARE_URL" value="https://domain.docuware.cloud"/>
42-
<env name="DOCUWARE_USERNAME" value="[email protected]"/>
24+
<env name="DOCUWARE_URL" value="https://laravel.docuware.cloud"/>
25+
<env name="DOCUWARE_USERNAME" value="username"/>
4326
<env name="DOCUWARE_PASSWORD" value="password"/>
4427
<env name="DOCUWARE_PASSPHRASE" value="passphrase"/>
4528
<env name="DOCUWARE_TIMEOUT" value="30"/>
46-
<env name="DOCUWARE_CACHE_DRIVER" value="array" />
29+
<env name="DOCUWARE_CACHE_DRIVER" value="file"/>
4730
<env name="DOCUWARE_CACHE_LIFETIME_IN_SECONDS" value="0"/>
48-
4931
<env name="DOCUWARE_TESTS_FILE_CABINET_ID" value="17eaf4ba-41a8-43ec-8be5-80a5f5f1eaf1"/>
5032
<env name="DOCUWARE_TESTS_DIALOG_ID" value="5afd9126-6cb1-4c7b-8ab2-2ca0bbbeb7be"/>
5133
<env name="DOCUWARE_TESTS_BASKET_ID" value="b_ac921d68-983b-4b0f-8a20-34ab05ff19c6"/>
5234
<env name="DOCUWARE_TESTS_ORGANIZATION_ID" value="1"/>
5335
<env name="DOCUWARE_TESTS_GROUP_ID" value="ae49d31e-41ce-46b2-9ebb-64db58e90046"/>
5436
<env name="DOCUWARE_TESTS_ROLE_ID" value="2444928d-1312-44db-aa79-101f198ac946"/>
5537
</php>
56-
</phpunit>
38+
<source>
39+
<include>
40+
<directory suffix=".php">./src</directory>
41+
</include>
42+
</source>
43+
</phpunit>

src/Connectors/DocuWareConnector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ protected function defaultAuth(): TokenAuthenticator
5757
*/
5858
protected function getOrCreateNewOAuthToken(): string
5959
{
60+
//ray($this->configuration->identifier);
61+
6062
$cache = Cache::store($this->configuration->cacheDriver);
6163

6264
$cacheKey = 'docuware.oauth.'.$this->configuration->identifier;
6365

66+
//ray($cache->has($cacheKey),'hasCachkey?');
67+
6468
// Check if the token exists in cache and return it if found
6569
if ($cache->has($cacheKey)) {
6670
$token = Crypt::decrypt($cache->get($cacheKey));

src/DTO/Authentication/OAuth/IdentityServiceConfiguration.php

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,44 @@ public static function make(array $data): self
2626
frontchannelLogoutSessionSupported: Arr::get($data, 'frontchannel_logout_session_supported'),
2727
backchannelLogoutSupported: Arr::get($data, 'backchannel_logout_supported'),
2828
backchannelLogoutSessionSupported: Arr::get($data, 'backchannel_logout_session_supported'),
29-
scopesSupported: Arr::get($data, 'scopes_supported'),
30-
claimsSupported: Arr::get($data, 'claims_supported'),
31-
grantTypesSupported: Arr::get($data, 'grant_types_supported'),
32-
responseTypesSupported: Arr::get($data, 'response_types_supported'),
33-
responseModesSupported: Arr::get($data, 'response_modes_supported'),
34-
tokenEndpointAuthMethodsSupported: Arr::get($data, 'token_endpoint_auth_methods_supported'),
35-
idTokenSigningAlgValuesSupported: Arr::get($data, 'id_token_signing_alg_values_supported'),
36-
subjectTypesSupported: Arr::get($data, 'subject_types_supported'),
37-
codeChallengeMethodsSupported: Arr::get($data, 'code_challenge_methods_supported'),
29+
scopesSupported: Arr::get($data, 'scopes_supported', []),
30+
claimsSupported: Arr::get($data, 'claims_supported', []),
31+
grantTypesSupported: Arr::get($data, 'grant_types_supported', []),
32+
responseTypesSupported: Arr::get($data, 'response_types_supported', []),
33+
responseModesSupported: Arr::get($data, 'response_modes_supported', []),
34+
tokenEndpointAuthMethodsSupported: Arr::get($data, 'token_endpoint_auth_methods_supported', []),
35+
idTokenSigningAlgValuesSupported: Arr::get($data, 'id_token_signing_alg_values_supported', []),
36+
subjectTypesSupported: Arr::get($data, 'subject_types_supported', []),
37+
codeChallengeMethodsSupported: Arr::get($data, 'code_challenge_methods_supported', []),
3838
requestParameterSupported: Arr::get($data, 'request_parameter_supported'),
39-
requestObjectSigningAlgValuesSupported: Arr::get($data, 'request_object_signing_alg_values_supported'),
40-
promptValuesSupported: Arr::get($data, 'prompt_values_supported'),
39+
requestObjectSigningAlgValuesSupported: Arr::get($data, 'request_object_signing_alg_values_supported', []),
40+
promptValuesSupported: Arr::get($data, 'prompt_values_supported', []),
4141
authorizationResponseIssParameterSupported: Arr::get($data, 'authorization_response_iss_parameter_supported'),
42-
backchannelTokenDeliveryModesSupported: Arr::get($data, 'backchannel_token_delivery_modes_supported'),
42+
backchannelTokenDeliveryModesSupported: Arr::get($data, 'backchannel_token_delivery_modes_supported', []),
4343
backchannelUserCodeParameterSupported: Arr::get($data, 'backchannel_user_code_parameter_supported'),
44-
dpopSigningAlgValuesSupported: Arr::get($data, 'dpop_signing_alg_values_supported'),
44+
dpopSigningAlgValuesSupported: Arr::get($data, 'dpop_signing_alg_values_supported', []),
4545
windowsAuthEndpoint: Arr::get($data, 'windows_auth_endpoint'),
4646
);
4747
}
4848

4949
public function __construct(
50-
public string $issuer,
51-
public string $jwksUri,
52-
public string $authorizationEndpoint,
53-
public string $tokenEndpoint,
54-
public string $userinfoEndpoint,
55-
public string $endSessionEndpoint,
56-
public string $checkSessionIframe,
57-
public string $revocationEndpoint,
58-
public string $introspectionEndpoint,
59-
public string $deviceAuthorizationEndpoint,
60-
public string $backchannelAuthenticationEndpoint,
61-
public string $pushedAuthorizationRequestEndpoint,
62-
public bool $requirePushedAuthorizationRequests,
63-
public bool $frontchannelLogoutSupported,
64-
public bool $frontchannelLogoutSessionSupported,
65-
public bool $backchannelLogoutSupported,
66-
public bool $backchannelLogoutSessionSupported,
50+
public ?string $issuer,
51+
public ?string $jwksUri,
52+
public ?string $authorizationEndpoint,
53+
public ?string $tokenEndpoint,
54+
public ?string $userinfoEndpoint,
55+
public ?string $endSessionEndpoint,
56+
public ?string $checkSessionIframe,
57+
public ?string $revocationEndpoint,
58+
public ?string $introspectionEndpoint,
59+
public ?string $deviceAuthorizationEndpoint,
60+
public ?string $backchannelAuthenticationEndpoint,
61+
public ?string $pushedAuthorizationRequestEndpoint,
62+
public ?bool $requirePushedAuthorizationRequests,
63+
public ?bool $frontchannelLogoutSupported,
64+
public ?bool $frontchannelLogoutSessionSupported,
65+
public ?bool $backchannelLogoutSupported,
66+
public ?bool $backchannelLogoutSessionSupported,
6767
public array $scopesSupported,
6868
public array $claimsSupported,
6969
public array $grantTypesSupported,
@@ -73,13 +73,13 @@ public function __construct(
7373
public array $idTokenSigningAlgValuesSupported,
7474
public array $subjectTypesSupported,
7575
public array $codeChallengeMethodsSupported,
76-
public bool $requestParameterSupported,
76+
public ?bool $requestParameterSupported,
7777
public array $requestObjectSigningAlgValuesSupported,
7878
public array $promptValuesSupported,
79-
public bool $authorizationResponseIssParameterSupported,
79+
public ?bool $authorizationResponseIssParameterSupported,
8080
public array $backchannelTokenDeliveryModesSupported,
81-
public bool $backchannelUserCodeParameterSupported,
81+
public ?bool $backchannelUserCodeParameterSupported,
8282
public array $dpopSigningAlgValuesSupported,
83-
public string $windowsAuthEndpoint,
83+
public ?string $windowsAuthEndpoint,
8484
) {}
8585
}

src/DTO/Config/ConfigWithCredentials.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace CodebarAg\DocuWare\DTO\Config;
44

5-
use Illuminate\Support\Facades\Crypt;
6-
use Illuminate\Support\Facades\Hash;
7-
85
final class ConfigWithCredentials
96
{
107
public string $identifier;
@@ -55,6 +52,6 @@ public function __construct(
5552

5653
$this->scope = filled($scope) ? $scope : config('laravel-docuware.configurations.scope');
5754

58-
$this->identifier = Hash::make($this->url.$this->username.Crypt::encrypt($this->password));
55+
$this->identifier = hash('sha256', $this->url.$this->username.$this->password);
5956
}
6057
}

src/DTO/Config/ConfigWithCredentialsTrustedUser.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace CodebarAg\DocuWare\DTO\Config;
44

5-
use Illuminate\Support\Facades\Crypt;
6-
use Illuminate\Support\Facades\Hash;
7-
85
final class ConfigWithCredentialsTrustedUser
96
{
107
public string $identifier;
@@ -59,6 +56,6 @@ public function __construct(
5956

6057
$this->scope = filled($scope) ? $scope : config('laravel-docuware.configurations.scope');
6158

62-
$this->identifier = Hash::make($this->url.$this->username.Crypt::encrypt($this->password));
59+
$this->identifier = hash('sha256', $this->url.$this->username.$this->password);
6360
}
6461
}

src/DocuWare.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,8 @@
22

33
namespace CodebarAg\DocuWare;
44

5-
use CodebarAg\DocuWare\DTO\Authentication\OAuth\RequestToken as RequestTokenDto;
6-
use CodebarAg\DocuWare\Requests\Authentication\OAuth\GetIdentityServiceConfiguration;
7-
use CodebarAg\DocuWare\Requests\Authentication\OAuth\GetResponsibleIdentityService;
8-
use CodebarAg\DocuWare\Requests\Authentication\OAuth\RequestTokenWithCredentials;
9-
105
class DocuWare
116
{
12-
public function getNewAuthenticationOAuthToken(
13-
?string $username = '',
14-
?string $password = '',
15-
?string $grantType = 'password',
16-
?string $clientId = 'docuware.platform.net.client'
17-
): RequestTokenDto {
18-
$responsibleIdentityServiceResponse = (new GetResponsibleIdentityService)->send();
19-
20-
$identityServiceConfigurationResponse = (new GetIdentityServiceConfiguration(
21-
identityServiceUrl: $responsibleIdentityServiceResponse->dto()->identityServiceUrl
22-
))->send();
23-
24-
$requestTokenResponse = (new RequestTokenWithCredentials(
25-
tokenEndpoint: $identityServiceConfigurationResponse->dto()->tokenEndpoint,
26-
clientId: $clientId,
27-
username: $username,
28-
password: $password,
29-
))->send();
30-
31-
return $requestTokenResponse->dto();
32-
}
33-
347
public function searchRequestBuilder(): DocuWareSearchRequestBuilder
358
{
369
return new DocuWareSearchRequestBuilder;

src/Facades/DocuWare.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Carbon\Carbon;
66
use CodebarAg\DocuWare\DocuWareSearchRequestBuilder;
77
use CodebarAg\DocuWare\DocuWareUrl;
8-
use CodebarAg\DocuWare\DTO\Cookie;
98
use CodebarAg\DocuWare\DTO\Documents\Document;
109
use CodebarAg\DocuWare\DTO\Documents\DocumentThumbnail;
1110
use CodebarAg\DocuWare\DTO\Documents\Field;
@@ -19,7 +18,6 @@
1918
/**
2019
* @see \CodebarAg\DocuWare\DocuWare
2120
*
22-
* @method static Cookie cookie(string $url, string $username, string $password, $rememberMe = false, $redirectToMyselfInCaseOfError = false, $licenseType = null)
2321
* @method static string login()
2422
* @method static void logout()
2523
* @method static Organization getOrganization(string $organizationId)

0 commit comments

Comments
 (0)