AsUserAuthRepository unavailable after latest update to 4.0.62?

Hi there. I’m installing a new machine and trying to load up an existing project I have been working on, and noticed that there is a new version of servicestack out, and so I updated my library reference but now my project won’t build and i cannot see why this would be - i’ve done the update, got all the usual SS references etc as best I can tell.

The particular error I am getting is that “IAuthRepository does not contain a definition for AsUserAuthRepository” in a line like:

var userAuthRepo = AuthRepo.AsUserAuthRepository(GetResolver());

I can find examples of similar code in other ServiceStack-based projects in Github, but no reference to that method in the current servicestack source - am i doing something wrong, or missing something obvious? Has this code been intentionally removed in the latest release?

I’m trying to pull down the SS source from Github to take a look but for some reason its insanely slow and taking a long time :-/

We’ve moved resolving the IAuthRepository to a centralized location in AppHost.GetAuthRepository() to enable support for Multitenancy Auth Providers which required some breaking changes.

Basically you should register your AuthRepository under, IAuthRepository, e.g:

container.Register<IAuthRepository>(c => ...);

However even if you’ve registered it under IUserAuthRepository ServiceStack will automatically register it under IAuthRepository as well.

If you’re not using the new OrmLiteAuthRepositoryMultitenancy you can just access it from the IAuthRepository as a regular dependency, i.e:

public IAuthRepository AuthRepo  { get; set; }

You should no longer need to cast it to IUserAuthRepository as there are convenience extension methods for all IUserAuthRepository APIs which lets you access it from the IAuthRepository dependency instead.

Otherwise the standard usage to access any IAuthRepository (inc. Multitenancy providers) is to resolve it from the AppHost and dispose it if it needed, e.g:

var authRepo = HostContext.AppHost.GetAuthRepository(base.Request);
using (authRepo as IDisposable)
{
  //..
}

I’ve also added it as a first-class base.AuthRepository property in Service to make access more convenient in next release.

1 Like