public SSHController() { if (User.Identity.Name.Trim() != null && User.Identity.Name.Trim() != "") { userManager = GebruikerManager.Create(System.Web.HttpContext.Current.GetOwinContext() .Get <AppBuilderProvider>().Get().GetDataProtectionProvider()); // AppbuilderProvider is een custom klasse die geregistreerd wordt in de startup.auth.cs } Admin admin = admgr.GetAdmin(); string passwd = admgr.GetPasswd(admin); string trimpasswd = passwd.Replace("'", ""); ssh = new SshClient("10.0.12.240", 10000, "admin", trimpasswd); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var userManager = GebruikerManager.Create(System.Web.HttpContext.Current.GetOwinContext().Get <AppBuilderProvider>().Get().GetDataProtectionProvider()); Gebruiker user = await userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, OAuthDefaults.AuthenticationType); ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, CookieAuthenticationDefaults.AuthenticationType); AuthenticationProperties properties = CreateProperties(user.UserName); AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); context.Validated(ticket); context.Request.Context.Authentication.SignIn(cookiesIdentity); }
public GebruikerController() { _userManager = GebruikerManager.Create(System.Web.HttpContext.Current.GetOwinContext().Get <AppBuilderProvider>().Get().GetDataProtectionProvider()); // AppbuilderProvider is een custom klasse die geregistreerd wordt in de startup.auth.cs }