Skip to content
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

Unwanted CookieBasedSession in Nancy Implementation #157

Open
devandy opened this issue Dec 11, 2014 · 14 comments
Open

Unwanted CookieBasedSession in Nancy Implementation #157

devandy opened this issue Dec 11, 2014 · 14 comments
Assignees

Comments

@devandy
Copy link

devandy commented Dec 11, 2014

In the Nancy implementation, there is a class that set the CookieBasedSession (EnableSessions.cs) on application start up.
This is bad because ovverides the application specific implementation of session management.
I think that that class has to be removed, and let the developer decide which type of session implementation is the best choice.

@devandy devandy changed the title Unwanted CookieBasedSession Unwanted CookieBasedSession in Nancy Implementation Dec 11, 2014
@PureKrome
Copy link
Member

@devandy can you please link to the specific code/file that this exists on?

@xt0rted
Copy link

xt0rted commented Dec 12, 2014

Cookie based sessions are enabled here EnableSessions.cs#L9

@devandy
Copy link
Author

devandy commented Dec 12, 2014

Yes, removing it the application's session management works again.

@phillip-haydon
Copy link
Member

This library should work out of the box so we need to enable sessions for it to work. So I guess we need to add a setting to disable the setting when you want to control it yourself.

@PureKrome PureKrome added the bug label Dec 12, 2014
@PureKrome PureKrome added this to the 2.0 - .NET 4.5 & Async/Await milestone Dec 12, 2014
@PureKrome PureKrome self-assigned this Dec 12, 2014
@PureKrome
Copy link
Member

@devandy out of interest, what type of session are you using and how are you setting that up, etc?

@devandy
Copy link
Author

devandy commented Dec 12, 2014

I'm using a MemoryCacheBasedSessions found on github (it uses an System.Runtime.Caching.ObjectCache to store values).
I'm setting it up in the Bootstrapper's ApplicationStartup method, hooking the pipelines:

pipelines.BeforeRequest.AddItemToStartOfPipeline(LoadSession);
pipelines.AfterRequest.AddItemToEndOfPipeline(SaveSession);

@PureKrome
Copy link
Member

OK. So I started looking into this issue and realized I'm an idiot (again) - I totally misunderstood the context of this problem.

So, with a Nancy app, the SA code was force-wiring up Cookies as the session backing store. not good.

In my new code for the v2.0 release, this is some sample code that is using sessions...

var redirectionResult = _webApplicationService.RedirectToProvider(redirectToProviderData);

// Remember any important information for later, after we've returned back here.
Session[SessionKeyState] = redirectionResult.CacheData;

// Now redirect :)
result = Response.AsRedirect(redirectionResult.RedirectUrl.AbsoluteUri);

So this is using the Nancy ISession object/property. So .. people .. correct me on this .. but anyone can determine the session provider to use for their nancy projects right? Either InMemory or Cookies, right? (ie. define this in the bootstrap). Also, what's the default one if nothing is set by the developer? An InMemory?

If that's the case, then my new code is good and I can close this issue.

@PureKrome
Copy link
Member

This bug is linked to #145

@xt0rted
Copy link

xt0rted commented Dec 24, 2014

Nancy doesn't have session support out of the box, you need to opt-in to it. The default provider will throw an exception if you try to access the session object.

@PureKrome
Copy link
Member

Ahhhh - excellent reply @xt0rted

Ok - so the next question is this: By default (for a Nancy web app), is it acceptable that Simple Authentication with throw an exception when a person tries to Redirect to a Provider (google, fb, etc) ?

My vote: yes it is. Rational: I see this as a Nancy concern, not an SA concern.

Thoughts anyone?

@fjeldstad
Copy link
Contributor

@PureKrome 👍

@devandy
Copy link
Author

devandy commented Feb 10, 2015

Yes, I expect that if i don't enable session support I'll get an exception, it's not a SA concern. Obviously I expect that there is a note in the SA documentation about Nancy Session Support requirement.

@PureKrome
Copy link
Member

Sweet! I'll add a label here so I know to document this issue when I get around to releasing the vnext.

@devandy
Copy link
Author

devandy commented Feb 12, 2015

@PureKrome 👍

@PureKrome PureKrome removed this from the 2.0 - .NET 4.5 & Async/Await milestone Oct 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants