General fix x problemi auth "ballerina"

This commit is contained in:
Samuele E. Locatelli
2018-12-01 15:17:33 +01:00
parent 77c16c29b3
commit 87bd80ae45
8 changed files with 65 additions and 19 deletions
+23
View File
@@ -0,0 +1,23 @@
using SteamWare;
using System;
namespace C_TRACK.App_Start
{
public class MyStartup
{
public static void Init()
{
logger.lg.scriviLog("Esecuzione MyStartup.init()", tipoLog.STARTUP);
try
{
// inizializzo appConf prima di tutto il resto...
memLayer.ML.resetAppConf();
logger.lg.scriviLog("Completata esecuzione preliminare setup AppConf", tipoLog.STARTUP);
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Eccezione in fase di INIT preliminare applicazione{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
}
}
}
+1
View File
@@ -368,6 +368,7 @@
<Link>VersGen.cs</Link>
</Compile>
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\MyStartup.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="barcode.aspx.cs">
<DependentUpon>barcode.aspx</DependentUpon>
+5 -5
View File
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using C_TRACK.App_Start;
using System;
using System.Web;
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
namespace C_TRACK
{
@@ -16,6 +13,9 @@ namespace C_TRACK
// Codice eseguito all'avvio dell'applicazione
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// avvio il metodo init x applicazione...
MyStartup.Init();
}
}
}
+14 -6
View File
@@ -41,8 +41,20 @@
</scripting>
</system.web.extensions>-->
<appSettings>
<add key="serializeSession" value="true" />
<add key="CodModulo" value="C.TRACK" />
<add key="cacheOnRedis" value="true"/>
<add key="maxAgeAppConf_min" value="15"/>
<add key="_logDir" value="~/logs/"/>
<add key="logMitigSec" value="30"/>
<add key="serializeSession" value="true" />
<add key="_navMaxChar" value="20" />
<!--Sito-->
<add key="baseUrl" value="http://IIS02/C.TRACK/" />
@@ -59,13 +71,9 @@
<add key="_righeDataGridMed" value="15" />
<add key="_righeDataGridShort" value="10" />
<add key="_fromEmail" value="xps@steamware.net" />
<add key="_logDir" value="./logs/" />
<add key="_logLevel" value="6" />
<add key="_logMaxMb" value="30" />
<add key="_allowForceUser" value="true" />
<add key="_safePages" value="chLang.aspx#jumper.aspx#unauthorized.aspx#allegati.aspx#forceUser.aspx#login.aspx#test.aspx" />
<add key="_safePages" value="chLang#jumper#unauthorized#forceUser#login#test#UserAdmin" />
<add key="_loginPages" value="UserAdmin" />
<add key="PageNoIndex" value="Test#UserAdmin#Login" />
<add key="_commonPages" value="menu.aspx" />
<add key="_titoloPagina" value="C.TRACKS" />
<add key="appName" value="C.TRACKS" />
@@ -22,12 +22,13 @@ namespace C_TRACK.WebUserControls
bool fatto = false;
string DeviceName = "";
string IPv4 = "";
string CodOpr = "";
try
{
UserAuthKey = Request["UserAuthkey"];
email = Request["USER_NAME"];
// salvo OPR (se c'è in link di auth...)
string CodOpr = Request["CodOpr"];
CodOpr = Request["CodOpr"];
memLayer.ML.setSessionVal("CodOpr", CodOpr);
userAgent = Request.UserAgent;
}
@@ -50,7 +51,8 @@ namespace C_TRACK.WebUserControls
}
if (fatto)
{
Response.Redirect("Default");
Response.Redirect("Login");
//Response.Redirect("Default");
}
else
{
@@ -36,7 +36,7 @@ namespace C_TRACK.WebUserControls
// controllo pagina...
bool pageAuth = devicesAuthProxy.stObj.isPageEnabled(lastPage);
// controllo pag auth...
if (!pageAuth && memLayer.ML.confReadString("PageNoIndex").ToLower().IndexOf(lastPage.ToLower()) < 0)
if (!pageAuth && memLayer.ML.confReadString("_safePages").ToLower().IndexOf(lastPage.ToLower()) < 0)
{
Response.Redirect("~/login");
}
+3 -1
View File
@@ -10,8 +10,10 @@ namespace C_TRACK
// aggiorno vocabolario
DataWrap.DW.resetVocabolario();
#if false
// reset dati in cache x DbConfig...
memLayer.ML.resetAppConf();
memLayer.ML.resetAppConf();
#endif
// svuoto session e cache per rileggere i dati da Db
Session.RemoveAll();
}
+14 -4
View File
@@ -19,6 +19,16 @@ namespace XPS
return pagina;
}
}
/// <summary>
/// Elenco pagine "safe" da web.config
/// </summary>
protected string safePages
{
get
{
return memLayer.ML.confReadString("_safePages").ToLower();
}
}
protected void Page_Load(object sender, EventArgs e)
{
@@ -27,15 +37,15 @@ namespace XPS
{
Page.Title = Request.Url.ToString();
// se ho cambiato pagina registro...)
if (devicesAuthProxy.pagPrecedente != titolo)
if (devicesAuthProxy.pagPrecedente.ToLower() != titolo.ToLower())
{
devicesAuthProxy.pagPrecedente = devicesAuthProxy.pagCorrente;
}
// salvo pagina corrente
devicesAuthProxy.pagCorrente = titolo;
}
// SOLO se la pagina NON E' "safe"...
if (memLayer.ML.confReadString("PageNoIndex").ToLower().IndexOf(titolo.ToLower()) < 0)
// SOLO se la pagina NON E' "safe"... e NON E' login
if (safePages.IndexOf(titolo.ToLower()) < 0 || titolo.ToLower() == "login")
{
bool userOk = checkUser();
bool pageOk = checkPageIsAuth();
@@ -83,7 +93,7 @@ namespace XPS
private bool checkPageIsAuth()
{
bool allOk = false;
bool pageSafe = (memLayer.ML.confReadString("PageNoIndex").ToUpper().IndexOf(titolo.ToUpper()) >= 0);
bool pageSafe = (memLayer.ML.confReadString("_safePages").ToUpper().IndexOf(titolo.ToUpper()) >= 0);
bool pageAuth = devicesAuthProxy.stObj.isPageEnabled(titolo);
allOk = (pageSafe || pageAuth);
return allOk;