nancy

How to set up cookie based authentication with NancyFx and IdentityServer3 (non-API website)

眉间皱痕 提交于 2019-12-10 14:12:38
问题 We have an environment with the following: Standalone IdentityServer3 instance (issues reference tokens, not jwt) ASP.NET WebAPI resource server .NET client applications that authenticate against IdSvr (via resource owner flow) ...and now we'd like to start adding an OWIN-hosted web app that will use NancyFx to serve server-rendered pages as well as a couple AngularJS SPAs. This Nancy website will NOT host any APIs, but may consume data from our existing API. I'd like to add authentication in

Model-bind POST with Array of objects in NancyFx

非 Y 不嫁゛ 提交于 2019-12-10 12:34:26
问题 I have a json object with the following structure { ContainerType: "Box", Items : [{Name: "Coin", Amount: 5}, {Name: "Spyglas", Amount : 1}] } This object has an representation in the Nancy backend system: public string ContainerType {get; set} public IEnumberable<Item> Items {get; set} where Item (as expected) is a very simple object with public properties: public string Name {get; set;} public double Amount {get; set;} My problem is that when I receive the Post in my module (based on

NullReferenceException experienced with Owin on Startup .Net Core 2.0 - Settings?

十年热恋 提交于 2019-12-10 11:19:59
问题 I'm trying to start up a WebApp to use with NancyFx in a .NET Core 2.0 project. The package i've added to the solution to do this is Microsoft.AspNet.WebApi.OwinSelfHost which installs it's dependencies: Microsoft.AspNet.WebApi.Client Microsoft.AspNet.WebApi.Core Microsoft.AspNet.WebApi.Owin Microsoft.Owin Microsoft.Owin.Host.HttpListener Microsoft.Owin.Hosting Newtonsoft.Json Owin I've also added: Nancy Nancy.Owin My project is of type "xUnit Test Project (.NET Core)". Starting with my test

NancyFx RequiresAuthentication extension returns 303 and not 403

ぐ巨炮叔叔 提交于 2019-12-10 10:14:12
问题 I'm not sure if I'm doing something wrong or there's a bug of some kind. If it is a bug, then I'd think this would have cropped up immediately. Either way: I'm using the extension method RequiresAuthentication from here: https://github.com/NancyFx/Nancy/blob/9d3c650575cba109e620ab163f4fda26a0536036/src/Nancy/Security/ModuleSecurity.cs Which uses SecurityHooks https://github.com/NancyFx/Nancy/blob/9d3c650575cba109e620ab163f4fda26a0536036/src/Nancy/Security/SecurityHooks.cs Or the code

When do you really need async on a web framework?

[亡魂溺海] 提交于 2019-12-10 02:51:55
问题 Async has become a buzzword in .net and MS have introduced it in Web API 2 so that more requests can be handled whilst others are waiting on IO to finish. Whilst I can see the benefit of this, is it really a concern? A x64 architecture has 30000+ threads in the Thread Pool so unless you have that many concurrent users on your website is async really required? Even if you have that many concurrent users without caching I'm pretty sure SQL Server will fall over with that many requests? Apart

Nancy: how do I capture all requests irrespective of verb or path

泪湿孤枕 提交于 2019-12-10 02:12:03
问题 I want to use Nancy with the default routing, as it's clean and works well, however I want an option to log all incoming requests to the console (I'm using Nancy's self-hosting module) irrespective of whether an explicit route exists. Put simply, I want to be able to capture the verb, the incoming request URI, any posted data (if it's a POST request), etc. How do I do this? Before / After only seem to run for requests that match an existing route, and a 404 does not trigger OnError either.

Test driving Nancy Modules

血红的双手。 提交于 2019-12-10 01:52:15
问题 Ok - I love NancyFx. Writing a web application with that few lines is just amazing! But how do you test drive your NancyModules on the unit level? Please note that I am aware of the excellent testframework supplied with Nancy (Nancy.Testing on NuGet), which gives excellent ways to test the whole (almost) application stack. But now I mean the unit level test I use to flesh out the contents of my NancyModule, in TDD fashion. Since the routes are defined in the constructor, often together with a

How to use Autofac to resolve instance per request dependencies for types in a child lifetime scope created by Nancy

假如想象 提交于 2019-12-09 06:53:29
问题 We have several applications hosted in Windows services that self host a Nancy endpoint in order to expose instrumentation about the operation of the applications. We use Autofac as our IOC. Several repositories are registered into the root container in a core DLL shared by all applications; this container is then passed to Nancy as its container using a bootstrapper derived from the Nancy.Autofac.Bootstrapper . What we found was that when a web request is received by Nancy it resolves a

How to handle subdomains in NancyFX routes

风格不统一 提交于 2019-12-08 16:44:33
Really liking the simplicity and the power of the NancyFX framework, but I ran into something which I cannot find a good solution for; how to route based on subdomains? For example; I want to define a route that matches something like {account}.website.com/restofroute While having other parts of my site react to the normal www.website.com routing. So basically I want multi tenant support in my site based on the host name. I found some ways to create and hookup a TrieNode so I can match the host header against some pattern and extract the account itself, but I don't see how I can link this up

How to handle subdomains in NancyFX routes

一笑奈何 提交于 2019-12-08 05:40:17
问题 Really liking the simplicity and the power of the NancyFX framework, but I ran into something which I cannot find a good solution for; how to route based on subdomains? For example; I want to define a route that matches something like {account}.website.com/restofroute While having other parts of my site react to the normal www.website.com routing. So basically I want multi tenant support in my site based on the host name. I found some ways to create and hookup a TrieNode so I can match the