Configuration File
  • 11 Sep 2024
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Configuration File

  • Dark
    Light
  • PDF

Article summary

Configuration File

The Safran API comes with a file where you can adjust and configure the behavior of the Safran API.

application.json

This is the current configuration file for the Safran API.

web.config

This implementation also has a web.config file, and it needs to be left as is.



Here is a sample file of the needed application.json file.

appsettings.json file
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",

  "ConnectionStrings": {
      "default": "Data Source=127.0.0.1:1521/SafranDatabase;User Id=SAFRANSA;Password=safran;Max Pool Size=200;",

      "default_mss": "Server=127.0.0.1;Database=SafranDatabase;User Id=SAFRANSA;Password=safran;",

      "default_ora": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=SafranDatabase)));User Id=SAFRANSA;Password=safran;"
    
  },

  "AppSettings": {
    "_comment_SafranWebApiUsers": "domain\\ADgroup or just ADgroup (then users current domain is assumed",
    "SafranWebApiUsers": "SafranWebApiUsers",

    "_comment_SafranWebApiAuthenticationType": "Use 'None' for no authentication, 'Basic' for basic database 'user' table authentication, or 'Kerberos' for Kerberos Windows Active Directory authentication",
    "SafranWebApiAuthenticationType": "none",

    "_comment_SafranWebAPIOwnerVerificationDuringApiCalls": "Use True to verify that given owner in a API call matches the owner of the network. User False to not use this functionality",
    "SafranWebAPIOwnerVerificationDuringApiCalls": "false",

    "jsonwebtoken": {
      "key": "ThisismySecretKey2749C6AE486C6E783BBADF7F8BADF",
      "issuer": "Safran",
      "audienceclaim": "e8a494f5-f180-dead-beef-762a85ce7d0f"
    }
  },

  "tracelog": {
    "serilog": {
      "_comment_serilog": "Valid values for serilog: Verbose, Debug, Information, Warning, Error, Fatal",
      "minimum_level": "Debug",
      "write_to_file_path": "c:\\temp\\SafranAPI.{Date}.Log.txt"
    },
    "safranlog": {
      "api": "info,call",
      "controller": "info,sql,dbconnection,data",
      "service": "info,sql,dbconnection,data",
      "repositories": "info,sql,dbconnection,data",
      "data": "info,sql,dbconnection,data"
    }
  }
}

web.config

This used to be the configuration file prior moving to .Net Core. This file is no longer used. Your settings need to be moved to the new file “Application.json”. This is only valid for version 7.3 and earlier.


Here is a sample file of the web.config file.

web.config file
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301879
  -->
<configuration>
  <connectionStrings>
    <add name="default" connectionString="Data Source=OracleTest.64;User ID=safransa;Password=safran" providerName="System.Data.OracleClient" />
    <!--<add name="default" connectionString="Data Source=MSSTest.64;Initial Catalog=SafranDatabase;User ID=safransa;Password=safran" providerName="System.Data.SqlClient" />-->
    
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="SqlCommandTimeOut" value="60" />
    
    <!-- domain\ADgroup or just ADgroup (then users current domain is assumed -->
    <add key="SafranWebApiUsers" value="SafranWebApiUsers" />
    <!-- Use "None" for no authentication, "Basic" for basic database 'user' table authentication, or "Kerberos" for Kerberos Windows Active Directory authentication-->
    <add key="SafranWebApiAuthenticationType" value="None" />
    <!-- Use True to verify that given owner in a API call matches the owner of the network. User False to not use this functionality -->
    <add key="SafranWebAPIOwnerVerificationDuringApiCalls" value="false" />
    
    <!--Valid values for serilog: Verbose, Debug, Information, Warning, Error, Fatal.-->
    <add key="serilog:minimum-level" value="Debug" />
    <add key="serilog:write-to:File.path" value="c:\temp\SafranAPI.{Date}.Log.txt" />
    <!-- Valid values for area: info, sql, dbconnection, data, call -->
    <add key="safranlog.api"          value="info,call" />
    <add key="safranlog.controller"   value="info,sql,dbconnection,data" />
    <add key="safranlog.service"      value="info,sql,dbconnection,data" />
    <add key="safranlog.repositories" value="info,sql,dbconnection,data" />
    <add key="safranlog.data"         value="info,sql,dbconnection,data" />
  </appSettings>
  
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxQueryStringLength="2048" />
    <authentication mode="Windows"></authentication>
  </system.web>
  
  <system.webServer>
    <modules>
      <remove name="UrlRoutingModule-4.0" />
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
    </modules>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <security>
       <requestFiltering>
         <requestLimits maxQueryString="2048" />
       </requestFiltering>
    </security>    
  </system.webServer>
  
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>


Was this article helpful?