mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added client side cache for static files.
Fixed upload error not showing during processing. Renamed default cookie names. Updated privacy policy to note no Piwik tracking, and new cookie names.
This commit is contained in:
parent
364898c8c5
commit
175eaa4762
@ -46,13 +46,8 @@
|
||||
<ul>
|
||||
<li><var>TeknikAuth</var> - Stores the authentication ticket for a login session.</li>
|
||||
<li><var>TeknikTrustedDevice_<username></var> - Used for determining if the browser has been trusted by the 2-Factor Auth system.</li>
|
||||
<li><var>__RequestVerificationToken</var> - Validation Token sent with every request to the server for Anti-Forgery purposes.</li>
|
||||
<li><var>TeknikAntiForgery</var> - Validation Token sent with every request to the server for Anti-Forgery purposes.</li>
|
||||
</ul>
|
||||
<h2>Analytics</h2>
|
||||
<p>
|
||||
We use <a href="http://piwik.org/">Piwik</a> to track user interaction with the site. We keep it hosted on the server locally, so no analytic data is leaving the server. This will store the first 2 bytes of your IP Address (e.g. 192.168.xxx.xxx) as an identifier. If you do not want to be tracked, enable Do Not Track in your browser (Recommended), or by unchecking below.
|
||||
</p>
|
||||
<iframe style="border: 0; height: 200px; width: 600px;" src="@(Config.PiwikConfig.API)index.php?module=CoreAdminHome&action=optOut&language=en"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -67,7 +62,7 @@
|
||||
gitFullUrl = gitUrl.ToString();
|
||||
}
|
||||
}
|
||||
<p><i>Last Modified February 15, 2017 - <a href="@gitFullUrl">View History</a></i></p>
|
||||
<p><i>Last Modified June 20th, 2018 - <a href="@gitFullUrl">View History</a></i></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
@ -55,7 +56,7 @@ namespace Teknik.Controllers
|
||||
// Get the Favicon
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
[ResponseCache(Duration = 31536000, Location = ResponseCacheLocation.Any)]
|
||||
[ResponseCache(Duration = 60 * 60 * 24, Location = ResponseCacheLocation.Any)]
|
||||
public IActionResult Favicon([FromServices] IHostingEnvironment env)
|
||||
{
|
||||
string imageFile = FileHelper.MapPath(env, Constants.FAVICON_PATH);
|
||||
@ -66,7 +67,7 @@ namespace Teknik.Controllers
|
||||
// Get the Logo
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
[ResponseCache(Duration = 31536000, Location = ResponseCacheLocation.Any)]
|
||||
[ResponseCache(Duration = 60 * 60 * 24, Location = ResponseCacheLocation.Any)]
|
||||
public IActionResult Logo([FromServices] IHostingEnvironment env)
|
||||
{
|
||||
string imageFile = FileHelper.MapPath(env, Constants.LOGO_PATH);
|
||||
|
@ -49,7 +49,7 @@ namespace Teknik
|
||||
name: "Default.Logo",
|
||||
domains: new List<string>() { config.Host, config.ShortenerConfig.ShortenerHost },
|
||||
subDomains: new List<string>() { "*" },
|
||||
template: "Logo",
|
||||
template: "logo.svg",
|
||||
defaults: new { area = "Default", controller = "Default", action = "Logo" }
|
||||
);
|
||||
routes.MapSubdomainRoute(
|
||||
@ -64,7 +64,7 @@ namespace Teknik
|
||||
domains: new List<string>() { config.Host, config.ShortenerConfig.ShortenerHost },
|
||||
subDomains: new List<string>() { "*" },
|
||||
template: "{url}",
|
||||
defaults: new { area = "Default", controller = "Default", action = "NotFound" },
|
||||
defaults: new { area = "Error", controller = "Error", action = "Http404" },
|
||||
constraints: new { url = "{*url}" }
|
||||
);
|
||||
}
|
||||
|
@ -384,6 +384,7 @@ function uploadComplete(fileID, key, encrypt, token, evt) {
|
||||
// Cancel out cancel token
|
||||
token.callback = null;
|
||||
|
||||
try {
|
||||
var obj = JSON.parse(evt.target.responseText);
|
||||
if (obj.result != null) {
|
||||
var itemDiv = $('#upload-panel-' + fileID);
|
||||
@ -424,8 +425,7 @@ function uploadComplete(fileID, key, encrypt, token, evt) {
|
||||
$('#upload-action-buttons').show();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
var errorMessage = 'Unable to Upload File';
|
||||
if (obj.error != null) {
|
||||
errorMessage = obj.error.message;
|
||||
@ -433,6 +433,10 @@ function uploadComplete(fileID, key, encrypt, token, evt) {
|
||||
setProgress(fileID, 100, 'progress-bar-danger', '', errorMessage);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
setProgress(fileID, 100, 'progress-bar-danger', '', 'Unable to Upload File');
|
||||
}
|
||||
}
|
||||
|
||||
function uploadFailed(fileID, token, evt) {
|
||||
// Cancel out cancel token
|
||||
|
@ -28,6 +28,7 @@ using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
using Teknik.Security;
|
||||
using Teknik.Attributes;
|
||||
using Teknik.Filters;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace Teknik
|
||||
{
|
||||
@ -77,7 +78,7 @@ namespace Teknik
|
||||
{
|
||||
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
options.MinimumSameSitePolicy = Microsoft.AspNetCore.Http.SameSiteMode.None;
|
||||
});
|
||||
|
||||
// Setup Authentication Service
|
||||
@ -85,7 +86,7 @@ namespace Teknik
|
||||
.AddCookie(options =>
|
||||
{
|
||||
options.Cookie.Domain = null;
|
||||
options.Cookie.Name = "TeknikAuthCore";
|
||||
options.Cookie.Name = "TeknikAuth";
|
||||
options.LoginPath = "/User/User/Login";
|
||||
options.LogoutPath = "/User/User/Logout";
|
||||
options.EventsType = typeof(TeknikCookieAuthenticationEvents);
|
||||
@ -100,7 +101,7 @@ namespace Teknik
|
||||
|
||||
services.AddHttpsRedirection(options =>
|
||||
{
|
||||
options.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect;
|
||||
options.RedirectStatusCode = StatusCodes.Status301MovedPermanently;
|
||||
});
|
||||
|
||||
// Sessions
|
||||
@ -108,6 +109,9 @@ namespace Teknik
|
||||
services.AddMemoryCache();
|
||||
services.AddSession();
|
||||
|
||||
// Set the anti-forgery cookie name
|
||||
services.AddAntiforgery(options => options.Cookie.Name = "TeknikAntiForgery");
|
||||
|
||||
// Core MVC
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||
|
||||
@ -147,10 +151,6 @@ namespace Teknik
|
||||
//app.UseDeveloperExceptionPage();
|
||||
app.UseDatabaseErrorPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
//app.UseHsts();
|
||||
}
|
||||
|
||||
// Performance Monitor the entire request
|
||||
app.UsePerformanceMonitor();
|
||||
@ -164,12 +164,26 @@ namespace Teknik
|
||||
// Cache Responses
|
||||
app.UseResponseCaching();
|
||||
|
||||
// Force a HTTPS redirection (301)
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
// Setup static files anc cache them client side
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
OnPrepareResponse = ctx =>
|
||||
{
|
||||
const int durationInSeconds = 60 * 60 * 24;
|
||||
ctx.Context.Response.Headers[HeaderNames.CacheControl] = "public,max-age=" + durationInSeconds;
|
||||
}
|
||||
});
|
||||
|
||||
// Enable Cookie Policy
|
||||
app.UseCookiePolicy();
|
||||
|
||||
// Authorize all the things!
|
||||
app.UseAuthentication();
|
||||
|
||||
// And finally, let's use MVC
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.BuildRoutes(config);
|
||||
|
Loading…
Reference in New Issue
Block a user