/// <summary> /// Handles the Click event of the LoginToAzure control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void LoginToAzure_Click(object sender, RoutedEventArgs e) { try { this.logger.LogInformation("Starting Azure login."); UserAuthenticator userAuthDetails = new UserAuthenticator(LoggingHelper.GetLogger <UserAuthenticator>()); // Raise Authentication prompt and log the user in. userAuthDetails.AuthenticateUserAsync().ConfigureAwait(false).GetAwaiter().GetResult(); this.logger.LogInformation("Token acquire complete."); SelectAzureRelay selectAzureRelay = new SelectAzureRelay(userAuthDetails); selectAzureRelay.Left = this.Left; selectAzureRelay.Top = this.Top; selectAzureRelay.Show(); this.Close(); } catch (Exception ex) { this.logger.LogError(ex, "Failed to Login into Azure"); MessageBox.Show("Failed to log you in!!", "Login failure", MessageBoxButton.OKCancel, MessageBoxImage.Error); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Set up the authentication service with the appropriate authenticator implementation FileStream accessControl = File.OpenRead(Path.Combine(Environment.CurrentDirectory, "users.json")); IUserAuthenticator userAuthenticator = new UserAuthenticator(); userAuthenticator.RefreshAccessList(accessControl); // Add various system services (rather than the custom ones) // Set up CORS to allow cross domain writing to the logging service services .AddLogging() .AddCors(options => { options.AddPolicy("CORSPolicy", builder => { builder.WithOrigins("http://localhost:60972", "https://localhost:44341"); }); }) .AddMvc(options => { // Add Custom Soap Envelope validation options.InputFormatters.Add(new SoapFormatter()); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); // Custom service setup for the API Manager services .AddCustomAuthentication(userAuthenticator) .AddCustomVersioning(); }
/// <summary> /// Here we have two user authenticators that we need to run together, since we just purchased a competitor's site. They are, however, incompatible in their methods. /// </summary> public static void Main() { User clint = User.CreateUser("Clint Eastwood", "MakeMyDayPunk"); IUserAuthenticator inHouseAuthenticator = new UserAuthenticator(); if (inHouseAuthenticator.CanAuthenticate(clint)) { Debug.WriteLine(clint.Name + " can access our site."); } else { // Go through the motions of the third-party authenticator, somewhat different to our in-house one. ThirdPartyAuthenticator thirdpartyAuthenticator = new ThirdPartyAuthenticator(); thirdpartyAuthenticator.StoreCredentials(clint.Name, clint.Password); // ... and try to authenticate using them both if (thirdpartyAuthenticator.TryToAuthenciate()) { Debug.WriteLine(clint.Name + " can access this website"); } else { Debug.WriteLine(clint.Name + " cannot access this website"); } } }
public static AuthenticationProfile Login(string emailAddress, string password) { var userAuthInfo = new UserAuthInfo { EmailAddress = emailAddress, Password = password }; var userInfo = UserAuthenticator.Authenticate(userAuthInfo, AuthenticationScope.Tenant); return(userInfo); }
private void SetData() { SQLServerAuthUserRepository repository = new SQLServerAuthUserRepository(); UserAuthenticator authenticator = new UserAuthenticator(repository); AuthenticateUserCommandHandler handler = new AuthenticateUserCommandHandler(authenticator); var data = new Dictionary <string, object>(); data.Add("handler", handler); login = new Login(data); }
private async void btnAuthenticate_Click(object sender, EventArgs e) { try { if (txtApplicationID.Text.Length > 20 && txtSharedSecret.Text.Length > 20) { btnAuthenticate.Text = "Authenticating..."; var appAuthInfo = new AppAuthInfo { ApplicationId = txtApplicationID.Text, SharedSecret = txtSharedSecret.Text }; if (txtEmail.Text.Contains("@") && txtEmail.Text.Contains(".") && txtPassword.Text.Length > 5) { await AppAuthenticator.InitializeAsync(appAuthInfo); btnAuthenticate.Text = "Loading Scopes..."; panelAPI.Visible = true; panelTenant.Visible = true; var userAuthInfo = new UserAuthInfo { EmailAddress = txtEmail.Text, Password = txtPassword.Text }; _userInfo = await UserAuthenticator.AuthenticateAsync(userAuthInfo, AuthenticationScope.Tenant); panelTenant.Visible = true; _userInfo.AuthorizedScopes.Insert(0, new Scope { Id = -1, Name = "[Select Tenant]" }); cbTenant.DataSource = _userInfo.AuthorizedScopes; btnAuthenticate.Text = "Renew Authentication"; } else { btnAuthenticate.Text = "Authenticate"; LogError(new Exception("Not enough User data entered for User Scope Authentication")); } } else { LogError(new Exception("Not enough Application data entered for Authentication")); } } catch (ApiException exc) { LogError(exc); btnAuthenticate.Text = "Authenticate"; } }
public void TestLocalUserPassword() { bool actual = false; bool expected = true; UserAuthenticator ua = new UserAuthenticator(AuthenticationMode.UserPassword); UserLoginResult res = ua.Login("Administrator", "admin", string.Empty); if (res == UserLoginResult.Ok) { actual = true; } Assert.AreEqual(actual, expected); }
public void TestLocalBadgeCode() { bool actual = false; bool expected = true; UserAuthenticator ua = new UserAuthenticator(AuthenticationMode.BadgeCode); UserLoginResult res = ua.Login(string.Empty, string.Empty, "12345"); if (ua.CurrentUser.LoginName == "Administrator" && res == UserLoginResult.Ok) { actual = true; } Assert.AreEqual(actual, expected); }
public ActionResult Login(string username, string password) { if (UserAuthenticator.TryLogIn(username, password, HttpContext.GetOwinContext())) { Session["apiUsername"] = username; Session["apiPassword"] = password; return(RedirectToAction("Summary", "Monitoring")); } else { return(View()); } }
private void doLoginIn_Click(object sender, EventArgs e) { //var fuser = new UserAuthenticator().Authenticate("mkabila", 123456); //AppInstance.Instance.CurrentUser = fuser; //StartActivity(typeof(LauncherActivity)); //return; var tusername = FindViewById <EditText>(Resource.Id.tUserName); var tpasscode = FindViewById <EditText>(Resource.Id.tPassCode); var uname = tusername.Text; if (string.IsNullOrWhiteSpace(uname) || string.IsNullOrWhiteSpace(tpasscode.Text)) { showDialog("Alert", "UserName and Passcode are both required"); return; } var passcode = Convert.ToInt32(tpasscode.Text); var authenticator = new UserAuthenticator(); var user = authenticator.Authenticate(uname, passcode); if (user != null) { //we set this as the logged in user AppInstance.Instance.CurrentUser = user; if (user.User.UserId == Constants.ADMIN_USERNAME) { //we show the admin view StartActivity(typeof(SystemConfigActivity)); } else { //load the main view and update current user options if (AppInstance.Instance.Configuration != null) { StartActivity(typeof(LauncherActivity)); } else { showDialog("Login Unsuccessful", "Please log in as Admin and set up the device"); } } } else { showDialog("Login Unsuccessful", "Could not log you in. Please check input supplied"); } }
public void TestRemoteBadgeCode() { bool actual = false; bool expected = true; string connectionString = "Data Source=192.168.100.250;Initial Catalog=TraMa4_520-334;User ID=TraMa;Password=trama"; UserAuthenticator ua = new UserAuthenticator(AuthenticationMode.BadgeCode, connectionString); UserLoginResult res = ua.Login(string.Empty, string.Empty, ";80380000100118208054?"); if (ua.CurrentUser.LoginName == "marco.dallera" && res == UserLoginResult.Ok) { actual = true; } Assert.AreEqual(actual, expected); }
/// <summary> /// Initializes a new instance of the <see cref="SelectAzureRelay"/> class. /// </summary> /// <param name="authenticationDetails">The authentication details for the user.</param> internal SelectAzureRelay(UserAuthenticator authenticationDetails) { this.ContentRendered += this.Window_ContentRendered; this.InitializeComponent(); this.userAuthenticator = authenticationDetails; this.relayResourceManager = new AzureRelayResourceManager(this.userAuthenticator); this.comboSubscriptionList.ItemsSource = this.subscriptions; this.comboAzureRelayList.ItemsSource = this.relays; // Disable controls to begin with. this.comboSubscriptionList.IsEnabled = false; this.comboAzureRelayList.IsEnabled = false; }
protected override UserAuthenticationDto ValidateCredentials(string name, string passwordHash, string customData, out string userData) { UserAuthenticationDto user = null; userData = null; UserDto authUser = UserAuthenticator.Authenticate(name, passwordHash); if (authUser != null) { user = new UserAuthenticationDto(); user.Name = authUser.Login; userData = authUser.Name; } return(user); }
/// <summary> /// Handles a login message from the client. /// If the user can be authenticated a User instance will be created, and the client will be able to log in. /// If the user cannot be authenticated, an error message will be send to the client. Indicating the username or password were wrong. /// </summary> /// <param name="message"></param> private void HandleLoginMessage(LoginMessage message) { Console.WriteLine("Handling Login"); User = UserAuthenticator.Authenticate(message.Username, message.Password, _userHandler); if (User == null) { SendMessage(new ErrorMessage("Login Failed")); } else { SendMessage(new OkLoginMessage()); _joinSession(message.SessionId, this); SendMessage(new OkLoginMessage()); Session.BroadCastChatMessage("Server", $"Welcome {message.Username}"); } }
/// <summary> /// By introducing the ThirdPartyAuthenticatorAdapter-class we have effectively wrapped the third-party authenticator, and can now call them in the same fashion. /// </summary> private static void Main() { User clint = User.CreateUser("Clint Eastwood", "MakeMyDayPunk"); IUserAuthenticator inHouseAuthenticator = new UserAuthenticator(); IUserAuthenticator thirdpartyAuthenticatorAdapter = new ThirdPartyAuthenticatorAdapter(); if (inHouseAuthenticator.CanAuthenticate(clint) || thirdpartyAuthenticatorAdapter.CanAuthenticate(clint)) { Debug.WriteLine(clint.Name + " can access our site."); } else { Debug.WriteLine(clint.Name + " cannot access this website"); } }
public void TestRemoteUserPassword() { bool actual = false; bool expected = true; //string connectionString = "Data Source=192.168.100.250;Initial Catalog=TraMa4_520-334;User ID=TraMa;Password=trama"; string connectionString = "Data Source=192.168.153.250;Initial Catalog=TraMa4_SLight;User ID=TraMa;Password=trama"; UserAuthenticator ua = new UserAuthenticator(AuthenticationMode.UserPassword, connectionString); UserLoginResult res = ua.Login("md", "md", string.Empty); //UserLoginResult res = ua.Login("marco.dallera", "md", string.Empty); if (res == UserLoginResult.Ok) { actual = true; } Assert.AreEqual(actual, expected); }
public ActionResult AdminLogin(LoginViewModel loginInfo) { if (String.IsNullOrEmpty((String)Session["user"])) { if (!ModelState.IsValid) { return(View()); } Administrator admin = UserAuthenticator.AuthenticateAdmin(loginInfo.email, loginInfo.password); if (admin != null) { Session["user"] = admin.email.Substring(0, admin.email.IndexOf("@")); return(RedirectToAction("AdminPage")); } else { ViewBag.failMessage = "Wrong email or password!"; return(View()); } } return(RedirectToAction("AdminPage")); }
public void SimpleAuthLoginTest() { var emailAddress = Mozu.Api.Test.Helpers.Environment.GetConfigValueByEnvironment("devOwnerEmail"); var password = Mozu.Api.Test.Helpers.Environment.GetConfigValueByEnvironment("devOwnerPassword"); var userAuthInfo = new UserAuthInfo { EmailAddress = emailAddress, Password = password }; var userInfo = UserAuthenticator.Authenticate(userAuthInfo, AuthenticationScope.Developer); Assert.IsNotNull(userInfo); Assert.IsNotNull(userInfo.AuthTicket); Assert.IsNotNull(userInfo.AuthTicket.AccessToken); if (userInfo.ActiveScope == null) { userInfo = UserAuthenticator.SetActiveScope(userInfo.AuthTicket, userInfo.AuthorizedScopes.First()); Assert.IsNotNull(userInfo); Assert.IsNotNull(userInfo.ActiveScope); } }
public async Task getInfo() { UserAuthenticator.SteamGuardAnswer sAnswer = new UserAuthenticator.SteamGuardAnswer(); UserAuthenticator.CaptchaAnswer cAnswer = new UserAuthenticator.CaptchaAnswer(); if (!string.IsNullOrWhiteSpace(txtSteamguard.Text)) { sAnswer.SolutionText = txtSteamguard.Text; } if (!string.IsNullOrWhiteSpace(txtCaptcha.Text)) { cAnswer.SolutionText = txtCaptcha.Text; } string captcha = txtCaptcha.Text; MessageBox.Show("fasiejfosfjois"); string user = txtUsername.Text; string password = txtPassword.Password; SteamUser swag = new SteamUser(); UserAuthenticator.SteamAccessRequestResult result = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password)); SteamguardID = result.SteamGuardID; if (result.IsCaptchaNeeded == true) { imgCaptcha.Source = new BitmapImage(new Uri(result.CaptchaURL.ToString())); MessageBox.Show("You received mail with captcha id"); } if (result.IsSteamGuardNeeded == true) { MessageBox.Show("You received mail with steamguard code"); } // MessageBox.Show("fasiejfosfjois"); // if (string.IsNullOrEmpty(txtCaptcha.Text) && !string.IsNullOrEmpty(txtSteamguard.Text)) //{ // SteamClient client = new SteamClient(); // string user = txtUsername.Text; // string password = txtPassword.Password; // SteamUser swag = new SteamUser(); // UserAuthenticator.SteamGuardAnswer realAnswer = new UserAuthenticator.SteamGuardAnswer(); // realAnswer.SolutionText = txtSteamguard.Text; // realAnswer.ID = SteamguardID; // UserAuthenticator.SteamAccessRequestResult result = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password,realAnswer)); // if (result.IsCaptchaNeeded == true) // { // imgCaptcha.Source = new BitmapImage(new Uri(result.CaptchaURL.ToString())); // MessageBox.Show("Check mail"); // } // if (result.IsSteamGuardNeeded == true) // { // MessageBox.Show("Check mail"); // } // SteamUser newUser = new SteamUser(); // newUser.SteamID = result.User.SteamID; // newUser.AuthCookie = result.User.AuthCookie; // newUser.TransferToken = result.User.TransferToken; // //SteamID newId = new SteamID(result.User.SteamID); // UserAuthenticator s = UserAuthenticator.ForProtectedResource(newUser.AuthCookie); // // SteamSharp.steam // //a/]][s.Authenticate(client,) // if(result.IsLoginComplete) // { // MessageBox.Show("Logged in as: " + newUser.SteamID + " auth token is :" + newUser.AuthCookie.Value.ToString()); // } // } }
private async void SaveUserOptions_Click(object sender, EventArgs e) { var userAuthenticator = new UserAuthenticator(); var userCreds = userAuthenticator.LoadCredentials(); var tNames = FindViewById <EditText>(Resource.Id.tUserNames); var tusername = FindViewById <EditText>(Resource.Id.tUserName); var tpasscode = FindViewById <EditText>(Resource.Id.tUserPassCode); var tpasscodAgain = FindViewById <EditText>(Resource.Id.tUserPassCodeAgain); if (string.IsNullOrWhiteSpace(tNames.Text) || string.IsNullOrWhiteSpace(tusername.Text) || string.IsNullOrWhiteSpace(tpasscode.Text) || (tpasscode.Text != tpasscodAgain.Text)) { showDialog("Alert", "UserName and Passcode are both required, and Passcodes should match"); return; } var uname = tusername.Text.ToLowerInvariant(); var passcode = Convert.ToInt32(tpasscode.Text); var hash = userAuthenticator.computeHash(uname, passcode); var matchingCred = (from cred in userCreds where cred.UserId == uname select cred).FirstOrDefault(); AppUser user = null; if (matchingCred == null) { //means we're ading a new user Toast.MakeText(this, "Creating new user", ToastLength.Long); var id = AppInstance.Instance.LocalEntityStoreInstance.InstanceLocalDb.newId(); user = new AppUser() { Id = new KindKey(id), EntityId = new KindKey(id), UserId = uname, Names = tNames.Text.ToUpperInvariant(), KnownBolg = hash, KindMetaData = (new KindMetaData() { chksum = 1, devid = AppInstance.Instance.Configuration.Serial, facidx = 0 } ).getJson() }; } else { //confirm with the user Toast.MakeText(this, "User found. Updating record", ToastLength.Long); user = matchingCred; user.KnownBolg = hash; user.Names = tNames.Text.ToUpperInvariant(); if (user.EntityId == null) { user.EntityId = user.Id; } if (string.IsNullOrWhiteSpace(user.KindMetaData)) { user.KindMetaData = (new KindMetaData() { chksum = 1, devid = AppInstance.Instance.Configuration.Serial, facidx = 0 } ).getJson(); } else { var metadata = new KindMetaData().fromJson(new KindItem(user.KindMetaData)); metadata.chksum += 1; user.KindMetaData = metadata.getJson(); } } //we save to the database Toast.MakeText(this, "Saving to database", ToastLength.Long); var saveableEntity = new DbSaveableEntity(user) { kindName = UserAuthenticator.KindName }; saveableEntity.Save(); Toast.MakeText(this, "Changes saved", ToastLength.Long); //we reset the form tNames.Text = ""; tusername.Text = ""; tpasscode.Text = ""; tpasscodAgain.Text = ""; //save to cloud var dbentity = new DbSaveableEntity(user.asGeneralEntity(UserAuthenticator.KindName)) { kindName = UserAuthenticator.KindName }; AppInstance.Instance.CloudDbInstance.AddToOutQueue(dbentity); await AppInstance.Instance.CloudDbInstance.EnsureServerSync(new WaitDialogHelper(this, sendToast)); }
private static async Task <ApplicationData> PerformInteractiveConfigurationAsync( IServiceProvider serviceProvider, string redirectionUrl = null) { Console.WriteLine("Please wait while we log you in..."); UserAuthenticator userAuthenticator = serviceProvider.GetRequiredService <UserAuthenticator>(); AzureRelayResourceManager relayResourceManager = serviceProvider.GetRequiredService <AzureRelayResourceManager>(); await userAuthenticator.AuthenticateUserAsync().ConfigureAwait(false); Console.WriteLine("Please wait while we gather subscription information..."); List <SubscriptionInner> userSubscriptions = await userAuthenticator.GetUserSubscriptionsAsync().ConfigureAwait(false); if (userSubscriptions.Count == 0) { Console.Error.WriteLine("No Azure subscriptions found"); throw new InvalidOperationException("User has no associated subscriptions"); } Console.WriteLine("Select the subscription you want to use"); for (int i = 0; i < userSubscriptions.Count; i++) { Console.WriteLine($"{i + 1} - {userSubscriptions[i].DisplayName}({userSubscriptions[i].SubscriptionId})"); } int selectedSubscriptionIndex = 0; while (true) { if (!int.TryParse(Console.ReadLine(), out selectedSubscriptionIndex)) { Console.Error.WriteLine("Invalid input. Please select the index."); continue; } if (selectedSubscriptionIndex > userSubscriptions.Count || selectedSubscriptionIndex == 0) { Console.Error.WriteLine("Invalid input. Select index out of allowed values"); continue; } break; } SubscriptionInner selectedSubscription = userSubscriptions[selectedSubscriptionIndex - 1]; List <RelayNamespaceInner> relayNamespaces = await relayResourceManager.GetRelayNamespacesAsync(selectedSubscription).ConfigureAwait(false); int selectedRelayIndex = 0; if (relayNamespaces.Count != 0) { Console.WriteLine("Select the Azure Relay you want to use."); Console.WriteLine("0 - Create a new Azure Relay"); for (int i = 0; i < relayNamespaces.Count; i++) { Console.WriteLine($"{i + 1} - {relayNamespaces[i].Name}"); } while (true) { if (!int.TryParse(Console.ReadLine(), out selectedRelayIndex)) { Console.Error.WriteLine("Invalid input. Please select the index."); continue; } if (selectedRelayIndex > relayNamespaces.Count) { Console.Error.WriteLine("Invalid input. Select index out of allowed values"); continue; } break; } } HybridConnectionDetails hybridConnectionDetails = null; if (selectedRelayIndex == 0) { Console.Write("Enter the name for the new Azure Relay. This must be atleast 6 character long and globally unique. "); string relayName = Console.ReadLine(); Console.WriteLine("Select the location for the new Relay from the list below"); List <Location> subscriptionLocations = userAuthenticator.GetSubscriptionLocations(selectedSubscription).ToList(); for (int i = 0; i < subscriptionLocations.Count; i++) { Console.WriteLine($"{i + 1} - {subscriptionLocations[i].DisplayName}"); } int selectedLocationIndex = 0; while (true) { if (!int.TryParse(Console.ReadLine(), out selectedLocationIndex)) { Console.Error.WriteLine("Invalid input. Please select the index."); continue; } if (selectedRelayIndex > subscriptionLocations.Count || selectedLocationIndex == 0) { Console.Error.WriteLine("Invalid input. Select index out of allowed values"); continue; } break; } Console.WriteLine("Please wait while the new Relay is being created"); hybridConnectionDetails = await relayResourceManager.CreateHybridConnectionAsync( selectedSubscription, relayName, Environment.MachineName, subscriptionLocations[selectedLocationIndex - 1].DisplayName).ConfigureAwait(false); } else { Console.WriteLine("Please wait while the details for Relay are fetched"); hybridConnectionDetails = await relayResourceManager.GetHybridConnectionAsync( selectedSubscription, relayNamespaces[selectedRelayIndex - 1], Environment.MachineName).ConfigureAwait(false); } if (string.IsNullOrEmpty(redirectionUrl)) { Console.Write("Enter the endpoint to route requests to. Example http://localhost:4200 "); redirectionUrl = Console.ReadLine(); } return(new ApplicationData { // DPAPI APIs used for encryption are only present on Windows. EnableCredentialEncryption = RuntimeInformation.IsOSPlatform(OSPlatform.Windows), EnabledPlugins = new HashSet <string>(), HybridConnectionKeyName = hybridConnectionDetails.HybridConnectionKeyName, HybridConnectionName = hybridConnectionDetails.HybridConnectionName, HybridConnectionSharedKey = hybridConnectionDetails.HybridConnectionSharedKey, HybridConnectionUrl = hybridConnectionDetails.RelayUrl, PluginSettingsMap = new Dictionary <string, Dictionary <string, string> >(), RedirectionUrl = redirectionUrl, }); }
public AuthenticatorController(UserAuthenticator userAuthenticator, UserLogin userLogin) { this.userAuthenticator = userAuthenticator; this.userLogin = userLogin; }
public ActionResult Login(LoginViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { // already logged in return(View("Manage")); } if (!UserAuthenticator.IsValid(model.Email, model.Password)) { // invalid username or password ModelState.AddModelError("", "Invalid email or password."); ViewBag.ReturnUrl = returnUrl; return(View(model)); } // load the user in memory var user = ApplicationUserEngine.GetApplicationUser(model.Email); // has the user authenticated their email address? if (!string.IsNullOrEmpty(user.ActivationKey)) { ModelState.AddModelError("", "Your account has not been activated."); ViewBag.ReturnUrl = returnUrl; return(View(model)); } // create our claim var ident = new ClaimsIdentity( new[] { // adding following 2 claim just for supporting default antiforgery provider new Claim(ClaimTypes.NameIdentifier, model.Email), new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string"), // Identity stuff to personalize the site new Claim(ClaimTypes.Email, model.Email), new Claim(ClaimTypes.Name, $"{user.DisplayName}#{user.Id}"), // extra data new Claim("Id", user.Id.ToString()), // add a role for a basic user // TODO: we'll need to add more roles for users for administrative permissions new Claim(ClaimTypes.Role, "User") }, DefaultAuthenticationTypes.ApplicationCookie); HttpContext.GetOwinContext().Authentication .SignIn(new AuthenticationProperties { IsPersistent = false, ExpiresUtc = DateTimeOffset.Now.AddDays(1) }, ident); if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); // auth succeed, take em to their destination } return(RedirectToAction("Index", "Home")); // auth succeed and no return url, take em home }
public async Task getAuth(string user, string password) { SteamClient client = new SteamClient(); UserAuthenticator.CaptchaAnswer captchaAns = new UserAuthenticator.CaptchaAnswer(); if (!string.IsNullOrWhiteSpace(txtSteamguard.Text)) { SteamguardSolution = txtSteamguard.Text; } if (!string.IsNullOrWhiteSpace(txtCaptcha.Text)) { captchaAns.SolutionText = txtCaptcha.Text; } //Wanneer er geen steamguard en captcha wordt meegegeven. if (loginPhase == 0) { try { UserAuthenticator.SteamAccessRequestResult authId = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password)); if (authId.IsSteamGuardNeeded) { SteamguardID = authId.SteamGuardID; MessageBox.Show("Please fill in the steam code you received by mail."); txtSteamguard.Visibility = Visibility.Visible; lblSteamguard.Visibility = Visibility.Visible; loginPhase = 1; } if (authId.IsCaptchaNeeded) { CaptchaID = authId.CaptchaGID; MessageBox.Show("Please fill in the captcha code"); txtCaptcha.Visibility = Visibility.Visible; lblCaptcha.Visibility = Visibility.Visible; new BitmapImage(new Uri(authId.CaptchaURL.ToString())); loginPhase = 2; } MessageBox.Show(authId.User.AuthCookie.ToString()); } catch (SteamAuthenticationException) { MessageBox.Show("Incorrect login information"); } } //Wanneer er een steamguard wordt meegegeven if (loginPhase == 1) { UserAuthenticator.SteamGuardAnswer steamguardAns = new UserAuthenticator.SteamGuardAnswer(); steamguardAns.ID = SteamguardID; steamguardAns.SolutionText = SteamguardSolution; UserAuthenticator.SteamAccessRequestResult authId = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password, steamguardAns)); if (authId.IsSteamGuardNeeded) { SteamguardID = authId.SteamGuardID; MessageBox.Show("Please fill in the steam code you received by mail."); txtSteamguard.Visibility = Visibility.Visible; lblSteamguard.Visibility = Visibility.Visible; } if (authId.IsCaptchaNeeded) { CaptchaID = authId.CaptchaGID; MessageBox.Show("Please fill in the captcha code"); txtCaptcha.Visibility = Visibility.Visible; lblCaptcha.Visibility = Visibility.Visible; new BitmapImage(new Uri(authId.CaptchaURL.ToString())); } MessageBox.Show(authId.User.AuthCookie.ToString()); //UserAuthenticator s = UserAuthenticator.ForProtectedResource(authId.User); //client.Authenticator = s; //ISteamRequest request; //request.SteamApiMethod(SteamNews.GetNewsForAppAsync(client,4,4,4)); //MessageBox.Show(player.PersonaName.ToString()); } }
public ServiceSecurityPolicy(UserAuthenticator Authenticator, Dictionary <string, string> Policies) { this.Authenticator = Authenticator; this.Policies = Policies; }
public ServiceSecurityPolicy() { Authenticator = null; Policies = null; }
public AuthRespositoryTest() { repository = new SQLServerAuthUserRepository(); authenticator = new UserAuthenticator(repository); handler = new AuthenticateUserCommandHandler(authenticator); }