Creating a service for client authentication using a service program?

I have several applications (mobile and desktop) for which I need a simple web service created for authentication and for sending information back to clients.

After a person had problems trying to figure out how to create a membership database or even find the previous one to check with the WCF service being used, I came across a service stack. Therefore, I have a couple of questions.

Is there a service in the stack from the database and the provider so that I can just add authentication for clients and create it myself. Therefore, I do not need to create it from scratch.

Is their service and database service an example already that I can use as a basis?

The whole WCF service scares me. Basically, all I'm looking for is a service that I can use to authorize an application for mobile applications and desktop computers, and maybe later add additional functions to it. He will need his own db, since it will not be launched from an existing website and there will be a way to manage them.

With WCF, this is too complicated for the task, and I did not find examples with the database already in use and how to manage them. Ideally, I would like to have an empty website, so I could manage my accounts and use the WCF service in the same database.

Is it possible to do all this easily using the service stack, and can anyone point out an example for it already? If you have any tips on my current approach that will also help.

+5
1

wiki, ServiceStack.

, UserData, :

/

, :

MemoryCacheClient, .

API SocialBootstrap, http://bootstrapapi.apphb.com, , ServiceStack , -.

AppHost.ConfigureAuth(), , .

AppSettings Auth Providers , Web.Config:

var appSettings = new AppSettings();

AuthFeature , -:

Plugins.Add(new AuthFeature(
    () => new CustomUserSession(), //Use your own typed Custom UserSession type
    new IAuthProvider[] {
        new CredentialsAuthProvider(),              //HTML Form post of UserName/Password credentials
        new TwitterAuthProvider(appSettings),       //Sign-in with Twitter
        new FacebookAuthProvider(appSettings),      //Sign-in with Facebook
        new DigestAuthProvider(appSettings),        //Sign-in with Digest Auth
        new BasicAuthProvider(),                    //Sign-in with Basic Auth
        new GoogleOpenIdOAuthProvider(appSettings), //Sign-in with Google OpenId
        new YahooOpenIdOAuthProvider(appSettings),  //Sign-in with Yahoo OpenId
        new OpenIdOAuthProvider(appSettings),       //Sign-in with Custom OpenId
    }));

ServiceStack CustomUserSession, UserAuth .

, :

Plugins.Add(new RegistrationFeature());

:

//container.RegisterAs<CustomRegistrationValidator, IValidator<Registration>>();

RDBMS OrmLite, DB Factory, SQLA UserAuth:

var connStr = appSettings.Get("SQLSERVER_CONNECTION_STRING", //AppHarbor or Local connection string
    ConfigUtils.GetConnectionString("UserAuth"));
container.Register<IDbConnectionFactory>(
    new OrmLiteConnectionFactory(connStr, //ConnectionString in Web.Config
        SqlServerOrmLiteDialectProvider.Instance) {
            ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
        });

ConnectionFilter , - ServiceStack.

, RDBMS , , IUserAuthRepository :

//Use OrmLite DB Connection to persist the UserAuth and AuthProvider info
container.Register<IUserAuthRepository>(c =>
    new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>())); 

OrmLiteAuthRepository, , AuthFeature:

//Drop and re-create all Auth and registration tables
var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>();
if (appSettings.Get("RecreateAuthTables", false))
    authRepo.DropAndReCreateTables(); 
else
    authRepo.CreateMissingTables(); //Create only the missing tables
+12

All Articles