nancy

Send parameter to Nancy module from test

て烟熏妆下的殇ゞ 提交于 2020-01-04 06:31:13
问题 I'm trying to test a module with parameter (below is only code where I'm trying to figure the problem out) public class StuffModule : NancyModule { public StuffModule() : base("/Stuff") { Get["/All/"] = parameters => { string str = parameters.one; return Response.AsJson(str); }; } } private Browser _browser; [SetUp] public void SetUp() { var module = new StuffModule(null); var mock = new Mock<IRecipeExtractor>(); var bootstrapper = new ConfigurableBootstrapper( with => with.Dependency(mock

Is Forms Authentication as described in the Nancy docs susceptible to session hijacking?

拈花ヽ惹草 提交于 2020-01-04 02:32:11
问题 I read the documentation of Nancy Forms Authentication. As far as I can tell, the approach recommended there leads to lifelong session IDs: "The identifier is the token that will be put in the authentication cookie which will be used to re-establish the identity of the user that is performing the request, so that you do not need to enter your credentials for each request." As far as I understand, that "identifier" is what most people call a session ID. It is also important to know that the

Accessing dynamic property in F#

与世无争的帅哥 提交于 2020-01-03 18:45:27
问题 I was trying to access dynamic property in Nancy. In Nancy if pass parameter in query it comes as dynamic property. How can I access that. There are many discussion / question about this but every where, first it is of creating dynamic and then consuming it. How can I consume what is already created? Here are two code snippet public class ParameterModule : NancyModule { public ParameterModule():base("/{about}") { this.Get["/"] = (parameters) => "Hello About" + parameters.about; } } and for F#

nancyfx posting json - Nancy.DynamicDictionary is empty

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 18:19:23
问题 I'm just starting to play with NancyFx to compare it with the .net MVC WebAPI stuff and I've hit an issue straight away. As I understand it Nancy should handle serialization straight out of the box. But I can't seem to get it working. I have a Nancy Module that looks like this: public class HelloWorld : NancyModule { public HelloWorld() { Post["/"] = parameters => { var myFieldValue = parameters.myField; return HttpStatusCode.OK; }; } } And I post to it using Fiddler like this: Headers: User

Where is Nancy's CancellationToken for async Request Handlers coming from and when is it cancelled?

假如想象 提交于 2020-01-03 08:44:11
问题 This is more a question regarding understanding how and when Nancy might cancel an async request handler via the provided cancellationToken instance. Basically what I am wondering about is in what conditions is the token's .IsCancellationRequested set to true - is this documented or explained somewhere? How does Nancy handle async handlers that 'never' return / in 'time'? And regarding 'in time': is there a timeout / limit after which handlers do get cancelled? 回答1: I know this is an old

Implement session-based authentication with Nancy

一个人想着一个人 提交于 2019-12-25 12:44:14
问题 This is a follow-up question to Is Forms Authentication as described in the Nancy docs susceptible to session hijacking? I understand now how Nancy Form Authentication works and also the idea behind it, thanks to Steven Robbins' answer. However, for my application that approach is not sufficient. It must not be possible to gain eternal access for an attacker if he manages to steal the auth cookie once. Thus, I'm currently investigating possibilities to switch to a session-based approach to

Implement session-based authentication with Nancy

心已入冬 提交于 2019-12-25 12:44:08
问题 This is a follow-up question to Is Forms Authentication as described in the Nancy docs susceptible to session hijacking? I understand now how Nancy Form Authentication works and also the idea behind it, thanks to Steven Robbins' answer. However, for my application that approach is not sufficient. It must not be possible to gain eternal access for an attacker if he manages to steal the auth cookie once. Thus, I'm currently investigating possibilities to switch to a session-based approach to

How configure Nancyfx with https

二次信任 提交于 2019-12-24 12:16:05
问题 I have register ssl certificates for server. Insert all certs to /usr/local/share/ca-certificates/ and make update-ca-certificates . When app start, I follow by url https_//www.site.org:443 but its not loading. static void Main(string[] args) { var uri = "https://localhost:443"; var host = new NancyHost(new Uri(uri)); host.Start(); // start hosting if (args.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase))) { Thread.Sleep(Timeout.Infinite); } else { Trictionary.initilizeDic(

Why does Nancy.Testing fail when @using statements are included in razor layouts?

≯℡__Kan透↙ 提交于 2019-12-24 03:05:45
问题 In a previous question Does Nancy.Testing support nested Razor views? I outlined the difficulties I was having with Nancy unit tests failing when presented with nested razor layouts. After investigation I can now refine that information. The problem is not related to nesting it is simply this: If you include a @using statement in a razor layout or view, then Nancy will fail to find that referenced namespace if accessed from a unit-test. For example: Master Layout @inherits Nancy.ViewEngines

Why does Nancy.Testing fail when @using statements are included in razor layouts?

偶尔善良 提交于 2019-12-24 03:05:37
问题 In a previous question Does Nancy.Testing support nested Razor views? I outlined the difficulties I was having with Nancy unit tests failing when presented with nested razor layouts. After investigation I can now refine that information. The problem is not related to nesting it is simply this: If you include a @using statement in a razor layout or view, then Nancy will fail to find that referenced namespace if accessed from a unit-test. For example: Master Layout @inherits Nancy.ViewEngines