Enabling terms of use / EULA
CGU is the French term for "conditions générales d'utilisation" (terms of use). EULA stands for End User Licence Agreement. In Lagoon, both terms refer to the agreement that the end user must accept before using the application.
Overview
Some applications must request the end user's acceptance of an agreement, for example to inform them of specific processing of their data. The terms of use are then displayed in a popup when the application starts and remain until accepted.
Lagoon supports:
- displaying the terms of use / EULA content;
- validation by the end user;
- a static mode based on the client project's
Dico.xml; - a dynamic mode based on the database;
- a shared mode based on server-side HTML files.
By default, a Lagoon application does not define any terms of use. If your application requires them, you must enable the option, choose an operating mode, and provide the text in the supported languages.
Enable the acceptance request
In the Client project, enable RequireEulaConsent in Main.cs.
public class Main : LgCustomApplication
{
protected override void OnConfigureBehavior(ApplicationBehavior app)
{
// Demande l'acceptation des CGU avant l'utilisation de l'application.
app.RequireEulaConsent = true;
}
}
The demo typically enables this configuration only in RELEASE.
public class Main : LgCustomApplication
{
protected override void OnConfigureBehavior(ApplicationBehavior app)
{
#if RELEASE
// Active les CGU en production et charge leur contenu depuis le serveur.
app.RequireEulaConsent = true;
app.EulaFromServer = true;
#endif
}
}
Static mode: content in Dico.xml
Static mode is the default mode. The content is defined in the Client project's Dico.xml with the EulaContent and EulaVersion keys.
<string key="EulaContent" fr="Contenu des conditions générales d'utilisation" en="Content of End User Licence Agreement" />
<string key="EulaVersion" fr="1" en="1" />
| Key | Description |
|---|---|
EulaContent | Content of the terms of use. The content can include HTML formatting. |
EulaVersion | Version of the terms of use. If the value changes between two releases, users must accept the terms of use again. |
The version number must be identical regardless of language, since revalidation is global to the application.
Dynamic mode: content in the database
In this mode, the terms of use are stored in the database and synchronized with the client dictionary when the application starts.
public class Main : LgCustomApplication
{
protected override void OnConfigureBehavior(ApplicationBehavior app)
{
// Demande les CGU et charge leur contenu depuis le serveur.
app.RequireEulaConsent = true;
app.EulaFromServer = true;
}
}
The Eula table contains the terms-of-use content per language and the current version. You can initialize these values in OnModelCreating.
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Initialise une version commune et un contenu par langue supportée.
builder.Entity<Eula>().HasData(new Eula() { Id = Eula.VersionKey, Value = "1" });
builder.Entity<Eula>().HasData(new Eula() { Id = "fr", Value = "CGU" });
builder.Entity<Eula>().HasData(new Eula() { Id = "en", Value = "EULA" });
}
The Eula model exposes the Id and Value properties, as well as the Eula.VersionKey and Eula.ContentKey constants.
Modifying the dynamic terms of use
Lagoon does not ship a client-side administration page for the terms of use. You can add one to your application. On the server side, the ILgEulaManager service allows you to manage the content.
[ApiController]
[Route("api/[controller]")]
public class EulaController : LgControllerBase
{
private readonly ILgEulaManager _eulaManager;
public EulaController(ILgEulaManager eulaManager)
{
_eulaManager = eulaManager;
}
}
| Method | Description |
|---|---|
GetAllEula() | Returns the list of configured terms of use, with sanitized HTML content. |
SetEula(string languageKey, string eula, bool updateVersion = true) | Creates or updates the text for a language (the HTML content is sanitized before saving). With updateVersion set to true, users will need to revalidate. |
GetEulaVersion() | Returns the current version of the terms of use. |
ForceEulaRevalidation() | Forces a revalidation of the terms of use. |
This service is used for dynamic mode. In static mode, edit Dico.xml. In shared mode, edit the source HTML files.
Shared mode: server-side HTML files
In this mode, the terms of use are extracted from files, stored in the database, and synchronized with the client dictionary at startup. When a source file is modified, applications using it will request revalidation.
On the client side, use the same configuration as dynamic mode:
public class Main : LgCustomApplication
{
protected override void OnConfigureBehavior(ApplicationBehavior app)
{
// Les CGU sont chargées depuis le serveur.
app.RequireEulaConsent = true;
app.EulaFromServer = true;
}
}
On the server side, configure a file per language in appsettings.json.
{
"Lagoon": {
"EulaFiles": [
{
"LanguageKey": "en",
"FilePath": "C:\\Temp\\SmallApps_GDPR.htm"
},
{
"LanguageKey": "fr",
"FilePath": "C:\\Temp\\SmallApps_GDPR - FR.htm"
},
{
"LanguageKey": "it",
"FilePath": "C:\\Temp\\SmallApps_GDPR - IT.htm"
}
]
}
}
| Key | Description |
|---|---|
LanguageKey | Language code of the file, for example fr, en, or it. |
FilePath | Path of the HTML file containing the terms-of-use text. |
HTML content sanitization
The terms of use are displayed to all users as HTML. In dynamic mode and shared mode, the server therefore sanitizes their content with the LgHtmlSanitizer service: scripts, event handlers, javascript: URLs, forms, and frames are removed.
- On write:
SetEulasaves the sanitized content. - On read:
GetAllEulaalso sanitizes content stored before sanitization was introduced, and content from shared-mode files. The database is not modified.
Content that contains an html or body tag is treated as a complete document: style elements (themselves sanitized), the class attribute, and @page, @media, and @font-face rules are preserved, so that a file exported from a word processor keeps its layout. Other head elements (meta, title, link, script…) are removed. Verify the rendering of your .htm files after the update.
Clients that have already cached the terms of use will download them once again, without user revalidation.
A custom implementation of ILgEulaManager does not benefit from this sanitization: inject LgHtmlSanitizer and call it yourself. Static-mode content (Dico.xml) is part of the application and is not sanitized.