Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal class SelfHost : AppSelfHostBase
- {
- public SelfHost() : base("HttpListener Self-Host", typeof(ServerEventsService).Assembly)
- {
- }
- public override void Configure(Container container)
- {
- Plugins.Add(new ServerEventsFeature
- {
- LimitToAuthenticatedUsers = true,
- NotifyChannelOfSubscriptions = false,
- OnHeartbeatInit = req =>
- {
- var userSession = req.GetSession();
- var sessionKey = SessionFeature.GetSessionKey(req.GetSessionId());
- }
- });
- container.Register<ICacheClient>(new MemoryCacheClient());
- Plugins.Add(new AuthFeature(() => new AuthUserSession(),
- new IAuthProvider[]
- {
- //new StreamSecurityAuthProvider()
- new CredentialsAuthProvider
- {
- SessionExpiry = TimeSpan.FromSeconds(30),
- SkipPasswordVerificationForInProcessRequests = true,
- },
- })
- );
- var userRep = new InMemoryAuthRepository();
- container.Register<IUserAuthRepository>(userRep);
- string hash;
- string salt;
- var pwd = "ValidPassword";
- new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
- userRep.CreateUserAuth(new UserAuth
- {
- Id = 3,
- DisplayName = "CustomDisplayName2",
- Email = "test2@gmail.com",
- UserName = "CustomUserName2",
- FirstName = "FirstName2",
- LastName = "LastName2",
- PasswordHash = hash,
- Salt = salt,
- }, pwd);
- }
- }
- _mainClient = new ServerEventsClient(baseUrl, "home");
- var authResponse = _mainClient.Authenticate(new Authenticate
- {
- provider = "credentials",
- UserName = "CustomUserName2",
- Password = "ValidPassword",
- //Password = "wfjuwheiu",
- RememberMe = false,
- });
- mainClient.Connect().Wait();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement