This project provides an implementation of ServiceStack's UserAuthRepository
using Marten for storage.
- .NET 6 +
- it's generic: supports custom implementations of
UserAuth
andUserAuthDetails
- handles user & role/permission management (implements
IUserAuthRepository, IManageRoles
) - handles API Key management (implements
IManageApiKeys
)
- 0.8.0 updated to Marten >= 6.0.5, ServiceStack >= 6.5.0
- 0.6.0 updated hashing to reflect changes in ServiceStack 5. Extacted public CreateUser method to be used with event store projections
- 0.5.0 implemented
IManageApiKeys
- 0.4.0 support for ServiceStack >= 5.0
- 0.3.0 support for Marten >= 2.0
-
install it via nuget
Install-Package ServiceStack.Authentication.Marten
-
when configuring Marten, use an
AuthRepository()
extension method to configure the storage for bothUserAuth
andUserAuthDetails
types (or your own implementations, when using generic version)DocumentStore.For(opts => { opts.AuthRepository() .UseAuth<UserAuth>() .UseAuthDetails<UserAuthDetails>(); });
-
register the auth repository in the container
// ex.: container.Register<IDocumentStore>(c => new DocumentStoreBuilder().Build()) // .ReusedWithin(ReuseScope.Hierarchy); container.RegisterAutoWiredAs<MartenAuthRepository, IUserAuthRepository>() .ReusedWithin(ReuseScope.Hierarchy);
no support for Marten as Event Store (yet ..)provide demo of Event Store approachoptionalStoreChanges
call when re-using IDocumentSession- full test coverage