Setup for Totalview Authentication

To enable Totalview Authentication for Totalview Reports you need to have a valid installation of Totalview Suite 2021 or newer running with Totalview Authentication.

Setup Reports

Find Totalview Reports folder and open the config file called “web.config” and set these fields.

Set UseTotalviewAuthentication to true
Set Authority to the url of your Totalview Authentication server
Set ClientSecret to secret – or the value store in the Totalview Database registered by Totalview Authentication. It is recommended to generate a new Secret and add it to the TotalviewDB ClientSecrets table (See below how to generate one)
Set RedirectUri to http(s)://[PUBLIC URL OF REPORTS]/authorization-code/callback
Set PostLogoutRedirectUri to http(s)://[PUBLIC URL OF REPORTS]

Example:

<appSettings>
    <add key="ConnectionString" value="[SOME CONNECTION STRING]" />
    <add key="UseTotalviewAuthentication" value="true" />
    <add key="Authority" value="https://formula.totalview.cloud/TotalviewAuthentication"/>
    <add key="ClientSecret" value="secret"/>
    <add key="RedirectUri" value="https://formula.totalview.cloud/reports/authorization-code/callback"/>
    <add key="PostLogoutRedirectUri" value="https://formula.totalview.cloud/reports"/>
</appSettings>

Make sure you remove authentication and authorization from the system.web section. Should look something like this:.

<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />

    <globalization culture="en-GB" uiCulture="en-GB" />
</system.web>

Remove every location element from the file. The file should look something like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<appSettings>
    <add key="ConnectionString" value="[SOME CONNECTION STRING]" />
    <add key="UseTotalviewAuthentication" value="true" />
    <add key="Authority" value="https://formula.totalview.cloud/TotalviewAuthenticationIS"/>
    <add key="ClientSecret" value="secret"/>
    <add key="RedirectUri" value="https://formula.totalview.cloud/reports/authorization-code/callback"/>
    <add key="PostLogoutRedirectUri" value="https://formula.totalview.cloud/reports"/>
</appSettings>
<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />

    <globalization culture="en-GB" uiCulture="en-GB" />
</system.web>
<system.webServer>
    <httpProtocol>
    <customHeaders>
        <remove name="X-UA-Compatible" />
        <add name="X-UA-Compatible" value="IE=edge" />
    </customHeaders>
    </httpProtocol>
    <handlers>
    <remove name="OPTIONSVerbHandler" />
    <remove name="TRACEVerbHandler" />
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <staticContent>
    <remove fileExtension=".ts" />
    <mimeMap fileExtension=".ts" mimeType="application/x-typescript" />
    </staticContent>
</system.webServer>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Fonlow.TypeScriptCodeDom" publicKeyToken="cf59ce9d94b04b8a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.1.0" newVersion="1.6.1.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Fonlow.Poco2Ts" publicKeyToken="cf59ce9d94b04b8a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.1.0" newVersion="1.6.1.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
    </dependentAssembly>
    </assemblyBinding>
</runtime>

<!-- swap commented out lines in or out to enable/disable debug logging -->
<nlog xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true" throwExceptions="true" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
    <target name="asyncSimpleFile" xsi:type="AsyncWrapper">
        <!--<target xsi:type="File" name="simpleFile" fileName="${basedir}/logs/${shortdate}.log" createDirs="true" />-->
        <target xsi:type="File" name="simpleFile" fileName="${basedir}/logs/${shortdate}.log" createDirs="true" layout="${time} ${uppercase:${level}} ${message}" />
    </target>
    <target name="asyncFullExceptionFile" xsi:type="AsyncWrapper">
        <target xsi:type="File" name="fullExceptionFile" fileName="${basedir}/logs/${shortdate}.log" createDirs="true" layout="${time} ${uppercase:${level}}${newline}              Call Site........: ${callsite}${newline}              Exception Type...: ${exception:format=Type}${newline}              Exception Message: ${exception:format=Message}${newline}              Stack Trace......: ${exception:format=StackTrace}${newline}" />
    </target>
    </targets>
    <rules>
    <!--<logger name="*" minlevel="Debug" writeTo="asyncSimpleFile" />-->
    <logger name="*" minlevel="Info" maxlevel="Info" writeTo="asyncSimpleFile" />
    <logger name="*" minlevel="Warn" writeTo="asyncFullExceptionFile" />
    </rules>
</nlog>
</configuration>

Go to the Totalview Database and in the “ClientRedirectUris” and “ClientPostLogoutRedirectUris” tables update the registered urls for the Totalview Reports client. They should be the same as registered in the Web.Config

Generate client secret

This will generate the value for a client secrete ‘secret’, and can be inserted into the ClientSecrets table.

DECLARE @HASHBYTES VARBINARY(128) = hashbytes('sha2_256', 'secret')
SELECT cast(N'' as xml).value('xs:base64Binary(sql:variable("@HASHBYTES"))', 'varchar(128)');