Skip to content

Commit a5a716d

Browse files
author
github-actions
committed
fix: automatic redirect after logout
1 parent 21e69b0 commit a5a716d

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

src/Aguacongas.TheIdServer.Duende/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ And the favicon is *wwwroot/favicon.ico*.
130130

131131
By replacing those files you can redefined the site style by yours.
132132

133+
### Configure account options
134+
135+
The section *AccountOptions* is bound to [`AccountOptions`](../Aguacongas.TheIdServer.Shared/Quickstart/Account/AccountOptions.cs).
136+
137+
```json
138+
"AccountOptions": {
139+
"AllowLocalLogin": true,
140+
"AllowRememberLogin": true,
141+
"RememberMeLoginDuration": "30.00:00:00",
142+
"ShowLogoutPrompt": true,
143+
"AutomaticRedirectAfterSignOut": false,
144+
"InvalidCredentialsErrorMessage": "Invalid username or password",
145+
"ShowForgotPassworLink": true,
146+
"ShowRegisterLink": true,
147+
"ShowResendEmailConfirmationLink": true
148+
}
149+
```
150+
133151
## Configure ASP.Net Core Identity options
134152

135153
The section **IdentityOptions** is binded to the class [`Microsoft.AspNetCore.Identity.IdentityOptions`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.identityoptions).

src/Aguacongas.TheIdServer.Shared/Quickstart/SecurityHeadersAttribute.cs

+22-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) 2022 @Olivier Lefebvre
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.AspNetCore.Mvc.Filters;
5+
using System.Text;
56

67
namespace Aguacongas.TheIdServer.UI
78
{
@@ -25,13 +26,28 @@ public override void OnResultExecuting(ResultExecutingContext context)
2526
}
2627

2728
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
28-
var csp = "default-src 'self'; object-src 'none'; frame-ancestors 'none'; sandbox allow-forms allow-same-origin allow-scripts; base-uri 'self';";
29-
// also consider adding upgrade-insecure-requests once you have HTTPS in place for production
30-
// csp += "upgrade-insecure-requests;";
29+
var builder = new StringBuilder("default-src 'self'");
30+
#if DEBUG
31+
builder.Append(" wss://localhost:44337/Aguacongas.TheIdServer.Duende/");
32+
#endif
33+
builder.Append("; object-src 'none'; frame-ancestors 'none'; sandbox allow-forms allow-same-origin allow-scripts; base-uri 'self';upgrade-insecure-requests;");
34+
builder.Append("style-src 'self' https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css;");
35+
var autorizeScriptsUrl = new[]
36+
{
37+
"'sha256-vwa3kDBkD7mP1Y0njpcyAH7GXn3/HkE72HGlVShVMUg='",
38+
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js",
39+
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.slim.min.js",
40+
};
41+
builder.Append("script-src 'self'");
42+
foreach(var url in autorizeScriptsUrl)
43+
{
44+
builder.Append(' ');
45+
builder.Append(url);
46+
}
3147
// also an example if you need client images to be displayed from twitter
32-
// csp += "img-src 'self' https://pbs.twimg.com;";
33-
csp += "style-src 'self' https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css;";
34-
48+
// builder.Append(";img-src 'self' https://pbs.twimg.com;");
49+
var csp = builder.ToString();
50+
3551
// once for standards compliant browsers
3652
if (!context.HttpContext.Response.Headers.ContainsKey("Content-Security-Policy"))
3753
{

src/Aguacongas.TheIdServer.Shared/Views/Shared/_Layout.cshtml

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,18 @@ Copyright (c) 2022 @Olivier Lefebvre
2222
<title>@Options.Value.Name</title>
2323
<link rel="icon" type="image/x-icon" href="~/favicon.ico" />
2424
<link rel="shortcut icon" type="image/x-icon" href="~/favicon.ico" />
25-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
25+
<link rel="stylesheet"
26+
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
27+
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
28+
crossorigin="anonymous"
29+
referrerpolicy="no-referrer" />
2630
<link rel="stylesheet" href="~/css/site.min.css" />
27-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
31+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.slim.min.js"
32+
asp-fallback-src="~/lib/jquery/jquery.min.js"
33+
asp-fallback-test="window.jQuery"
34+
integrity="sha512-6ORWJX/LrnSjBzwefdNUyLCMTIsGoNP6NftMy2UAm1JBm6PRZCO1d7OHBStWpVFZLO+RerTvqX/Z9mBFfCJZ4A=="
35+
crossorigin="anonymous"
36+
referrerpolicy="no-referrer"></script>
2837
</head>
2938
<body>
3039
<header>

src/Aguacongas.TheIdServer/Pages/_Host.cshtml

+14-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,20 @@ Copyright (c) 2022 @Olivier Lefebvre
1414
<title>TheIdServer Admin</title>
1515
<base href="/" />
1616
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
17-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
18-
<script src="//code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
19-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
17+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
18+
rel="stylesheet"
19+
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
20+
crossorigin="anonymous">
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.slim.min.js"
22+
asp-fallback-src="~/lib/jquery/jquery.min.js"
23+
asp-fallback-test="window.jQuery"
24+
integrity="sha512-6ORWJX/LrnSjBzwefdNUyLCMTIsGoNP6NftMy2UAm1JBm6PRZCO1d7OHBStWpVFZLO+RerTvqX/Z9mBFfCJZ4A=="
25+
crossorigin="anonymous"
26+
referrerpolicy="no-referrer"></script>
27+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
28+
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
29+
crossorigin="anonymous"
30+
referrerpolicy="no-referrer"></script>
2031
<link href="css/app.css" rel="stylesheet" />
2132
</head>
2233
<body class="bg-light">

0 commit comments

Comments
 (0)