nbarbettini / BeautifulRestApi

Beautiful REST API design with ASP.NET Core and Ion
Apache License 2.0
604 stars 144 forks source link

Update to ASP.NET Core 2.0 #7

Open KeithT opened 7 years ago

KeithT commented 7 years ago

Just completed (nearly all) your Lynda course (which is excellent by the way) following along using Core 2. I thought you might be interested in a couple of things that break:

In Startup.cs:

        // Add ASP.NET Core Identity
            services.AddIdentity<UserEntity, UserRoleEntity>()
                .AddEntityFrameworkStores<HotelApiContext, Guid>()
                .AddDefaultTokenProviders();

needs to go to:

        // Add ASP.NET Core Identity
            services.AddIdentity<UserEntity, UserRoleEntity>()
                .AddEntityFrameworkStores<HotelApiContext>()
                .AddDefaultTokenProviders();

and in the UsersController.cs:

                var canSeeEveryone = await _authzService
                    .AuthorizeAsync(User, "ViewAllUsersPolicy");
                if (canSeeEveryone)
                {
                    users = await _userService.GetUsersAsync(
                        pagingOptions, sortOptions, searchOptions, ct);
                }

Error CS0029 Cannot implicitly convert type 'Microsoft.AspNetCore.Authorization.AuthorizationResult' to 'bool' bodimecore ...\Controllers\UsersController.cs error

Which I've not had time to look at yet. (Monday hopefully). Thanks again for the great course.

nbarbettini commented 7 years ago

Thanks for watching the course! I'm glad it was helpful.

I need to update this repo (and the course eventually) to all the Core 2.0 packages. I just haven't had time yet. Thanks for the reminder. 👍

KeithT commented 7 years ago

I've not been able to get the authentication part working, there seems to be significant changes in Core 2 in this area: https://github.com/aspnet/Announcements/issues/232.

Blocked by: Could not load type 'Microsoft.AspNetCore.Builder.AuthenticationOptions' from assembly 'Microsoft.AspNetCore.Authentication in Startup at

app.UseOAuthValidation(); app.UseOpenIddict();

I've tried different package versions of things e.g. tried upgrading OpenIddict, downgrading System.IdentityModel.Tokens.Jwt with no luck

Any pointers greatly appreciated.

EthernetIp commented 6 years ago

Although a new course that I just watched, Its great btw. The authentication section, that was my only issue to start with, is already obsolete. Can you PLEASE, update it to Core 2, and maybe show the hash method as well as identity.

nbarbettini commented 6 years ago

Updates are a little delayed but definitely coming.

What's the hash method you mentioned?

EthernetIp commented 6 years ago

Digest authentication , MD5 hashing I guess.

Tx in advance.

SeanFarrow commented 6 years ago

Hi,

this looks really good. Have you started to update this to core/net standard 2.0? If not I'm happy to do this and submit a pr, if that would help?