Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Allow a way to mark all cookies as "HTTP only" and "SSL required" by default #42

Closed
GrabYourPitchforks opened this issue Apr 16, 2014 · 24 comments

Comments

@GrabYourPitchforks
Copy link
Contributor

Basically, this would be an equivalent to the <httpCookies> element in Web.config:

<httpCookies domain="String" 
             httpOnlyCookies="true|false" 
             requireSSL="true|false" />

Allows marking all cookies with these flags regardless of how the CookieOptions object is constructed. More info at http://msdn.microsoft.com/en-us/library/ms228262(v=vs.100).aspx.

@davidfowl davidfowl modified the milestone: Alpha Apr 16, 2014
@glennc glennc added this to the 1.0.0-alpha3 milestone Jun 23, 2014
@Tratcher Tratcher added this to the 1.0.0-rc1 milestone Jan 21, 2015
@muratg muratg modified the milestones: 1.0.0-beta5, 1.0.0-beta4 Mar 24, 2015
@blowdart
Copy link
Member

blowdart commented May 4, 2015

And rename the "secure" cookie option as part of this.

@Eilon
Copy link
Contributor

Eilon commented May 4, 2015

Removing @GrabYourPitchforks as the assignee 😄 (Unless you like, you know, really want to do it 😄 )

@Tratcher
Copy link
Member

Tratcher commented May 4, 2015

@blowdart in this case secure is appropriate because that's the actual text used in the cookie header.

@blowdart
Copy link
Member

blowdart commented May 4, 2015

That doesn't make it true though.

@Tratcher
Copy link
Member

Tratcher commented May 4, 2015

Agreed, but we can't change the RFC. Renaming our APIS that set this value will just case confusion about what's being set.

@davidfowl
Copy link
Member

Seems like this would be a feature of Hosting

@Tratcher
Copy link
Member

Tratcher commented May 4, 2015

Any proposals on how? High jacking the IResponseCookiesFeature?

@davidfowl
Copy link
Member

I think so.

@SteveArr
Copy link

SteveArr commented May 4, 2015

I would be interested in taking this on.

I am already doing some work with the Secure flag on cookies for aspnet/Session#28

@HaoK
Copy link
Member

HaoK commented Jun 29, 2015

@blowdart how important is this for beta 6 (i.e. do we need this now?)

@blowdart
Copy link
Member

It's a big security regression, so it would be really really nice to have as soon as possible, but I leave the exact release to your discretion. If you have time now, then please do now.

@HaoK
Copy link
Member

HaoK commented Jun 29, 2015

Ok I will try to take a look this week

@Tratcher
Copy link
Member

Preference for making this a middleware rather than embedding it in hosting.

@blowdart
Copy link
Member

Added suggestion - why not change the cookie class to make cookies http only for default, and make them "secure" by default if the request is over https.

@HaoK
Copy link
Member

HaoK commented Jul 13, 2015

Not going to happen for beta 6 at this point

@HaoK HaoK modified the milestones: 1.0.0-beta7, 1.0.0-beta6 Jul 13, 2015
@glennc glennc modified the milestones: 1.0.0-beta8, 1.0.0-beta7 Aug 6, 2015
@davidfowl
Copy link
Member

@HaoK lets have a little design meeting before you tackle this.

@glennc glennc modified the milestones: Backlog, 1.0.0-beta8 Sep 4, 2015
@muratg muratg unassigned HaoK Sep 5, 2015
@muratg muratg modified the milestones: 1.0.0-beta8, Backlog Sep 9, 2015
@muratg
Copy link

muratg commented Sep 9, 2015

@HaoK will you be able to look into this?

@HaoK
Copy link
Member

HaoK commented Sep 11, 2015

UseCookiePolicy(new CookiePolicyOptions
{
  HttpOnly = HttpOnlyPolicy.None | Always
  Secure = SecurityPolicy.None | Always | SameAsRequest
  OnAppendCookie = ctx => 
  OnDeleteCookie = ctx => 

  AppendCookieContext ( HttpContext, CookieOption, CookieName, CookieValue)
  DeleteCookieContext ( HttpContext, CookieOption, CookieName)
});

@HaoK
Copy link
Member

HaoK commented Sep 11, 2015

Test Map behavior

@HaoK
Copy link
Member

HaoK commented Sep 11, 2015

Namespace: Microsoft.AspNet.CookiePolicy in security repo stand alone package.

@davidfowl
Copy link
Member

This is nice!

@HaoK
Copy link
Member

HaoK commented Sep 17, 2015

5cc1fea40045041f77a6bb2bd23e231e24f82da7

@mgolois
Copy link

mgolois commented Aug 15, 2018

@HaoK I just want to confirm. Im currently migrating code.

.net 4.5 mvc:
<httpCookies requireSSL="true" />

so in .net core mvc, it should be this:
services.ConfigureApplicationCookie(o => o.Cookie.SecurePolicy = Microsoft.AspNetCore.Http.CookieSecurePolicy.Always);

is that correct?

@Tratcher
Copy link
Member

Comments on closed issues are not tracked, please open a new issue with the details for your scenario.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants