-
Notifications
You must be signed in to change notification settings - Fork 65
Add Secure cookie flag option to session cookie #28
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.AspNet.Session | ||
{ | ||
/// <summary> | ||
/// Determines how the identity cookie's security property is set. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW a lot of this new code mentions "identity" yet this is all about session. Is that deliberate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a direct copy from the cookie auth middleware: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should rename that too then |
||
/// </summary> | ||
public enum CookieSecureOption | ||
{ | ||
/// <summary> | ||
/// If the URI that provides the cookie is HTTPS, then the cookie will only be returned to the server on | ||
/// subsequent HTTPS requests. Otherwise if the URI that provides the cookie is HTTP, then the cookie will | ||
/// be returned to the server on all HTTP and HTTPS requests. This is the default value because it ensures | ||
/// HTTPS for all authenticated requests on deployed servers, and also supports HTTP for localhost development | ||
/// and for servers that do not have HTTPS support. | ||
/// </summary> | ||
SameAsRequest, | ||
|
||
/// <summary> | ||
/// CookieOptions.Secure is never marked true. Use this value when your login page is HTTPS, but other pages | ||
/// on the site which are HTTP also require authentication information. This setting is not recommended because | ||
/// the authentication information provided with an HTTP request may be observed and used by other computers | ||
/// on your local network or wireless connection. | ||
/// </summary> | ||
Never, | ||
|
||
/// <summary> | ||
/// CookieOptions.Secure is always marked true. Use this value when your login page and all subsequent pages | ||
/// requiring the authenticated identity are HTTPS. Local development will also need to be done with HTTPS urls. | ||
/// </summary> | ||
Always, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,7 @@ public static class SessionDefaults | |
{ | ||
public static string CookieName = ".AspNet.Session"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Tratcher are all these suppose to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
public static string CookiePath = "/"; | ||
public static CookieSecureOption CookieSecure = CookieSecureOption.SameAsRequest; | ||
public static bool CookieHTTPOnly = true; | ||
} | ||
} |
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.
BTW we just changed the copyright notice to:
Copyright (c) .NET Foundation. All rights reserved.