protected static void CheckPermissions(DecryptedRequest decryptedRequest, SecureApiSettings secureApiSettings)
        {
            if (decryptedRequest == null)
            {
                throw new ArgumentNullException(nameof(decryptedRequest));
            }

            if (!secureApiSettings.IsSecureApiEnabled)
            {
                throw new X1WalletException(HttpStatusCode.Unauthorized,
                                            "SecureApi is disabled by configuration/arguments", null);
            }

            if (string.IsNullOrWhiteSpace(secureApiSettings.SecureApiUser) || string.IsNullOrWhiteSpace(secureApiSettings.SecureApiPassword))
            {
                return;
            }

            var user     = secureApiSettings.SecureApiUser.Trim();
            var password = secureApiSettings.SecureApiPassword.Trim();

            if (user != decryptedRequest.User || password != decryptedRequest.Password)
            {
                throw new X1WalletException(HttpStatusCode.Unauthorized,
                                            "Invalid credentials.", null);
            }
        }
Пример #2
0
 /// <summary>
 /// Get the default configuration.
 /// </summary>
 /// <param name="builder">The string builder to add the settings to.</param>
 /// <param name="network">The network to base the defaults off.</param>
 public static void BuildDefaultConfigurationFile(StringBuilder builder, Network network)
 {
     SecureApiSettings.BuildDefaultConfigurationFile(builder, network);
 }
Пример #3
0
 public SecureApiController(WalletController walletController, SecureApiSettings secureApiSettings)
 {
     this.walletController          = walletController;
     this.secureApiSettings         = secureApiSettings;
     CommandsWithoutWalletNameCheck = new[] { "createWallet", "getWalletFiles" };
 }
Пример #4
0
 /// <summary>
 /// Prints the help information on how to configure the settings to the logger.
 /// </summary>
 /// <param name="network">The network to use.</param>
 public static void PrintHelp(Network network)
 {
     SecureApiSettings.PrintHelp(network);
 }