Skip to content

NFC-99 Web eID for mobile support#64

Open
SanderKondratjevNortal wants to merge 1 commit intoweb-eid-mobilefrom
NFC-99
Open

NFC-99 Web eID for mobile support#64
SanderKondratjevNortal wants to merge 1 commit intoweb-eid-mobilefrom
NFC-99

Conversation

@SanderKondratjevNortal
Copy link

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

@SanderKondratjevNortal SanderKondratjevNortal changed the base branch from main to web-eid-mobile November 27, 2025 11:05
@SanderKondratjevNortal SanderKondratjevNortal force-pushed the NFC-99 branch 2 times, most recently from 0315bc1 to 076734c Compare November 27, 2025 12:55
…eid example

Signed-off-by: Sander Kondratjev <sander.kondratjev@nortal.com>
JsonSerializer.Serialize(authToken.SupportedSignatureAlgorithms)));
}

var identity = new ClaimsIdentity(claims,CookieAuthenticationDefaults.AuthenticationScheme);
Copy link
Member

Choose a reason for hiding this comment

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

Formatting issue, missing space:

Suggested change
var identity = new ClaimsIdentity(claims,CookieAuthenticationDefaults.AuthenticationScheme);
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);


const path = window.location.pathname;
let endpoint;
if (path === "/sign/mobile/certificate") {
Copy link
Member

Choose a reason for hiding this comment

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

As discussed during Java code review, you can just validate the path and then reuse it directly:

const path = window.location.pathname;
const allowedEndpoints = ["/sign/mobile/certificate", "/sign/mobile/signature"];
if (!allowedEndpoints.includes(path)) {
    const error = new Error("Unexpected callback path: " + path);
    error.code = "INVALID_CALLBACK_PATH";
    throw error;
}

method: "POST",
headers: {
"Content-Type": "application/json",
"RequestVerificationToken": csrf
Copy link
Member

@mrts mrts Feb 12, 2026

Choose a reason for hiding this comment

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

Consider using the same pattern as with other pages (needs meta tag with id also):

Suggested change
"RequestVerificationToken": csrf
[csrfHeaderName]: csrf

};
}

private static string Base64UrlEncode(string input)
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed given that WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(input)) exists?

.Replace("=", "");
}

private string BuildMobileRequestUri(string path, string encoded)
Copy link
Member

Choose a reason for hiding this comment

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

Can we make code more DRY by extracting this into utility/extension method and reusing in all places (MobileAuthInitController etc)?

<PackageReference Include="System.Runtime.Caching" Version="8.0.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="WebEid.Security" Version="1.2.0" />
<ProjectReference Include="..\..\..\src\WebEid.Security\WebEid.Security.csproj" />
Copy link
Member

Choose a reason for hiding this comment

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

Leave the previous line with a comment as well so that it serves as an example how to use the library in a real project.

*/
namespace WebEid.Security.AuthToken
{
using Newtonsoft.Json;
Copy link
Member

@mrts mrts Feb 12, 2026

Choose a reason for hiding this comment

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

Maybe we should use .NET built-in JSON support (System.Text.Json) instead of Newtonsoft in the new version?

/// They are used by AuthTokenValidator internally and are not part of the public API.
/// </summary>
internal interface ISubjectCertificateValidator
public interface ISubjectCertificateValidator
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make this public?

using WebEid.Security.Util;

internal sealed class SubjectCertificateNotRevokedValidator : ISubjectCertificateValidator
public sealed class SubjectCertificateNotRevokedValidator : ISubjectCertificateValidator
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make this public?

using Org.BouncyCastle.Security;

internal sealed class SubjectCertificatePolicyValidator : ISubjectCertificateValidator
public sealed class SubjectCertificatePolicyValidator : ISubjectCertificateValidator
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make this public?

using WebEid.Security.Exceptions;

internal sealed class SubjectCertificateTrustedValidator : ISubjectCertificateValidator
public sealed class SubjectCertificateTrustedValidator : ISubjectCertificateValidator
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make this public?

/// Represents an ordered batch of subject certificate validators that are executed sequentially
/// during authentication token validation.
/// </summary>
public sealed class SubjectCertificateValidatorBatch
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make this public?

/// <summary>
/// Determines whether this validator supports the specified token format.
/// </summary>
public virtual bool Supports(string format) =>
Copy link
Member

Choose a reason for hiding this comment

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

As in Java, to make code more DRY, use a template method getSupportedFormatPrefix() and implement it in AuthTokenV1Validator and AuthTokenV11Validator:

public override bool Supports(string format) =>
            format != null &&
            format.StartsWith(getSupportedFormatPrefix());

public string getSupportedFormatPrefix() => V1_SUPPORTED_TOKEN_FORMAT_PREFIX;

/// <summary>
/// Determines whether this validator supports the specified token format.
/// </summary>
public override bool Supports(string format) =>
Copy link
Member

Choose a reason for hiding this comment

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

As in Java:

Suggested change
public override bool Supports(string format) =>
protected override string getSupportedFormatPrefix() => V11_SUPPORTED_TOKEN_FORMAT_PREFIX;

@@ -0,0 +1,236 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

In general, please apply all review comments from Java PR web-eid/web-eid-authtoken-validation-java#82.

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