-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HSTS and UseHttpsRedirection #5902
Conversation
aspnetcore/security/enforcing-ssl.md
Outdated
|
||
[!code-csharp[sample](enforcing-ssl/sample/Startup.cs?name=snippet1&highlight=10)] | ||
|
||
`UseHsts` not recommend in development because calling `UseHsts` excludes the local loopback address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"UseHsts
not recommend in development because the HSTS header is highly cachable by browsers. By default, UseHsts excludes the local loopback address."
|
||
* `localhost` : The IPv4 loopback address. | ||
* `127.0.0.1` : The IPv4 loopback address. | ||
* `[::1]` : The IPv6 loopback address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add that you also may specify other excluded hosts on the HstsOptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No setter
See source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still call options.ExcludedHosts.Add(...)
to add onto the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is part of the HstsOptions, not the HttpsRedirectionOptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you send me the code to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, wrong place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
services.AddHsts(options =>
{
options.Preload = true;
options.IncludeSubDomains = true;
options.MaxAge = TimeSpan.FromDays(60);
options.ExcludedHosts.Add("example.com");
options.ExcludedHosts.Add("www.example.com");
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah looks good!
aspnetcore/security/enforcing-ssl.md
Outdated
* `127.0.0.1` : The IPv4 loopback address. | ||
* `[::1]` : The IPv6 loopback address. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to sample here?
Looks good to me doc wise. I'll spin up the sample once I get the chance to and make sure that works. |
## Require HTTPS | ||
|
||
::: moniker range=">= aspnetcore-2.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're missing the ::: moniker-end
for this block.
Fixes #4568
Fixes Option to opt-out of HTTPS #5960
Review URL