Skip to content

Cover authentication, token handling and signatures with tests - #75

Merged
robertlemke merged 2 commits into
mainfrom
task/improve-test-coverage
Sep 11, 2026
Merged

robertlemke merged 2 commits into
mainfrom
task/improve-test-coverage

Conversation

@robertlemke

Copy link
Copy Markdown
Member

This adds unit tests for the security relevant parts of the package: the authentication provider, the token, the entry point, the signed token arguments and the signature verification of identity tokens. Signatures are verified against RSA keys generated during the test run, so forged or modified tokens are actually rejected in the tests.

To make the authentication flow testable without Flow's dependency injection, the provider, token and entry point now get their clients from an injectable OpenIdConnectClientFactory, and TokenArguments receives the HashService as an argument. This refactoring does not change behaviour, but the signatures of TokenArguments::fromArray() and fromSignedString() change, which fits into the upcoming 6.0 release.

The authentication provider, token and entry point get their OpenID
Connect clients from an injected OpenIdConnectClientFactory. Token
arguments receive the hash service as an explicit argument. The
behaviour of the authentication components does not change.

Previously, these classes created clients with "new" and token
arguments relied on property injection inside a static factory method.
Without Flow's dependency injection, neither could be replaced, so the
authentication flow could not be covered by unit tests.

The signatures of TokenArguments::fromArray() and fromSignedString()
now require a HashService. This is part of the breaking changes of the
next major release.
@robertlemke
robertlemke force-pushed the task/improve-test-coverage branch from cdb73ed to 681fd0a Compare September 11, 2026 08:08
Unit tests now cover the authentication provider, the token, the entry
point, the signed token arguments and the signature verification of
identity tokens.

Previously, only parsing of identity tokens, the JWKS retrieval and the
cookie middleware were tested. The security relevant parts had no
tests at all. Signatures are now verified against RSA keys generated
during the test run, so a forged or modified token is actually
rejected rather than only parsed.

Deprecations triggered inside dependencies are ignored, because Flow
9.1 itself uses a cast which PHP 8.5 deprecates. Deprecations in this
package still fail the tests.
@robertlemke
robertlemke force-pushed the task/improve-test-coverage branch from 681fd0a to ac36f3a Compare September 11, 2026 09:03
@robertlemke
robertlemke merged commit 1af7633 into main Sep 11, 2026
6 checks passed
@robertlemke
robertlemke deleted the task/improve-test-coverage branch September 11, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant