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(),
new IAuthProvider[] {
new CredentialsAuthProvider(),
new TwitterAuthProvider(appSettings),
new FacebookAuthProvider(appSettings),
new DigestAuthProvider(appSettings),
new BasicAuthProvider(),
new GoogleOpenIdOAuthProvider(appSettings),
new YahooOpenIdOAuthProvider(appSettings),
new OpenIdOAuthProvider(appSettings),
}));
ServiceStack CustomUserSession, UserAuth .
, :
Plugins.Add(new RegistrationFeature());
:
RDBMS OrmLite, DB Factory, SQLA UserAuth:
var connStr = appSettings.Get("SQLSERVER_CONNECTION_STRING",
ConfigUtils.GetConnectionString("UserAuth"));
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(connStr,
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