Skip to content

Commit 6dd077a

Browse files
authored
chore: compat with latest versions of everything (#5)
* chore: compat with latest versions of everything * CS * fix tests
1 parent 5be21cb commit 6dd077a

File tree

10 files changed

+64
-64
lines changed

10 files changed

+64
-64
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
name: ci
22

3-
on: ["pull_request", "push"]
3+
on: ['pull_request', 'push']
44

55
jobs:
66
php-cs-fixer:
77
name: PHP CS Fixer (PHP ${{ matrix.php }})
88

99
runs-on: ubuntu-latest
1010

11-
strategy:
12-
matrix:
13-
php:
14-
- '8.1'
15-
fail-fast: false
16-
1711
steps:
1812
- name: Checkout
19-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
2014

2115
- name: Setup PHP
2216
uses: shivammathur/setup-php@v2
2317
with:
24-
php-version: ${{ matrix.php }}
18+
php-version: '8.2'
2519
tools: php-cs-fixer, cs2pr
2620

2721
- name: Run PHP CS Fixer
@@ -32,20 +26,14 @@ jobs:
3226

3327
runs-on: ubuntu-latest
3428

35-
strategy:
36-
matrix:
37-
php:
38-
- '8.1'
39-
fail-fast: false
40-
4129
steps:
4230
- name: Checkout
43-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
4432

4533
- name: Setup PHP
4634
uses: shivammathur/setup-php@v2
4735
with:
48-
php-version: ${{ matrix.php }}
36+
php-version: '8.2'
4937
tools: composer
5038

5139
- name: Run Composer
@@ -55,57 +43,59 @@ jobs:
5543
run: ./vendor/bin/psalm --output-format=github
5644

5745
tests:
58-
name: "tests"
46+
name: tests
5947

60-
runs-on: ${{ matrix.operating-system }}
48+
runs-on: ubuntu-latest
6149

6250
strategy:
6351
matrix:
6452
dependencies:
65-
- "lowest"
66-
- "highest"
53+
- lowest
54+
- highest
6755
php-version:
68-
- "8.1"
69-
operating-system:
70-
- "ubuntu-latest"
56+
- '8.1'
57+
- '8.2'
58+
exclude:
59+
- php-version: '8.1'
60+
dependencies: lowest
7161

7262
steps:
73-
- name: "checkout"
74-
uses: "actions/checkout@v2"
63+
- name: checkout
64+
uses: actions/checkout@v3
7565

76-
- name: "installing PHP"
77-
uses: "shivammathur/setup-php@v2"
66+
- name: installing PHP
67+
uses: shivammathur/setup-php@v2
7868
with:
79-
php-version: "${{ matrix.php-version }}"
69+
php-version: ${{ matrix.php-version }}
8070
ini-values: memory_limit=-1
8171
tools: composer:v2
8272

83-
- name: "caching dependencies"
84-
uses: "actions/cache@v2"
73+
- name: caching dependencies
74+
uses: actions/cache@v3
8575
with:
8676
path: |
8777
~/.composer/cache
8878
vendor
89-
key: "php-${{ matrix.php-version }}-${{ matrix.operating-system }}"
90-
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.operating-system }}"
79+
key: php-${{ matrix.php-version }}-${{ matrix.operating-system }}
80+
restore-keys: php-${{ matrix.php-version }}-${{ matrix.operating-system }}
9181

92-
- name: "installing lowest dependencies"
82+
- name: installing lowest dependencies
9383
if: ${{ matrix.dependencies == 'lowest' }}
94-
run: "composer update --prefer-lowest --no-interaction --no-progress"
84+
run: composer update --prefer-lowest --no-interaction --no-progress
9585

96-
- name: "installing highest dependencies"
86+
- name: installing highest dependencies
9787
if: ${{ matrix.dependencies == 'highest' }}
98-
run: "composer update --no-interaction --no-progress"
88+
run: composer update --no-interaction --no-progress
9989

100-
- name: "installing phpunit"
101-
run: "php vendor/bin/simple-phpunit install"
90+
- name: installing PHPUnit
91+
run: php vendor/bin/simple-phpunit install
10292

103-
- name: "running tests"
93+
- name: running tests
10494
if: ${{ matrix.dependencies == 'lowest' }}
10595
env:
10696
SYMFONY_DEPRECATIONS_HELPER: disabled=1
107-
run: "php vendor/bin/simple-phpunit"
97+
run: php vendor/bin/simple-phpunit
10898

109-
- name: "running tests"
99+
- name: running tests
110100
if: ${{ matrix.dependencies == 'highest' }}
111-
run: "php vendor/bin/simple-phpunit"
101+
run: php vendor/bin/simple-phpunit

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"require": {
2121
"php": ">=8.1",
22-
"jumbojett/openid-connect-php": "dev-master",
22+
"jumbojett/openid-connect-php": "^0.9.10",
2323
"symfony/http-client": "^6.0",
2424
"easyrdf/easyrdf": "^1.1",
2525
"ml/json-ld": "^1.2",
@@ -40,7 +40,6 @@
4040
"symfony/routing": "^6.0",
4141
"symfony/security-bundle": "^6.0",
4242
"symfony/twig-bundle": "^6.0",
43-
"symfony/debug": "^4.4",
4443
"symfony/debug-bundle": "^6.0",
4544
"symfony/web-profiler-bundle": "^6.0",
4645
"symfony/console": "^6.0",
@@ -49,6 +48,6 @@
4948
"symfony/browser-kit": "^6.0",
5049
"symfony/css-selector": "^6.0",
5150
"symfony/security-core": "^6.0",
52-
"vimeo/psalm": "^4.22"
51+
"vimeo/psalm": "^5.12"
5352
}
5453
}

