Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b20c335
Updated identification examples
gabriel-sadrack Apr 23, 2026
74964e5
Update RestPki widget and adjust session API parameter passing
gabriel-sadrack Apr 30, 2026
5655fe3
[RPNG-643] Refactored SessionsController into specialized biometric c…
gabriel-sadrack May 12, 2026
4971663
[RPNG-643] Migrated to automatic configuration properties scanning
gabriel-sadrack May 12, 2026
88a5d34
[RPNG-643] Migrated biometric controllers to constructor injection
gabriel-sadrack May 12, 2026
5cac123
[RPNG-643] Simplified biometric session endpoints; removed DTOs
gabriel-sadrack May 12, 2026
3a5bab9
[RPNG-643] Refactor Util to RestBioConfig and expose RestBioService a…
gabriel-sadrack May 12, 2026
c8d6ae8
[RPNG-643] Updated sample biometric API controllers
gabriel-sadrack May 12, 2026
ba11277
[RPNG-643] Refined comments and examples in bio sample controllers
gabriel-sadrack May 13, 2026
871cd7d
[RPNG-643] Updated biometric session parameter binding to @ModelAttri…
gabriel-sadrack May 13, 2026
d1114a6
[RPNG-643] Adjusted backend and frontend parameters and endpoints
gabriel-sadrack May 13, 2026
9ec387b
[RPNG-643] Refactored sample API endpoint routing
gabriel-sadrack May 15, 2026
a8f27b2
[RPNG-643] Added sample controllers for bio identification
gabriel-sadrack May 15, 2026
bb1a4da
[RPNG-643] Added sample frontend for bio identification
gabriel-sadrack May 15, 2026
1fa366f
[RPNG-643] Bumped client-lib version to 1.4.0
gabriel-sadrack May 25, 2026
6c42975
Added trustedOrigin config in application.yml
gabriel-sadrack May 25, 2026
f2930ef
[RPNG-643] Reverted Java version to 21
gabriel-sadrack May 25, 2026
73dc4ee
[RPNG-643] Adjusted sample API routes
gabriel-sadrack Jun 2, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using Lacuna.RestPki.Api.Bio;
using Lacuna.RestPki.Api.Bio.Sessions;
using Lacuna.RestPki.Client;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using RestBioAspNetCoreSample.Configuration;

