You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# M_FILES_SESSION_ID= # optional; exposed as config('m-files.auth.session_id') for custom use
37
44
```
38
45
39
46
### Configuration Options
@@ -44,7 +51,9 @@ The package supports the following configuration options:
44
51
-`M_FILES_USERNAME` - Your M-Files username
45
52
-`M_FILES_PASSWORD` - Your M-Files password
46
53
-`M_FILES_VAULT_GUID` - The vault GUID to connect to
47
-
-`M_FILES_CACHE_DRIVER` - Cache driver for storing authentication tokens (default: file)
54
+
-`M_FILES_CACHE_DRIVER` - Cache driver for storing authentication tokens (defaults to `CACHE_DRIVER`, then `file`)
55
+
-`M_FILES_EXPIRATION_SECONDS` - How long to cache the vault authentication token, in seconds (default: `3600`)
56
+
-`M_FILES_SESSION_ID` - Optional; sets `config('m-files.auth.session_id')` (not used by the package’s built-in connector/requests; available for your own integrations)
48
57
49
58
## Authentication
50
59
@@ -61,19 +70,27 @@ $config = new ConfigWithCredentials(
61
70
vaultGuid: '{ABC0DE2G-3HW-QWCQ-SDF3-WERWETWETW}',
62
71
username: 'your-username',
63
72
password: 'your-password',
64
-
cacheDriver: 'file'
73
+
cacheDriver: 'file',
74
+
tokenTtlSeconds: 3600,
65
75
);
66
76
67
-
$connector = new MFilesConnector(config: $config);
77
+
$connector = new MFilesConnector(configuration: $config);
68
78
```
69
79
70
-
### Authentication
80
+
### How the connector authenticates
71
81
72
82
Authentication is handled automatically by the `MFilesConnector`. When you create a connector instance with your credentials, it will automatically:
73
83
74
-
1.**Cache authentication tokens** - Tokens are cached for 1 hour to avoid repeated login requests
84
+
1.**Cache authentication tokens** - Tokens are cached for `M_FILES_EXPIRATION_SECONDS` / `config('m-files.auth.expiration')` (default 3600 seconds), or the `tokenTtlSeconds` argument on `ConfigWithCredentials`
75
85
2.**Include authentication headers** - The `X-Authentication` header is automatically added to all requests
76
-
3.**Handle token refresh** - When tokens expire, new ones are automatically obtained
86
+
3.**Handle token refresh** - When the cache entry expires, a new token is obtained on the next request
87
+
88
+
You can optionally inject a `CacheKeyManager` for tests or custom cache wiring: `new MFilesConnector(configuration: $config, cacheKeyManager: $manager)`.
89
+
90
+
### Cache and production security
91
+
92
+
- Auth tokens are stored in your configured **Laravel cache store**. Use a **private** backend in production (not a shared public cache).
93
+
- Cache keys incorporate a hash of connection parameters (including credentials). For **multi-tenant** apps, avoid sharing one cache namespace across tenants; prefer per-tenant key prefixes or separate Redis databases where applicable.
77
94
78
95
```php
79
96
use CodebarAg\MFiles\Requests\LogInToVaultRequest;
@@ -301,31 +318,34 @@ Represents M-Files configuration with authentication credentials.
301
318
-`vaultGuid` (string) - Vault GUID
302
319
-`username` (string) - M-Files username
303
320
-`password` (string) - M-Files password
304
-
-`cacheDriver` (string|null) - Cache driver for tokens
321
+
-`cacheDriver` (string|null) - Cache store name for tokens (see `M_FILES_CACHE_DRIVER` / `config('m-files.cache_driver')`)
322
+
-`tokenTtlSeconds` (int) - Cache TTL for the vault token in seconds (default **3600**; must be **≥ 1**)
`composer test` runs Pest with `--no-coverage` so the suite passes without PCOV or Xdebug (PHPUnit is configured with `failOnWarning="true"`, and missing a coverage driver would otherwise fail the run).
565
+
566
+
Static analysis:
567
+
568
+
```bash
569
+
composer analyse
570
+
```
571
+
572
+
To generate a coverage report locally, install and enable [PCOV](https://github.com/krakjoe/pcov) or Xdebug, then run:
573
+
574
+
```bash
575
+
composer test-coverage
576
+
```
577
+
578
+
On GitHub Actions, the `run-tests` workflow runs the matrix with `--no-coverage` and includes a **coverage** job (PHP 8.5 + PCOV) that writes Clover output and uploads it as a workflow artifact.
579
+
544
580
## Changelog
545
581
546
582
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
547
583
548
584
## Contributing
549
585
550
-
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
586
+
Open a pull request or issue on [GitHub](https://github.com/codebar-ag/laravel-m-files). Please run `composer test` and `composer analyse` before submitting.
551
587
552
588
## Security
553
589
590
+
Operational notes on caching and credentials are described under [Cache and production security](#cache-and-production-security).
591
+
554
592
If you discover any security related issues, please email security@codebar.ch instead of using the issue tracker.
message:'#^Assign to protected\(set\) property CodebarAg\\MFiles\\DTO\\DownloadedFile\:\:\$content\.$#'
23
+
identifier:assign.propertyProtectedSet
24
+
count:1
25
+
path:tests/Unit/DTO/DownloadedFileTest.php
26
+
27
+
-
28
+
message:'#^Assign to protected\(set\) property CodebarAg\\MFiles\\DTO\\File\:\:\$id\.$#'
29
+
identifier:assign.propertyProtectedSet
30
+
count:1
31
+
path:tests/Unit/DTO/FileTest.php
32
+
33
+
-
34
+
message:'#^Assign to protected\(set\) property CodebarAg\\MFiles\\DTO\\ObjectProperties\:\:\$classId\.$#'
35
+
identifier:assign.propertyProtectedSet
36
+
count:1
37
+
path:tests/Unit/DTO/ObjectPropertiesTest.php
38
+
39
+
-
40
+
message:'#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Carbon\\\\CarbonImmutable'' and Carbon\\CarbonImmutable will always evaluate to true\.$#'
41
+
identifier:method.alreadyNarrowedType
42
+
count:3
43
+
path:tests/Unit/DTO/ObjectPropertiesTest.php
44
+
45
+
-
46
+
message:'#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Illuminate\\\\Support\\\\Collection'' and Illuminate\\Support\\Collection will always evaluate to true\.$#'
47
+
identifier:method.alreadyNarrowedType
48
+
count:6
49
+
path:tests/Unit/DTO/ObjectPropertiesTest.php
50
+
51
+
-
52
+
message:'#^Access to an undefined property PHPUnit\\Framework\\TestCase\:\:\$cacheManager\.$#'
53
+
identifier:property.notFound
54
+
count:9
55
+
path:tests/Unit/Helpers/CacheKeyManagerTest.php
56
+
57
+
-
58
+
message:'#^Access to an undefined property PHPUnit\\Framework\\TestCase\:\:\$config\.$#'
0 commit comments