//Configure ServiceStack Authentication and CustomUserSession private void ConfigureAuth(Funq.Container container) { Routes .Add <Auth>("/auth") .Add <Auth>("/auth/{provider}") .Add <Registration>("/register"); var appSettings = new AppSettings(); AuthFeature.Init(this, () => new CustomUserSession(), new IAuthProvider[] { new CredentialsAuthProvider(appSettings), new FacebookAuthProvider(appSettings), new TwitterAuthProvider(appSettings), new BasicAuthProvider(appSettings), }); RegistrationFeature.Init(this); container.Register <IUserAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve <IDbConnectionFactory>())); var authRepo = (OrmLiteAuthRepository)container.Resolve <IUserAuthRepository>(); if (new AppSettings().Get("Recr eateTables", true)) { authRepo.DropAndReCreateTables(); } else { authRepo.CreateMissingTables(); } }
protected void InitTest(IUserAuthRepository userAuthRepository) { new RedisClient().FlushAll(); ((IClearable)userAuthRepository).Clear(); var appsettingsMock = new Mock <IResourceManager>(); var appSettings = appsettingsMock.Object; AuthFeature.Init(null, null, new IAuthProvider[] { new CredentialsAuthProvider(), new BasicAuthProvider(), new FacebookAuthProvider(appSettings), new TwitterAuthProvider(appSettings) }); mockService = new Mock <IServiceBase>(); mockService.Expect(x => x.TryResolve <IUserAuthRepository>()).Returns(userAuthRepository); requestContext = new MockRequestContext(); mockService.Expect(x => x.RequestContext).Returns(requestContext); service = mockService.Object; registrationDto = new Registration { UserName = "******", Password = "******", Email = "*****@*****.**", DisplayName = "DisplayName", FirstName = "FirstName", LastName = "LastName", }; }
public override void Configure(Container container) { AuthFeature.Init(this, () => new CustomUserSession(), new AuthProvider[] { new CredentialsAuthProvider(), //HTML Form post of UserName/Password credentials new BasicAuthProvider(), //Sign-in with Basic Auth }); container.Register <ICacheClient>(new MemoryCacheClient()); var userRep = new InMemoryAuthRepository(); container.Register <IUserAuthRepository>(userRep); string hash; string salt; new SaltedHash().GetHashAndSaltString(Password, out hash, out salt); userRep.CreateUserAuth(new UserAuth { Id = 1, DisplayName = "DisplayName", Email = "*****@*****.**", UserName = UserName, FirstName = "FirstName", LastName = "LastName", PasswordHash = hash, Salt = salt, }, Password); }
public override void Configure(Container container) { AuthFeature.Init(this, () => new CustomUserSession(), new AuthConfig[] { new CredentialsAuthConfig(), //HTML Form post of UserName/Password credentials new BasicAuthConfig(), //Sign-in with Basic Auth }); container.Register <ICacheClient>(new MemoryCacheClient()); container.Register <IUserAuthRepository>(new InMemoryAuthRepository()); }