2
votes

I am trying to implement ServiceStack Authentication and Authorization for RavenDb. ServiceStack UserAuth model has property "Id" as Int while RavenDb excepts "Id" to be String.

When I try to create a new user I get the following exception:

Message=Cannot set identity value 'UserAuths/1-A' on property 'Id' for type 'ServiceStack.Auth.UserAuth' because property type is not a string. Source=Raven.Client

Can I implement a custom_UserAuth table ignoring ServiceStack UserAuth table? Is that the only way?

1

1 Answers

2
votes

Auth Repositories must at a minimum implement IUserAuth but you can use your own concrete UserAuth Table which is what the RavenDbUserAuthRepository allows by using the generic RavenDbUserAuthRepository<TUserAuth, TUserAuthDetails>.

E.g: you can create a custom MyRavenDbUserAuthRepository using your own MyUserAuth or MyUserAuthDetails classes:

public class MyRavenDbUserAuthRepository 
  : RavenDbUserAuthRepository<MyUserAuth, MyUserAuthDetails>, IUserAuthRepository
{
    public RavenDbUserAuthRepository(IDocumentStore docStore) : base(docStore) { }
}

Otherwise it looks like RavenDB lets you customize which property to use as its Identity.