Skip to content

Commit d62240c

Browse files
authored
Merge pull request #36 from codebar-ag/feature-auth
Feature | manual request cookie
2 parents 7fa3e0c + 0a03c07 commit d62240c

19 files changed

+443
-451
lines changed

.github/workflows/run-tests.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ name: run-tests
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [ main ]
66
pull_request:
7-
branches: [main]
7+
branches: [ main ]
88

99
jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
fail-fast: true
1414
matrix:
15-
os: [ubuntu-latest, windows-latest]
16-
php: [8.1]
17-
laravel: [9.*]
18-
stability: [prefer-lowest, prefer-stable]
15+
os: [ ubuntu-latest, windows-latest ]
16+
php: [ 8.1 ]
17+
laravel: [ 9.* ]
18+
stability: [ prefer-lowest, prefer-stable ]
1919
include:
2020
- laravel: 9.*
2121
testbench: 7.*
@@ -49,3 +49,4 @@ jobs:
4949
DOCUWARE_URL: ${{ secrets.DOCUWARE_URL }}
5050
DOCUWARE_USERNAME: ${{ secrets.DOCUWARE_USERNAME }}
5151
DOCUWARE_PASSWORD: ${{ secrets.DOCUWARE_PASSWORD }}
52+
DOCUWARE_COOKIES: ${{ secrets.DOCUWARE_COOKIES }}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to `laravel-docuware` will be documented in this file.
44

5+
## 1.2.2 - 2022-09-27
6+
- Added `DOCUWARE_COOKIES` property to the config.php. This allows the user to manually set the DocuWare Request cookie instead of regenerating it after every cache reset. There is currently a DocuWare limitation with available seats per license, which can cause issues if you renew the request cookie too many times. The current lifespan of a DocuWare cookie is one year.
7+
- Added `DOCUWARE_CACHE_DRIVER` property to the config.php. This allows the user to manually set the default Cache Driver, which is used to store the DocuWare Request Cookie.
8+
9+
- Removed Solutions for Errors (Facade/Ignition).
10+
511
## 1.1.0 - 2021-07-22
612

