Skip to content
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

Add tokenCacheDir to the firebase options #192

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,6 @@ parameters:
count: 2
path: ../../src/Tiqr/Legacy/TiqrService.php

-
message: "#^Cannot access offset 'projectId' on mixed\\.$#"
count: 1
path: ../../src/Tiqr/TiqrConfiguration.php

-
message: "#^Cannot access offset 'credentialsFile' on mixed\\.$#"
count: 1
path: ../../src/Tiqr/TiqrConfiguration.php

-
message: "#^Cannot access offset 'cacheTokens' on mixed\\.$#"
count: 1
path: ../../src/Tiqr/TiqrConfiguration.php

-
message: "#^Cannot access offset 'arguments' on mixed\\.$#"
count: 4
Expand Down
1 change: 1 addition & 0 deletions config/openconext/parameters.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ parameters:
projectId: 'FCM project ID'
credentialsFile: 'absolute path to file with service account key'
cacheTokens: false
tokenCacheDir: '/tmp'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The missing link! 🥇

accountblocking:
maxAttempts: 5
storage:
Expand Down
4 changes: 3 additions & 1 deletion src/Tiqr/TiqrConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ public function __construct(array $tiqrConfiguration)
$this->options['apns.environment'] = $tiqrConfiguration['library']['apns']['environment'];
}

if (isset($tiqrConfiguration['library']['firebase'])) {
if (isset($tiqrConfiguration['library']['firebase']) && is_array($tiqrConfiguration['library']['firebase'])) {
Assertion::string($tiqrConfiguration['library']['firebase']['projectId']);
$this->options['firebase.projectId'] = $tiqrConfiguration['library']['firebase']['projectId'];
Assertion::string($tiqrConfiguration['library']['firebase']['credentialsFile']);
$this->options['firebase.credentialsFile'] = $tiqrConfiguration['library']['firebase']['credentialsFile'];
Assertion::boolean($tiqrConfiguration['library']['firebase']['cacheTokens']);
$this->options['firebase.cacheTokens'] = $tiqrConfiguration['library']['firebase']['cacheTokens'];
Assertion::string($tiqrConfiguration['library']['firebase']['tokenCacheDir']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not type safe enough also see the failing PHPStan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added check if it is an array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to convert this to an object instead of an array when there's maintenance.

$this->options['firebase.tokenCacheDir'] = $tiqrConfiguration['library']['firebase']['tokenCacheDir'];
}

if (isset($tiqrConfiguration['accountblocking'][self::MAX_ATTEMPTS])) {
Expand Down