forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppHost.cs
More file actions
46 lines (40 loc) · 1.23 KB
/
Copy pathAppHost.cs
File metadata and controls
46 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Funq;
using ServiceStack.CacheAccess;
using ServiceStack.CacheAccess.Providers;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceInterface.Auth;
using ServiceStack.WebHost.Endpoints;
using ServiceStack.WebHost.Endpoints.Tests;
namespace ServiceStack.WebHostApp
{
public class AppHost
: AppHostBase
{
public AppHost()
: base("Validation Tests", typeof(SecuredService).Assembly) { }
public override void Configure(Container container)
{
Plugins.Add(new AuthFeature(() => 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("test1", out hash, out salt);
userRep.CreateUserAuth(new UserAuth {
Id = 1,
DisplayName = "DisplayName",
Email = "as@if.com",
UserName = "test1",
FirstName = "FirstName",
LastName = "LastName",
PasswordHash = hash,
Salt = salt,
}, "test1");
}
}
}