Migration to 8.1

Hi,

Have all the x templates been upgraded to work with > 8.1 ?

I’m trying to migrate one of my project to ServiceStack 8.3 from 8.0 and I’m running into some issues with the ConfigureAuth class.

So I updated x and created a new project to see if there are were any changes in the generated classes.

This is the class created by x:

public class ConfigureAuth : IHostingStartup  
{  
    public void Configure(IWebHostBuilder builder) => builder  
        .ConfigureServices(services => {  
            //services.AddSingleton<ICacheClient>(new MemoryCacheClient()); //Store User Sessions in Memory Cache (default)  
        })  
        .ConfigureAppHost(appHost => {  
            var appSettings = appHost.AppSettings;  
            appHost.Plugins.Add(new AuthFeature(() => new CustomUserSession(),  
                new IAuthProvider[] {  
                    new CredentialsAuthProvider(appSettings),     
                    //... 
                }));  
  
            appHost.Plugins.Add(new RegistrationFeature()); //Enable /register Service  
  
            //override the default registration validation with your own custom implementation            appHost.RegisterAs<CustomRegistrationValidator, IValidator<Register>>();  
        });}

From what I understood plugins are supposed to be added here:

public class ConfigureAuth : IHostingStartup  
{  
    public void Configure(IWebHostBuilder builder) => builder  
        .ConfigureServices((context, services) => {  
            services.AddPlugin(new AuthFeature(() => new CustomUserSession(),  
                new IAuthProvider[] {  
                    new CredentialsAuthProvider(new NetCoreAppSettings(context.Configuration)),
                }));  
        })        .ConfigureAppHost(appHost => {  
          //override the default registration validation with your own custom implementation  
            appHost.RegisterAs<CustomRegistrationValidator, IValidator<Register>>();  
        });}

Is this how it should be done now?

If I comment out options.MapEndpoints() in program.cs everything seems to work fine:

app.UseServiceStack(new AppHost(), options => {  
    //options.MapEndpoints();  
});

But if I uncomment it I’m getting :

Could not deserialize 'application/json' request using ServiceStack.Authenticate'
Error: The JSON value could not be converted to System.Nullable`1[System.Boolean]. Path: $.RememberMe | LineNumber: 0 | BytePositionInLine: 68.
      System.Runtime.Serialization.SerializationException: Could not deserialize 'application/json' request using ServiceStack.Authenticate'

Do you have a project that has been upgraded to 8.1 and that’s using more features like AutoQuery, the AuthRepository, etc. that I could look at to see the other changes?

Thanks a lot.

All our ASP .NET Identity Auth templates have been upgraded to use Endpoint Routing, it only works with ASP .NET Identity Auth whereas you’re trying to use it with ServiceStack Auth.

If you want to use ServiceStack Auth you can’t use Endpoint Routing, if you want an ASP .NET Identity Auth template you’ll need to start with a pre-configured one from:

https://servicestack.net/start

I’ve migrated everything except the Auth portion. I’m using the servicestack UI to assign roles, etc., and it seems to support ASP .Net identity.

My service is in staging, and I only have a few users.

Eventually, I’ll build a Svelte front-end to interact with the service.

I’m using Ormlite and PostgreSQL.

Do you recommend upgrading to ASP .Net Identity for this scenario?

Thanks for all your great work.

PS. I have never used ASP .Net identity.

If you’re starting a new project we recommend using ASP .NET Identity Auth since that’s where our focus will be in future. But ServiceStack Auth isn’t going anywhere so if you’re comfortable with that, that will be a good choice. ServiceStack Auth is simpler, so IMO it’ll depend if your App/project has a fixed set of requirements which you’ll implement and then go in maintenance mode.

For living Apps/projects which will continually be developed and evolved over time I’d recommend using ASP .NET Identity Auth so that it will be future proofed and able to take advantage of new features added in future releases.

I’ll migrate in this case.

I only have a few users and I don’t mind scrapping the DB and starting from scratch if it’s simpler.

You previously said that all the templates were upgraded to use ASP .NET Identity Auth.

I’m trying to setup a simple web project using ASP .NET Identity Auth. I’m not using Blazor, etc.

If I download the project template here:

Simple Auth Story for .NET 8 Microservices - ServiceStack

Everything works, I’m not getting any error.

If I download the Web template in the ASP.NET identity Auth tab here Create new .NET 8 project - ServiceStack

And try to mix auth and auth-db I’m always getting:

So I guess mix auth and auth-db are intended for adding ServiceStack Auth and not ASP.NET identity Auth. Is there another mix option I’m missing to add the ASP.NET identity Auth to a new project or is this planned?

Do you have an example of a minimal Web “empty” project Templates using ASP.NET identity auth (role, admin ui, etc.)? A starter project for new comers that will use APS.NET identity auth from the beginning?

It would really help. I went through the Blazor project and it seems that a lot has changed but since I’ve never used Blazor or ASP.NET identity I’m having a a bit of a hard time.

Thanks again for your assistance.

There’s no mix to add Identity Auth, you need to start from one of the ASP .NET Identity Auth templates:

https://servicestack.net/start

Choose any template with the auth tag.

If you add a mix option for this in the future or make a version of
image

With auth please let me know.

In the meantime, I’ll go over the other projects and see how far I can get.

I don’t think there’s an official Microsoft version of this package for PostgreSQL:

Microsoft.EntityFrameworkCore.Sqlite

But this should do:

Npgsql.EntityFrameworkCore.PostgreSQL

Thanks.