Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it take to implement authentication provider for ServiceStack with RavenDB datastore?

I've been looking at the ServiceStack's SocialBootstrapAPI example app and it seems most of the wiring is done inside the AppHost class. That is the wiring.

Looking at this page, there are some clues and I might just start coding away but I fear I might miss some points along the way: https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization

I know I have to inherit CredentialsAuthProvider and override TryAuthenticate but I guess I also have to implement IUserAuthRepository to work with RavenDB database.

So I came up with just one class, someone please tell me if this will work (if anyone has done it before):

public sealed class RavenDBAuthProvider : CredentialsAuthProvider, IUserAuthRepository

will this be enough or is there anything else ?

like image 590
mare Avatar asked Dec 21 '25 00:12

mare


1 Answers

You only need to implement IUserAuthRepository which is what all the built-in Auth providers use to persist the UserAuth Info.

If you want to change the data models used i.e. use something other than UserAuth / UserOAuthProvider POCOs then you want to implement your own AuthProviders as well. CredentialsAuthProvider just allows the standard User/Password form authentication.

The existing IUserAuthRepositoryimplementations should be a good reference on how to go about implementing it:

  • MongoDBAuthRepository
  • NHibernateUserAuthRepository
  • RedisAuthRepository
  • InMemoryAuthRepository
  • OrmLiteAuthRepository

If you would like, we would welcome the addition to the ServiceStack.Contrib project, and we can include it in the deployment cycle of ServiceStack's NuGet packages.

like image 66
mythz Avatar answered Dec 24 '25 10:12

mythz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!