src/Bundle/Resources/config/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
->set(LogoutListener::class)
3434
->set(SolidClientFactory::class)
3535
->set(BundleSolidClientFactory::class)
36-
;
36+
;
3737
};

src/Bundle/Security/SolidAuthenticator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ protected function getLoginUrl(Request $request): string
4545
public function supports(Request $request): bool
4646
{
4747
return
48-
$request->getSession()->has(self::OIDC_CLIENT_KEY) &&
49-
(
50-
$request->query->has('code') ||
51-
$request->query->has('error')
48+
$request->getSession()->has(self::OIDC_CLIENT_KEY)
49+
&& (
50+
$request->query->has('code')
51+
|| $request->query->has('error')
5252
);
5353
}
5454

src/OidcClient.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ final class OidcClient extends OpenIDConnectClient
4545
public function authenticate(): bool
4646
{
4747
$this->setCodeChallengeMethod('S256');
48-
$this->addScope('openid');
49-
$this->addScope('webid');
50-
$this->addScope('offline_access');
48+
$this->addScope(['openid', 'webid', 'offline_access']);
5149

5250
return parent::authenticate();
5351
}

src/SolidClient.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
) {
3232
}
3333

34-
public function createContainer(string $parentUrl, string $name, ?string $data = null): ResponseInterface
34+
public function createContainer(string $parentUrl, string $name, string $data = null): ResponseInterface
3535
{
3636
return $this->post($parentUrl, $data, $name, true);
3737
}
@@ -41,7 +41,7 @@ public function createContainer(string $parentUrl, string $name, ?string $data =
4141
*
4242
* @see https://github.com/solid/solid-web-client/blob/main/src/client.js#L231=
4343
*/
44-
public function post(string $url, ?string $data = null, ?string $slug = null, bool $isContainer = false, array $options = []): ResponseInterface
44+
public function post(string $url, string $data = null, string $slug = null, bool $isContainer = false, array $options = []): ResponseInterface
4545
{
4646
if ($isContainer || !isset($options['headers']['Content-Type'])) {
4747
$options['headers']['Content-Type'] = self::DEFAULT_MIME_TYPE;
@@ -75,7 +75,13 @@ public function request(string $method, string $url, array $options = []): Respo
7575

7676
public function getProfile(string $webId, array $options = []): Graph
7777
{
78-
return new Graph($webId, $this->get($webId, $options)->getContent());
78+
$response = $this->get($webId, $options);
79+
if (null !== $format = $response->getHeaders()['content-type'][0] ?? null) {
80+
// strip parameters (such as charset) if any
81+
$format = explode(';', $format, 2)[0];
82+
}
83+
84+
return new Graph($webId, $response->getContent(), $format);
7985
}
8086

8187
public function getOidcIssuer(string $webId, array $options = []): string

src/SolidClientFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(private readonly HttpClientInterface $httpClient)
2222
{
2323
}
2424

25-
public function create(?OidcClient $oidcClient = null): SolidClient
25+
public function create(OidcClient $oidcClient = null): SolidClient
2626
{
2727
return new SolidClient($this->httpClient, $oidcClient);
2828
}

tests/SmokeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public function testPublicProfile(): void
2424
$client->request('GET', '/kevin');
2525

2626
$this->assertResponseIsSuccessful();
27-
$this->assertSelectorTextContains('h1', 'dunglas');
27+
$this->assertSelectorTextContains('h1', 'https://id.inrupt.com/dunglas');
2828
}
2929
}

tests/app/Kernel.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Bundle\DebugBundle\DebugBundle;
1515
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1616
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
17+
use Symfony\Bundle\SecurityBundle\Security;
1718
use Symfony\Bundle\SecurityBundle\SecurityBundle;
1819
use Symfony\Bundle\TwigBundle\TwigBundle;
1920
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
@@ -49,6 +50,7 @@ protected function configureContainer(ContainerConfigurator $container): void
4950
'profiler' => [
5051
'only_exceptions' => false,
5152
],
53+
'http_method_override' => false,
5254
];
5355

5456
if ('test' === $this->environment) {
@@ -58,8 +60,7 @@ protected function configureContainer(ContainerConfigurator $container): void
5860

5961
$container->extension('framework', $frameworkConfig);
6062
$container->extension('web_profiler', ['toolbar' => true]);
61-
$container->extension('security', [
62-
'enable_authenticator_manager' => true,
63+
$security = [
6364
'password_hashers' => [
6465
PasswordAuthenticatedUserInterface::class => 'auto',
6566
],
@@ -80,7 +81,13 @@ protected function configureContainer(ContainerConfigurator $container): void
8081
],
8182
],
8283
],
83-
]);
84+
];
85+
86+
if (!method_exists(Security::class, 'getFirewallConfig')) {
87+
$security['enable_authenticator_manager'] = true;
88+
}
89+
90+
$container->extension('security', $security);
8491
}
8592

8693
protected function configureRoutes(RoutingConfigurator $routes): void
@@ -111,7 +118,7 @@ public function kevin(Environment $twig, SolidClientFactory $solidClientFactory)
111118
{
112119
$client = $solidClientFactory->create();
113120

114-
$webId = 'https://pod.inrupt.com/dunglas/profile/card#me';
121+
$webId = 'https://id.inrupt.com/dunglas';
115122
$profile = $client->getProfile($webId);
116123

117124
return new Response($twig->render('kevin.html.twig', ['webId' => $webId, 'profile' => $profile]));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends 'base.html.twig' %}
22

33
{% block body %}
4-
<h1>Public profile of {{ profile.getLiteral(webId, '<http://xmlns.com/foaf/0.1/name>') }}</h1>
4+
<h1>Public profile of {{ profile.uri }}</h1>
55

66
{{ dump(profile) }}
77
{% endblock %}

0 commit comments

Comments
 (0)