namespace RestBioAspNetCoreSample.Controllers {

[ApiController]
[Route("/sample-api/sessions/authentication")]
public class SampleAuthenticationController(

IRestBioService restBioService,
IOptions<ExampleConfig> exampleConfig

) : ControllerBase {

[HttpPost]
public async Task<StartBioSessionResponse> StartAuthenticationSessionAsync([FromBody] BioSubjectReference bioSubjectReference) {

// This is an example of how to start an authentication session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// The response of the following call contains the session URL that
// will be loaded in the Widget to start the biometric session.

var response = await restBioService.StartAuthenticationSessionAsync(new() {
TrustedOrigin = exampleConfig.Value.TrustedOrigin,
Subject = bioSubjectReference,
// additional options for authenticationSession
});

// Although not mandatory, you may want to save the SessionId in your database
// along with your user/session information, as you can use this ID to retrieve
// the status of the session by later using the GetAuthenticationSessionStatusAsync()
// method. But at the end of the session, the Widget will return you a ticket
// that you can use to retrieve the session status without needing to store
// the SessionId.

// Available properties of the response:
_ = response.SessionUrl; // The URL to be loaded in the Widget to start the biometric session.
_ = response.SessionId; // The ID of the session.
_ = response.SessionType; // The type of the session (Authentication).

return response;
}

[HttpPost("completion")]
public async Task<BioAuthenticationSessionStatusModel> CompleteAuthenticationSessionAsync(CompleteBioSessionRequest request) {

// This is an example of how to complete an authentication session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// By calling the following endpoint, you will get the final status of the
// biometric session.

var result = await restBioService.CompleteAuthenticationSessionAsync(request.Ticket);

// Available properties of the result:
var sessionId = result.SessionId; // The ID of the session.

// Authentication-specific properties (the exact properties may vary based on the actual model structure):
// Note: The properties below are based on the liveness model and may need adjustment for authentication
// You should verify the actual properties available in BioAuthenticationSessionStatusModel

var success = result.Success; // Whether the biometric session was successful or not.

if (success == true) {
// The biometric session was successful and the user was authenticated.

} else if (success == false) {
// The biometric session was completed, but authentication failed.
// Here you may want to retry, lock the account, or implement other security measures.

} else {
// The biometric session is still in progress. This should not happen here,
// as the Widget will only provide a complete ticket when the session is completed
// (either successfully or not).
}

return result;
}

[HttpGet("status")]
public async Task<BioAuthenticationSessionStatusModel> GetAuthenticationSessionStatusAsync(Guid sessionId) {
return await restBioService.GetAuthenticationSessionStatusAsync(sessionId);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using Lacuna.RestPki.Api.Bio.Sessions;
using Lacuna.RestPki.Client;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using RestBioAspNetCoreSample.Configuration;

namespace RestBioAspNetCoreSample.Controllers {

[ApiController]
[Route("/sample-api/sessions/enrollment")]
public class SampleEnrollmentController(

IRestBioService restBioService,
IOptions<ExampleConfig> exampleConfig

) : ControllerBase {

[HttpPost]
public async Task<StartBioSessionResponse> StartEnrollmentSessionAsync(
[FromQuery] string subjectIdentifier,
[FromQuery] bool? captureIdentificationDocument = false,
[FromQuery] bool? dangerousOverrideIfAlreadyEnrolled = false
) {

// This is an example of how to start an enrollment session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// The response of the following call contains the session URL that
// will be loaded in the Widget to start the biometric session.

var response = await restBioService.StartEnrollmentSessionAsync(new() {
TrustedOrigin = exampleConfig.Value.TrustedOrigin,
SubjectIdentifier = subjectIdentifier,
// Additional properties for enrollment:
CaptureIdentificationDocument = captureIdentificationDocument ?? false,
DangerousOverrideIfAlreadyEnrolled = dangerousOverrideIfAlreadyEnrolled ?? false,

});

// Although not mandatory, you may want to save the SessionId in your database
// along with your user/session information, as you can use this ID to retrieve
// the status of the session by later using the GetEnrollmentSessionStatusAsync()
// method. But at the end of the session, the Widget will return you a ticket
// that you can use to retrieve the session status without needing to store
// the SessionId.

// Available properties of the response:
_ = response.SessionUrl; // The URL to be loaded in the Widget to start the biometric session.
_ = response.SessionId; // The ID of the session.
_ = response.SessionType; // The type of the session (Enrollment).

return response;
}

[HttpPost("completion")]
public async Task<BioEnrollmentSessionStatusModel> CompleteEnrollmentSessionAsync(CompleteBioSessionRequest request) {

// This is an example of how to complete an enrollment session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// By calling the following endpoint, you will get the final status of the
// biometric session.

var result = await restBioService.CompleteEnrollmentSessionAsync(request.Ticket);

// Available properties of the result:
var sessionId = result.SessionId; // The ID of the session.

// Enrollment-specific properties (the exact properties may vary based on the actual model structure):
// Note: The properties below are based on the enrollment model and may need adjustment for enrollment
// You should verify the actual properties available in BioEnrollmentSessionStatusModel

var success = result.Success; // Whether the biometric session was successful or not.

if (success == true) {
// The biometric session was successful and the user was enrolled.

// You may want to store SubjectID to be used later
_ = result.SubjectId;
} else if (success == false) {
// The biometric session was completed, but it was not successful.
// Here you may want to retry or increase an attempt counter of the user.

} else {
// The biometric session is still in progress. This should not happen here,
// as the Widget will only provide a complete ticket when the session is completed
// (either successfully or not).
}

return result;
}

[HttpGet("status")]
public async Task<BioEnrollmentSessionStatusModel> GetEnrollmentSessionStatusAsync(Guid sessionId) {
return await restBioService.GetEnrollmentSessionStatusAsync(sessionId);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Lacuna.RestPki.Api.Bio.Sessions;
using Lacuna.RestPki.Client;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using RestBioAspNetCoreSample.Configuration;

namespace RestBioAspNetCoreSample.Controllers {

[ApiController]
[Route("/sample-api/sessions/id-capture")]
public class SampleIdCaptureController(

IRestBioService restBioService,
IOptions<ExampleConfig> exampleConfig

) : ControllerBase {

[HttpPost]
public async Task<StartBioSessionResponse> StartIdentificationDocumentCaptureSessionAsync() {

// This is an example of how to start an identification document capture session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// The response of the following call contains the session URL that
// will be loaded in the Widget to start the biometric session.

var response = await restBioService.StartIdentificationDocumentCaptureSessionAsync(new() {
TrustedOrigin = exampleConfig.Value.TrustedOrigin
});

// Although not mandatory, you may want to save the SessionId in your database
// along with your user/session information, as you can use this ID to retrieve
// the status of the session by later using the GetIdentificationDocumentCaptureSessionStatusAsync()
// method. But at the end of the session, the Widget will return you a ticket
// that you can use to retrieve the session status without needing to store
// the SessionId.

// Available properties of the response:
_ = response.SessionUrl; // The URL to be loaded in the Widget to start the biometric session.
_ = response.SessionId; // The ID of the session.
_ = response.SessionType; // The type of the session (IdentificationDocumentCapture).

return response;
}

[HttpPost("completion")]
public async Task<IdentificationDocumentCaptureSessionStatusModel> CompleteIdentificationDocumentCaptureSessionAsync(CompleteBioSessionRequest request) {

// This is an example of how to complete an identification document session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// By calling the following endpoint, you will get the final status of the
// biometric session.

var result = await restBioService.CompleteIdentificationDocumentCaptureSessionAsync(request.Ticket);

// Available properties of the result:
var sessionId = result.SessionId; // The ID of the session.
var success = result.Success; // Whether the biometric session was successful or not.

if (success == true) {
// The biometric session was successful and the user captured an ID document that passed all checks.

// You may want to store the ID capture status to be used later
_ = result.IdCaptureStatus.Success; // Whether the user captured an ID document.

} else if (success == false) {
// The biometric session was completed, but it was not successful.
// Here you may want to retry or increase an attempt counter of the user.

} else {
// The biometric session is still in progress. This should not happen here,
// as the Widget will only provide a complete ticket when the session is completed
// (either successfully or not).
}

return result;
}

[HttpGet("status")]
public async Task<IdentificationDocumentCaptureSessionStatusModel> GetIdentificationDocumentCaptureSessionStatusAsync(Guid sessionId) {
return await restBioService.GetIdentificationDocumentCaptureSessionStatusAsync(sessionId);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using Lacuna.RestPki.Api.Bio.Identifications;
using Lacuna.RestPki.Api.Bio.Sessions;
using Lacuna.RestPki.Client;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using RestBioAspNetCoreSample.Configuration;

namespace RestBioAspNetCoreSample.Controllers {

[ApiController]
[Route("/sample-api/sessions/identification")]
public class SampleIdentificationController(

IRestBioService restBioService,
IOptions<ExampleConfig> exampleConfig

) : ControllerBase {

[HttpPost("identification2d")]
public async Task<BioIdentificationResponse> Identification2DAsync(BioIdentificationRequest request, Guid? subscriptionId = null) {
return await restBioService.IdentifyAsync(request, subscriptionId);
}

[HttpPost]
public async Task<StartBioSessionResponse> StartIdentificationAsync() {

// This is an example of how to start an identification session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// The response of the following call contains the session URL that
// will be loaded in the Widget to start the biometric session.

var response = await restBioService.StartIdentificationSessionAsync(new StartBioIdentificationSessionRequest {
TrustedOrigin = exampleConfig.Value.TrustedOrigin,
// Additional properties for identification session:
FaceCaptureProvider = Lacuna.RestPki.Api.FaceCaptureProviders.FaceTecLiveness3d
});


// Although not mandatory, you may want to save the SessionId in your database
// along with your user/session information, as you can use this ID to retrieve
// the status of the session by later using the GetIdentificationSessionCompletionAsync()
// method. But at the end of the session, the Widget will return you a ticket
// that you can use to retrieve the session status without needing to store
// the SessionId.

// Available properties of the response:
_ = response.SessionUrl; // The URL to be loaded in the Widget to start the biometric session.
_ = response.SessionId; // The ID of the session.
_ = response.SessionType; // The type of the session (Identification).

return response;
}

[HttpPost("completion")]
public async Task<BioIdentificationSessionStatusModel> GetIdentificationSessionCompletionAsync(CompleteBioSessionRequest request) {

// This is an example of how to complete an identification session.
// You must implement your own security measures to ensure that only users
// you want to have access to this endpoint can call it.

// By calling the following endpoint, you will get the final status of the
// biometric session.
var result = await restBioService.CompleteIdentificationSessionAsync(request.Ticket);

// Available properties of the result:
var sessionId = result.SessionId; // The ID of the session.
var success = result.Success; // Whether the biometric session was successful or not.

if (success == true) {
// The biometric session was successful and the identification process is complete.
// You can now trust that the person behind the camera is who they claim to be.

} else if (success == false) {
// The biometric session was completed, but the identification failed.
// Here you may want to retry, or implement other security measures.

} else {
// The biometric session is still in progress. This should not happen here,
// as the Widget will only provide a ticket when the session is finalized.
}

return result;
}

[HttpGet("status")]
public async Task<BioIdentificationSessionStatusModel> GetIdentificationSessionStatusAsync(Guid sessionId) {
return await restBioService.GetIdentificationSessionStatusAsync(sessionId);
}

}
}
Loading