Skip to content

NFC-102 Web eID for mobile support#46

Open
SanderKondratjevNortal wants to merge 7 commits intoweb-eid-mobilefrom
NFC-102
Open

NFC-102 Web eID for mobile support#46
SanderKondratjevNortal wants to merge 7 commits intoweb-eid-mobilefrom
NFC-102

Conversation

@SanderKondratjevNortal
Copy link
Copy Markdown

Signed-off-by: Sander Kondratjev sander.kondratjev@nortal.com

@SanderKondratjevNortal SanderKondratjevNortal force-pushed the NFC-102 branch 3 times, most recently from 363add3 to 1d5a80e Compare January 26, 2026 09:08
@SanderKondratjevNortal SanderKondratjevNortal changed the base branch from main to web-eid-mobile January 26, 2026 09:10
$base64ChallengeNonce
);

session_regenerate_id();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Session is regenerated twice, see Auth.validate() line 80.

session_regenerate_id();

$subjectName = $this->getPrincipalNameFromCertificate($cert);
$_SESSION["auth-user"] = $subjectName;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would suggest to move all session-related logic either up into Auth.validate() (along with session regeneration) or here for consistency.

Comment on lines +50 to +54
if (str_starts_with($baseUrl, 'http')) {
$authUri = rtrim($baseUrl, '/') . '/auth#' . $encodedPayload;
} else {
$authUri = rtrim($baseUrl, '/') . '//auth#' . $encodedPayload;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe ternary conditional would be more clear:

Suggested change
if (str_starts_with($baseUrl, 'http')) {
$authUri = rtrim($baseUrl, '/') . '/auth#' . $encodedPayload;
} else {
$authUri = rtrim($baseUrl, '/') . '//auth#' . $encodedPayload;
}
$fragment = (str_starts_with($baseUrl, 'http') ? '//' : '/') . 'auth#';
$authUri = rtrim($baseUrl, '/') . $fragment . $encodedPayload;


public function assertCsrf(bool $jsonError = true): void
{
$headers = array_change_key_case(getallheaders());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Explicit is better than implicit:

Suggested change
$headers = array_change_key_case(getallheaders());
$headers = array_change_key_case(getallheaders(), CASE_LOWER);

return (new AuthTokenValidatorBuilder($logger))
->withSiteOrigin(new Uri($this->config->get('origin_url')))
->withTrustedCertificateAuthorities(...$this->trustedIntermediateCACertificates())
->withOcspRequestTimeout(5)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is explicit OCSP timeout required here, can we omit this and rely on the default instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, we can, removed. Default: src/validator/AuthTokenValidatorBuilder.php:125

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also used prettier

Comment on lines +252 to +255
<code
>~/Library/Containers/eu.web-eid.web-eid/Data/Library/Application\
Support/RIA/web-eid/web-eid.log</code
>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Formatting issue, remove line breaks from HTML tags:

Suggested change
<code
>~/Library/Containers/eu.web-eid.web-eid/Data/Library/Application\
Support/RIA/web-eid/web-eid.log</code
>
<code>
~/Library/Containers/eu.web-eid.web-eid/Data/Library/Application\
Support/RIA/web-eid/web-eid.log
</code>

Reformat with a HTML formatting tool for consistent formatting.

in macOS
</li>
<li>
<code
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Formatting issue here as well, tags have line breaks inside.

of Safari in macOS
</li>
<li>
<code
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Formatting issue here as well, tags have line breaks inside.

<p>
Technical overview of the solution is available in the project
<a href="https://github.com/web-eid/web-eid-system-architecture-doc"
>system architecture document</a
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Formatting issue here as well, tags have line breaks inside.

Comment on lines +75 to +76
} catch (Throwable) {
throw new CertificateDecodingException("'{$fieldName}' decode failed");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally the recommendation is that lower layers like current library code should catch Exceptions, not Throwables. Throwables should be caught at the outer application layer.

Also, would it help to include the original exception?

Suggested change
} catch (Throwable) {
throw new CertificateDecodingException("'{$fieldName}' decode failed");
} catch (Throwable $e) {
throw new CertificateDecodingException($e, "'{$fieldName}' decode failed");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also used prettier

}
} catch (UserCertificateOCSPCheckFailedException $e) {
throw $e;
} catch (Throwable $e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same Throwable problem in existing code.

}

private static function checkNonce(OcspRequest $request, OcspBasicResponse $basicResponse): void
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Broken indents, reformat with PHP formatting tool.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Used prettier


if ($signingCertificates === null || empty($signingCertificates)) {
throw new AuthTokenParseException(
"'unverifiedSigningCertificates' field is missing, null or empty for format 'web-eid:1.1'"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can unverifiedSigningCertificates legitimately be empty, for example when the signing certificate does not exist on the eID token or the reader cannot read the signing cert etc? How did you specify this? (This applies to .NET and Java, too.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In the current web-eid:1.1, unverifiedSigningCertificates is expected to be present and contain at least one entry. The PHP, Java and .NET validators all enforce that intentionally.
This is based on the current token format definition (will be also in the readme).


try {
$loaded = $subjectCertificate->loadX509($authToken->getUnverifiedCertificate());
} catch (Throwable $e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another Throwable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also used prettier

…ort for web-eid example

Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
…bile auth error layout

Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
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.

2 participants