예제 #1
0
 public Configuration()
 {
     Authentication = new AuthenticationProfile();
     Proxy          = new ProxyProfile();
     ServerProfiles = new List <ServerProfile>();
     ChampionNames  = new SerialisableDictionary <int, string>();
 }
예제 #2
0
        public Configuration()
        {
            //20 minutes
            AutomaticUpdateInterval = 20 * 60;

            //5 seconds
            ReconnectDelay = 5 * 1000;

            //Default to SQLite instead of Mono
            DatabaseProvider = "System.Data.SQLite";

            Database = "RiotControl.sqlite";

            Index = "Index.html.template";

            RankedSeason = 2;

            MinimiseToTray = true;

            Web            = new WebConfiguration();
            Authentication = new AuthenticationProfile();

            Proxy = new ProxyProfile();

            //Not really necessary
            Privileges = new List <PrivilegeClass>();

            //Not really necessary
            RegionProfiles = new List <EngineRegionProfile>();
        }
예제 #3
0
 public ConnectionProfile(AuthenticationProfile authentication, RegionProfile region, string user, string password)
 {
     Authentication = authentication;
     Region = region;
     User = user;
     Password = password;
 }
        public ConnectionProfile(AuthenticationProfile authentication, RegionProfile region, ProxyProfile proxy, string user, string password)
        {
            Authentication = authentication;
            Region         = region;
            Proxy          = proxy;

            User     = user;
            Password = password;
        }
예제 #5
0
 void InitialiseAuthenticationProfile()
 {
     //Create a new authentication profile that uses the client version from the master server instead of the (null) one provided by the configuration file
     AuthenticationProfile = new AuthenticationProfile();
     AuthenticationProfile.ClientVersion = Profile.ClientVersion;
     AuthenticationProfile.Domain        = Configuration.Authentication.Domain;
     AuthenticationProfile.IPAddress     = Configuration.Authentication.IPAddress;
     AuthenticationProfile.Locale        = Configuration.Authentication.Locale;
 }
예제 #6
0
        public static Dictionary <Int32, Scope> GetSandboxes(AuthenticationProfile authenticationProfile)
        {
            var sandboxes = new Dictionary <Int32, Scope>();
            var sbCount   = 0;

            foreach (var sandbox in authenticationProfile.AuthorizedScopes)
            {
                sandboxes.Add(++sbCount, sandbox);
            }
            return(sandboxes);
        }
예제 #7
0
        public SandboxSelector(AuthenticationProfile authenticationProfile)
        {
            InitializeComponent();

            // Add all of the sandboxes to the list
            _sandboxes = Account.GetSandboxes(authenticationProfile);
            foreach (var scope in _sandboxes.Values)
            {
                this.listSandboxes.Items.Add(new ViewScope(scope));
            }
        }
예제 #8
0
        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";
            }
        }
