MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Proof of concept: CSLA with ASP.NET Core Identity split into tiers #576

Open michaelcsikos opened 6 years ago

michaelcsikos commented 6 years ago

Preamble I have started a proof of concept for a new app with the following project tiers:

Dal                  .NET Standard 2.0
DalEf                .NET Standard 2.0
Business             Shared
Business.Net         .NET 4.6.1
Business.NetStandard .NET Standard 2.0
AppService           .NET Core 2.1 / Razor pages / MVC
WindowsForms         .NET 4.6.1

The solution can be cloned or downloaded from here: https://github.com/michaelcsikos/CslaAspNetCoreIdentityTiers

I have created AppUser and Role classes in Business, and created AppUserStore and RoleStore classes in the AppService project. The AppUserStore implements enough of the Identity interfaces to get it going. There is quite a lot of code to basically replicate what Identity 3.0 already did, but if we want a clean design I think this is the way to go.

Identity 2.0 required custom user and role classes to implement interfaces, but with Identity 3.0 this is no longer the case. So, the Business project does not have any references to Identity, which is great.

Following the Project Tracker example, the data access is separate with the Dal interface layer and DalEf implementation using Entity Framework Core. I have not added a DalMock or Tests yet.

Running the AppService up, Users can be registered, and log in and out is working.

My plan was to add a Xamarin UI, but I created the WindowsForms project to test if I had configured the HttpProxy and DataPortalController correctly. Well, it's not right and I'm stuck.

System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).

Most of the CSLA examples are not quite the same (WCF, etc). I have set both the AppService and WindowsForms as startup projects, put the ProxyTypeName, DefaultUrl and User in WindowsForms Program.cs, added the same to App.config. I have tried different ports and URLs.

Please help If anyone can show me what I've missed or done wrong, I would be so grateful. I think the rest of the code is promising and could form the basis of a new .NET Core sample for CSLA.

Kind regards Michael

Version and Platform CSLA version: 4.7.101 OS: Windows Platform: WinForms, ASP.NET Core, MVC, (Xamarin later)

michaelcsikos commented 6 years ago

Has anyone had a chance to look at this yet? I still haven't got the the HttpProxy and DataPortalController working.

michaelcsikos commented 6 years ago

It's been almost a week, so maybe this SOS has fallen through the cracks. Forgive me for tagging a few of you directly: @rockfordlhotka @jonnybee @JasonBock

rockfordlhotka commented 6 years ago

No problem with the tagging - I've been traveling and buried in various other aspects of my day job over the past few weeks, so my time to do CSLA stuff has been limited...

rockfordlhotka commented 6 years ago

I'm not 100% sure what was going on initially. Here's what I did:

  1. Removed the SSL setting (you may want to put it back, but I wanted to keep things simple while troubleshooting)
  2. Add a ValuesController to the project (in case that added any config stuff necessary to get routing working - I don't know if this did anything, but I used this to establish that I could reach /api/Values in the browser)
  3. Changed the client URL to be localhost:12345/api/DataPortal (the post method name shouldn't have been there)
  4. Changed the assembly names of the .NET and .Netstandard business logic projects to match each other

I issued a PR to your repo with the changes. I don't know if the identity stuff is working, but I do know the data portal calls now work.