713
- Added `error` property to the `DocumentPaginator`. This is used for failed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<img src="https://banners.beyondco.de/Laravel%20DocuWare.png?theme=light&packageManager=composer+require&packageName=codebar-ag%2Flaravel-docuware&pattern=circuitBoard&style=style_1&description=An+opinionated+way+to+integrate+DocuWare+with+Laravel&md=1&showWatermark=0&fontSize=175px&images=document-report">
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/laravel-docuware.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-docuware)
4+
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/codebar-ag/laravel-docuware/run-tests?label=tests)](https://github.com/codebar-ag/laravel-docuware/actions?query=workflow%3Arun-tests+branch%3Amain)
5+
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/codebar-ag/laravel-docuware/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/codebar-ag/laravel-docuware/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
46
[![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/laravel-docuware.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-docuware)
5-
[![run-tests](https://github.com/codebar-ag/laravel-docuware/actions/workflows/run-tests.yml/badge.svg)](https://github.com/codebar-ag/laravel-docuware/actions/workflows/run-tests.yml)
6-
[![Psalm](https://github.com/codebar-ag/laravel-docuware/actions/workflows/psalm.yml/badge.svg)](https://github.com/codebar-ag/laravel-docuware/actions/workflows/psalm.yml)
7-
[![Check & fix styling](https://github.com/codebar-ag/laravel-docuware/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/codebar-ag/laravel-docuware/actions/workflows/php-cs-fixer.yml)
87

98
This package was developed to give you a quick start to communicate with the
109
DocuWare REST API. It is used to query the most common endpoints.
@@ -21,7 +20,7 @@ then optimize the processes that power the core of your business.
2120

2221
## 🛠 Requirements
2322

24-
### >= v.1.2
23+
### > = v.1.2
2524

2625
- PHP: `^8.1`
2726
- Laravel: `^9.*`
@@ -42,12 +41,14 @@ composer require codebar-ag/laravel-docuware
4241
```
4342

4443
Add the following environment variables to your `.env` file:
44+
The "DOCUWARE_COOKIES" variable is optional and only used if you want to set the request cookie manually.
4545

4646
```bash
4747
DOCUWARE_URL=https://domain.docuware.cloud
4848
4949
DOCUWARE_PASSWORD=password
5050
DOCUWARE_PASSPHRASE="passphrase"
51+
DOCUWARE_COOKIES="cookie"
5152
```
5253

5354
With the passphrase we are able to encrypt the URLs.
@@ -467,6 +468,25 @@ This is the contents of the published config file:
467468

468469
return [
469470

471+
/*
472+
|--------------------------------------------------------------------------
473+
| Cache driver
474+
|--------------------------------------------------------------------------
475+
| You may like to define a different cache driver than the default Laravel cache driver.
476+
|
477+
*/
478+
479+
'cache_driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_DRIVER', 'file')),
480+
481+
/*
482+
|--------------------------------------------------------------------------
483+
| Cookies
484+
|--------------------------------------------------------------------------
485+
| This variable is optional and only used if you want to set the request cookie manually.
486+
|
487+
*/
488+
489+
'cookies' => env('DOCUWARE_COOKIES'),
470490
/*
471491
|--------------------------------------------------------------------------
472492
| DocuWare Credentials
@@ -529,6 +549,7 @@ Modify environment variables in the phpunit.xml-file:
529549
<env name="DOCUWARE_USERNAME" value="[email protected]"/>
530550
<env name="DOCUWARE_PASSWORD" value="password"/>
531551
<env name="DOCUWARE_PASSPHRASE" value="passphrase"/>
552+
<env name="DOCUWARE_COOKIE" value="cookie"/>
532553
```
533554

534555
Run the tests:

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
],
2727
"require": {
2828
"php": "^8.1",
29+
"guzzlehttp/guzzle": "^7.5",
2930
"illuminate/contracts": "^9.0",
3031
"spatie/laravel-ignition": "^1.5",
3132
"spatie/laravel-package-tools": "^1.13.0"
3233
},
3334
"require-dev": {
34-
"brianium/paratest": "^6.6",
3535
"laravel/pint": "^1.0",
3636
"nunomaduro/collision": "^6.0",
3737
"nunomaduro/larastan": "^2.0.1",
@@ -57,8 +57,8 @@
5757
},
5858
"scripts": {
5959
"psalm": "vendor/bin/psalm",
60-
"test": "./vendor/bin/testbench package:test --parallel --no-coverage",
61-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
60+
"test": "./vendor/bin/testbench package:test --no-coverage",
61+
"test-coverage": "vendor/bin/pest --coverage-html coverage",
6262
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
6363
},
6464
"config": {

config/docuware.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22

33
return [
44

5+
/*
6+
|--------------------------------------------------------------------------
7+
| Cache driver
8+
|--------------------------------------------------------------------------
9+
| You may like to define a different cache driver than the default Laravel cache driver.
10+
|
11+
*/
12+
13+
'cache_driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_DRIVER', 'file')),
14+
515
/*
616
|--------------------------------------------------------------------------
7-
| Set the Cache driver
17+
| Cookies
818
|--------------------------------------------------------------------------
19+
| This variable is optional and only used if you want to set the request cookie manually.
920
|
1021
*/
1122

12-
'default_cache_driver' => env('CACHE_DRIVER', 'local'),
23+
'cookies' => env('DOCUWARE_COOKIES'),
1324

1425
/*
1526
|--------------------------------------------------------------------------

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@
4141
<env name="DOCUWARE_USERNAME" value="[email protected]"/>
4242
<env name="DOCUWARE_PASSWORD" value="password"/>
4343
<env name="DOCUWARE_PASSPHRASE" value="passphrase"/>
44+
<env name="DOCUWARE_COOKIES" value="cookies"/>
4445
</php>
4546
</phpunit>

src/DocuWare.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class DocuWare
2424
{
2525
public function login(): void
2626
{
27+
if (config('docuware.cookies')) {
28+
return;
29+
}
30+
2731
EnsureValidCredentials::check();
2832

2933
$url = sprintf(
@@ -52,6 +56,10 @@ public function login(): void
5256

5357
public function logout(): void
5458
{
59+
if (config('docuware.cookies')) {
60+
return;
61+
}
62+
5563
EnsureValidCookie::check();
5664

5765
$url = sprintf(
@@ -272,7 +280,7 @@ public function updateDocumentValue(
272280
int $documentId,
273281
string $fieldName,
274282
string $newValue,
275-
): null | int | float | Carbon | string {
283+
): null|int|float|Carbon|string {
276284
EnsureValidCookie::check();
277285

278286
$url = sprintf(

src/Exceptions/UnableToFindPassphrase.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,12 @@
22

33
namespace CodebarAg\DocuWare\Exceptions;
44

5-
use Facade\IgnitionContracts\BaseSolution;
6-
use Facade\IgnitionContracts\ProvidesSolution;
7-
use Facade\IgnitionContracts\Solution;
85
use RuntimeException;
96

10-
class UnableToFindPassphrase extends RuntimeException implements ProvidesSolution
7+
class UnableToFindPassphrase extends RuntimeException
118
{
129
public static function create(): self
1310
{
14-
return new static('Your passphrase is not found.');
15-
}
16-
17-
public function getSolution(): Solution
18-
{
19-
return BaseSolution::create('Try to add following in your .env-file:')
20-
->setSolutionDescription('DOCUWARE_PASSPHRASE=passphrase')
21-
->setDocumentationLinks([
22-
'GitHub' => 'https://github.com/codebar-ag/laravel-docuware#installation',
23-
]);
11+
return new static('Your passphrase is not found. Try to add "DOCUWARE_PASSPHRASE=passphrase" in your .env-file.');
2412
}
2513
}

src/Exceptions/UnableToFindPasswordCredential.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,12 @@
22

33
namespace CodebarAg\DocuWare\Exceptions;
44

5-
use Facade\IgnitionContracts\BaseSolution;
6-
use Facade\IgnitionContracts\ProvidesSolution;
7-
use Facade\IgnitionContracts\Solution;
85
use RuntimeException;
96

10-
class UnableToFindPasswordCredential extends RuntimeException implements ProvidesSolution
7+
class UnableToFindPasswordCredential extends RuntimeException
118
{
129
public static function create(): self
1310
{
14-
return new static('Your password is not found.');
15-
}
16-
17-
public function getSolution(): Solution
18-
{
19-
return BaseSolution::create('Try to add following in your .env-file:')
20-
->setSolutionDescription('DOCUWARE_PASSWORD=password')
21-
->setDocumentationLinks([
22-
'GitHub' => 'https://github.com/codebar-ag/laravel-docuware#installation',
23-
]);
11+
return new static('Your password is not found. Try to add "DOCUWARE_PASSWORD=password" in your .env-file.');
2412
}
2513
}

src/Exceptions/UnableToFindUrlCredential.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,12 @@
22

33
namespace CodebarAg\DocuWare\Exceptions;
44

5-
use Facade\IgnitionContracts\BaseSolution;
6-
use Facade\IgnitionContracts\ProvidesSolution;
7-
use Facade\IgnitionContracts\Solution;
85
use RuntimeException;
96

10-
class UnableToFindUrlCredential extends RuntimeException implements ProvidesSolution
7+
class UnableToFindUrlCredential extends RuntimeException
118
{
129
public static function create(): self
1310
{
14-
return new static('Your URL is not found.');
15-
}
16-
17-
public function getSolution(): Solution
18-
{
19-
return BaseSolution::create('Try to add following in your .env-file:')
20-
->setSolutionDescription('DOCUWARE_URL=https://domain.docuware.cloud')
21-
->setDocumentationLinks([
22-
'GitHub' => 'https://github.com/codebar-ag/laravel-docuware#installation',
23-
]);
11+
return new static('Your URL is not found. Try to add "DOCUWARE_URL=https://domain.docuware.cloud" in your .env-file.');
2412
}
2513
}

0 commit comments

Comments
 (0)