예제 #9
0
        public async Task Execute()
        {
            if (this.isValidated == false)
            {
                await Validate();
            }
            if (this.credential.LoginID == "TST-USER" && this.credential.LoginPassword == "TST-PSSWRD")
            {
                this.accessToken = new AccessToken
                {
                    LoginID    = "TST-USER",
                    IsLongTerm = true,
                    UserID     = new Guid(),
                    UserName   = "******"
                };
                Guid g = Guid.Empty;
                Guid.TryParse("b79d510f-eaf3-439f-b884-931b179fe3d3", out g);
                this.accessToken.AccessTokenID = g;
                this.accessTokenID             = g;
                this.httpStatusCode            = HttpStatusCode.OK;
                Debug.Print("Login with test user");
                return;
            }
            try
            {
                //If accessToken is null we are logging in for the first time
                if (this.accessToken == null)
                {
                    if (this.httpStatusCode == System.Net.HttpStatusCode.OK)
                    {
                        // handle login/token-creation or simply create an anonymous token
                        if (this.httpStatusCode == HttpStatusCode.OK)
                        {
                            if ((string.IsNullOrEmpty(this.credential.LoginID) == false) && (string.IsNullOrEmpty(this.credential.LoginPassword) == false))
                            {
                                // Authenticate User Based on Login ID and Login Password
                                // Only Daytona users are able to create a token and login at the same time
                                User user = AuthenticateUserLogic.AuthenticateUser(
                                    this.databaseSettings,
                                    this.credential.LoginID,
                                    this.credential.LoginPassword);

                                if (user != null)
                                {
                                    this.accessTokenID = await AccessTokenLogic.CreateAccessTokenAsync(this.databaseSettings, user.UserID);
                                }


                                Debug.Print("[AccessTokensController.Post] Access Token Created = " + this.accessTokenID.ToString());
                                this.accessToken = await AccessTokenLogic.GetAccessTokenAsync(this.databaseSettings, this.accessTokenID);
                            }
                        }
                    }
                }
                else
                {
                    AuthenticationProfile authenticationProfile = new AuthenticationProfile
                    {
                        AutoLoginUserID   = this.accessToken.UserID,
                        AutoLoginIsActive = true
                    };

                    //
                    // The Access Token already exists so wee are just updating it
                    //
                    if ((string.IsNullOrEmpty(this.credential.LoginID) == false) && (string.IsNullOrEmpty(this.credential.LoginPassword) == false))
                    {
                        // Attach a new user to an existing token if valid
                        User user = AuthenticateUserLogic.AuthenticateUser(
                            this.databaseSettings,
                            this.credential.LoginID,
                            this.credential.LoginPassword);

                        if (user != null)
                        {
                            if (string.IsNullOrEmpty(this.credential.NewLoginPassword) == false)
                            {
                                UserProfiles userProfiles = await UserProfileLogic.UserProfileGet(this.databaseSettings, Guid.Empty, user.UserID);

                                UserProfile userProfile = userProfiles.FirstOrDefault();
                                // we've made it this far, so no need to check the old password
                                userProfile.Password = this.credential.NewLoginPassword;
                                userProfile.IsPasswordChangeRequired = false;
                                UserProfileChangePasswordCommand command = new UserProfileChangePasswordCommand(
                                    datastoreProfile: this.databaseSettings,
                                    effectiveUserID: user.UserID,
                                    userProfile: userProfile
                                    );
                                if (await command.Execute())
                                {
                                    // good to go
                                }
                                else
                                {
                                    this.errorOut       = command.ErrorOut;
                                    this.httpStatusCode = command.HttpStatusCode;
                                    return;
                                }
                            }
                        }

                        if (user == null)
                        {
                            this.accessToken = null;
                            Debug.Print("[AccessTokensController.Post] User - Invalid Login or Password.");

                            if (this.errorOut == null)
                            {
                                this.errorOut = new ErrorOut(20025, "Invalid Login or Password. (20025)");
                            }
                            this.httpStatusCode = System.Net.HttpStatusCode.Unauthorized;
                        }
                        else
                        {
                            AccessTokenLogic.ChangeUser(this.databaseSettings, this.accessTokenID, user.UserID, this.credential.IsLongTerm);
                            Debug.Print("[AccessTokensController.Post] User changed.");
                            // Access Token has been changed, so reload it
                            this.accessToken = AccessTokenLogic.GetAccessToken(this.databaseSettings, this.accessTokenID);
                        }
                    }
                    else
                    {
                        // Clear the user off the token
                        AccessTokenLogic.ChangeUser(this.databaseSettings, this.accessTokenID, authenticationProfile.AutoLoginUserID, false);
                        Debug.Print("[AccessTokensController.Post] User cleared.");
                        // Access Token has been changed, so reload it
                        this.accessToken = AccessTokenLogic.GetAccessToken(this.databaseSettings, this.accessTokenID);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print("[AccessTokensController.Post] Unhandled Exception: " + ex.ToString());
                this.httpStatusCode = HttpStatusCode.InternalServerError;
                this.errorOut       = new ErrorOut(0, "Unhandled Exception");
            }
            if (this.httpStatusCode == System.Net.HttpStatusCode.OK)
            {
                if (this.accessToken == null)
                {
                    Debug.Print("[AccessTokensController.Post] Returning Unauthorized.");
                    if (this.errorOut == null && string.IsNullOrEmpty(this.credential.LoginID) == false)
                    {
                        this.errorOut = new ErrorOut(20025, "Invalid Login or Password. (20025)");
                    }
                    this.httpStatusCode = HttpStatusCode.Unauthorized;
                }
            }
        }