Click or drag to resize

How to Integrate Visual Guard in Angular Server Application

To integrate Visual Guard in your application you must:
  • Add the assemblies of Visual Guard as references of your project.
  • Insert the code to enable the security in your application.
  • Create a Visual Guard repository and declare your application. This repository will contain all security items (users, roles, permissions ...) of your application.
  • Generate the Visual Guard configuration files by using the Visual Guard console. These configuration files will be needed to connect your application to the repository.
Referencing Visual Guard assemblies

In order to use Visual Guard, you must add references to Visual Guard assemblies:

  • Open the solution of your project in Visual Studio.
  • In the solution explorer, expands the project node.
  • Right-click the Project node for the project and select Add Reference from the shortcut menu.
  • In .Net tab, select the 5 assemblies
    1. Novalys.VisualGuard.Security
    2. Novalys.VisualGuard.Security.Angular.dll
    3. Novalys.VisualGuard.Security.Core.dll
    4. Novalys.VisualGuard.Security.<RepositoryType> (Files, SQLServer or Oracle)
    5. Novalys.VisualGuard.Security.WebForm.Core.dll
    And, then click the Select button, and then click the OK button

If the assemblies does not appear in this list you can use the Browse tab and select them in the directory <Visual Guard installation directory>/bin/  for respective target platform .net applications (x86, x64 or Any CPU). <Visual Guard installation directory>/bin/ contains 'Any CPU' assemblies.

Add References Angular

Description of Visual Guard assemblies:

  • Novalys.VisualGuard.Security contains the main Visual Guard classes.
  • Novalys.VisualGuard.Security.Files contains the classes needed to access to a file based repository.
  • Novalys.VisualGuard.Security.SQLServer contains the classes needed to access to a repository stored in a Microsoft SQLServer database (SQLServer 2005 or higher). Available only in Visual Guard Enterprise Edition
  • Novalys.VisualGuard.Security.Oracle contains the classes needed to access to a repository stored in an Oracle database (8i or higher). Available only in Visual Guard Enterprise Edition
  • Novalys.VisualGuard.Security.Angular.dll contains all classes based on Angular control. This assembly is needed only if you want to integrate Visual Guard in your angular application.
  • Novalys.VisualGuard.Security.Core contains all classes required to support .Net Core applications. This assembly is needed only if you want to integrate Visual Guard in .net core applications.
  • Novalys.VisualGuard.Security.WebForm.Core.dll contains all classes required to support Web applications for .net core. This assembly is needed only if you want to integrate Visual Guard in .net core web applications.

Note Note

In the list of assemblies, Visual Studio can display different versions of the Visual Guard assemblies. You must select the assembly corresponding to the version of the framework and target (x64, x32, or Any CPU) used in your project.

Note Note

Please make sure Visual Guard configuration files are properly generated

  • VisualGuardConfiguration.config
  • VisualGuardConfiguration.exe.config
Note Note

Once the Visual Guard assemblies are referenced into project, you need to mark "Copy Local" property to "true" for each assembly.

Install packages using Nuget Packages Manager
  • Microsoft.AspNetCore.App 2.2.0
  • System.Configuration.ConfigurationManager 4.5.0
  • System.Drawing.Common 4.5.1
  • System.DirectoryServices 4.5.0
Apply changes in your code

1) Import namespace references as follows

C#
using Novalys.VisualGuard.Security.Angular.Middlewares;

Angular namespace

2) Add following lines in 'Startup.cs'

  • In Method - ConfigureServices()
    C#
    var mvcBuilder = services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
    services.AddVGConfig(this.Configuration, mvcBuilder);
    Angular startup
  • In Method - Configure(), Add below lines before “app.UseMvc();”

    C#
    app.UseVGAuthentication();
    app.UseVGCors();

    Angular startup 2

3) Add new properties in appsettings.json for the list of allowed client hosts and Server hosts that can make an authentication requests to Visual Guard Angular Security APIs:

"VGCorsOriginServerHost": "http://localhost:8888",

"VGCorsOriginClientHosts": "http://localhost:8866,http://localhost:8877",

Angular appsettings
How to secure WebService with Visual Guard
See Also