• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Company · Blog · Newsletter · Events · Partner Program

Downloads      Support      Security     Admin Login
Rublon

Rublon

Secure Remote Access

  • Product
    • Regulatory Compliance
    • Use Cases
    • Rublon Reviews
    • Authentication Basics
    • What is MFA?
    • Importance of MFA
    • User Experience
    • Authentication Methods
    • Rublon Authenticator
    • Remembered Devices
    • Logs
    • Single Sign-On
    • Access Policies
    • Directory Sync
  • Solutions
    • MFA for Remote Desktop
    • MFA for Remote Access Software
    • MFA for Windows Logon
    • MFA for Linux
    • MFA for Active Directory
    • MFA for LDAP
    • MFA for RADIUS
    • MFA for SAML
    • MFA for RemoteApp
    • MFA for Workgroup Accounts
    • MFA for Entra ID
  • Customers
  • Industries
    • Financial Services
    • Investment Funds
    • Retail
    • Technology
    • Healthcare
    • Legal
    • Education
    • Government
  • Pricing
  • Docs
Contact Sales Free Trial

Rublon .NET SDK: Secure .NET Apps with MFA

October 9, 2024 By Rublon Authors

Last updated on July 8, 2025

Overview

The Rublon .NET SDK library is a client-side implementation of the Rublon API written in C# (.NET Framework). It forms a convenient C# coding language facade for Rublon API’s REST interface.

The library is available on NuGet.

The minimum required version of the .NET Framework: is 4.5.

Use Cases

Rublon adds an extra layer of security by prompting the user to authenticate using an extra authentication method such as Mobile Push. Even if a malicious actor compromises the user’s password, the hacker would not be able to log in to the user’s account because the second secure factor will thwart them.

Rublon can add an extra layer of security in the following two use cases:

  1. When a user signs in to a system (after the user enters the correct password)
  2. When a user undergoes a security-sensitive transaction (such as changing the password or conducting a money transfer)

When a user signs in to a system, the second authentication factor should be initiated only after:

  • the user has successfully completed the first authentication factor (e.g., entered the correct password)
  • the username (and optionally, email address) have been gathered

Supported Authentication Methods

Authentication Method Supported Comments
Mobile Push ✔ N/A
WebAuthn/U2F Security Key ✔ N/A
Passcode ✔ N/A
SMS Passcode ✔ N/A
SMS Link ✔ N/A
Phone Call ✔ N/A
QR Code ✔ N/A
Email Link ✔ N/A
YubiKey OTP Security Key ✔ N/A

Before You Start

Before you start implementing the Rublon .NET SDK library into your code, you must create an application in the Rublon Admin Console. We also recommend that you install the Rublon Authenticator mobile app.

Get the SDK

Download the Rublon .NET SDK.

Create an Application in the Rublon Admin Console

  1. Sign up for the Rublon Admin Console. Here’s how.
  2. In the Rublon Admin Console, go to the Applications tab and click Add Application.
  3. Enter a name for your application and then set the type to Other.
  4. Click Save to add the new .NET SDK application in the Rublon Admin Console.
  5. Copy and save the values of System Token and Secret Key. You are going to need these values later.

Optional: Install Rublon Authenticator

For increased security of Multi-Factor Authentication (MFA), end-users are recommended to install the Rublon Authenticator mobile app.

Download the Rublon Authenticator for:

  • Android
  • iOS
  • HarmonyOS

After installing the mobile app, users can authenticate using the following authentication methods:

  • Mobile Push
  • Mobile Passcode
  • QR Code

In some cases, users may not want to install any additional apps on their phones. Also, some users own older phones that do not support modern mobile applications. These users can authenticate using one of the following authentication methods instead:

  • WebAuthn/U2F Security Keys
  • SMS Passcode
  • SMS Link
  • Email Link
  • WebAuthn/U2F Security Keys
  • YubiKey OTP

Configuration

Follow the steps below to configure Rublon .NET SDK.

INFO: Initial Assumptions

Let’s assume there is a session handler class Session. It has access to an object that stores the user data of the currently logged-in user. Also, let’s assume there is the HttpServer class which is a simple HTTP server instance.

INFO: Modifying the Library

The Rublon class implements a few public methods, which, when needed, can be overridden with inheritance.

We strongly discourage you from modifying any part of the library, as it usually leads to difficulties during library updates. If you need to change the flow or internal structure of the Rublon or RublonCallback classes, do not hesitate to subclass them according to your needs.

Initialize the Library

To initialize the Rublon .NET SDK library, you need to instantiate a Rublon class object. Its constructor takes three arguments.

Rublon class constructor arguments:

NameTypeDescription
systemTokenStringThe System Token value you copied from the Rublon Admin Console.
secretKeyStringThe Secret Key value you copied from the Rublon Admin Console.
apiServerStringOptional.
Rublon API Server URI.
Default: https://core.rublon.net

Example .NET Code

using Rublon.Sdk.twofactor.Rublon;

...

var rublon = new Rublon(
	// system token:
	"A69FC450848B4B94A040416DC4421523",
	// secret key:
	"bLS6NDP7pGjg346S4IHqTHgQQjjSLw3CyApvz5iRjYzgIPN4e9EOi1cQJLrTlvLoHY8zeqg4ILrItYidKJ6JjEUZaA6pR1tZMwSZ"
);

Perform Authentication

The Rublon.Auth() method uses the username to check the user’s protection status and returns a URL address the user should be redirected to in their web browser. The method returns null if the user’s protection is not active.

The Rublon.Auth() method has one argument of type AuthenticationParameters with the following fields:

Rublon.Auth() method arguments:

Property NameTypeDescription
CallbackUrlStringRequired.

The integrated system’s callback URL.

Rublon will redirect the user to this URL after successful authentication
UserNameStringRequired.

The user’s unique ID, which allows to check the user’s protection status and match the user to a Rublon account.
UserEmailJSONObjectOptional.

The user’s email address. This is an optional parameter and can be empty. If set, the email address will be set in the Rublon Admin Console for the given username.
AdditionalParamsJSONObjectOptional.

Additional transaction parameters (optional). You can use the ParamsBuilder class to prepare parameters easily.

Example .NET Code

An example of logging in a user on an integrated system:

/**
 * An example method used to log the user in (integrated system's method)
 */
void login(String login, String password) {

	if (loginPreListener()) {
		User user = authenticate(login, password);
		if (user != null) {
		
			// The user has been authenticated.
			Session.setUser(user);
			loginPostListener();
			
		}
	}
	
}


/**
 * Listener (hook) invoked after a successful first factor user authentication,
 * implemented for Rublon integration purposes.
 */
void loginPostListener() {
	
	Rublon rublon = new Rublon(
		// systemToken (please store in a config):
		"A69FC450848B4B94A040416DC4421523",
		// secretKey (please store in a safe config):
		"bLS6NDP7pGjg346S4IHqTHgQQjjSLw3CyApvz5iRjYzgIPN4e9EOi1cQJLrTlvLoHY8zeqg4ILrItYidKJ6JjEUZaA6pR1tZMwSZ"
	);
	
	try { // Initiate a Rublon authentication transaction
	
		String url = rublon.Auth(new AuthenticationParameters(){
				CallbackUrl = "https://example.com/rublon_callback", 
				Username = Session.getUser().getId()
			}
		);
		
		if (url != null) { // User protection is active
		
			// Log the user out before checking the second factor:
			Session.setUser(null);
			
			// Redirect the user's web browser to Rublon servers
			// to verify the protection:
			HttpServer.sendHeader("Location", url);
			
		}
		
	} catch (RublonException e) {
		// An error occurred
		Session.setUser(null);
		HttpServer.setStatus(500);
		HttpServer.setResponse("There was an error, please try again later.");
	}
	
	/* If we're here, the user's account is not protected by Rublon.
	The user can be authenticated. */

}

Note: Make sure that your code checks that the user is not signed in. The user should be signed in only after successful Rublon authentication.

Finalize Authentication

After successful authentication, Rublon redirects the user to the callback URL. The callback flow continues and finalizes the authentication process.

Input Params

The callback URL will receive its input arguments in the URL address itself (query string).

Callback URL arguments:

NameTypeDescription
rublonStateStringAuthentication result: ok, error or cancel
rublonTokenStringAccess token (100 alphanumeric characters, upper- and lowercase), which allows verifying the authentication using a background Rublon API connection

Note: If the callback URL has been set to, e.g., https://example.com/twofactor/auth/, the params will be appended to the URL address:

https://example.com/twofactor/auth/?rublonState=ok&rublonToken=Kmad4hAS…d

Note: If you want to construct the callback URL differently (e.g., by using URL Rewrite), you can set the callback URL’s template using the meta-tags: %rublonToken% and %rublonState% like so:

https://example.com/twofactor/auth/%rublonState%/%rublonToken%

Handle Authentication Result

After the callback is invoked, you need to create a RublonCallback subclass instance to properly finalize authentication. Since the RublonCallback class is abstract, you need to create a subclass that implements the methods you need. The implementation is up to you and depends on your requirements and unique system details.

RublonCallback class constructor method arguments:

NameTypeDescription
rublonRublonAn instance of the Rublon class.

Next, call the RublonCallback.Call() method.

You should implement the following abstract methods in a subclass.

  • String GetState() – returns the “rublonState” parameter from the HTTP GET request.
  • String GetAccessToken() – returns the “rublonToken” parameter from the HTTP GET request.
  • void HandleCancel() – called when the state parameter is not “ok” nor “error”.
  • void HandleError() – called when the state parameter value is “error”.
  • void UserAuthenticated(String appUserId) – handle the authenticated user with given user’s local ID.

Example .NET Code

An example implementation of the RublonCallback class and usage in the callback:

class Callback extends RublonCallback {
	public String GetState() {
		return HttpServer.getRequestHandler().getParam(PARAMETER_STATE);
	}
	public String GetAccessToken() {
		return HttpServer.getRequestHandler().getParam(PARAMETER_ACCESS_TOKEN);
	}
	protected void HandleCancel() {
		HttpServer.sendHeader("Location", "/login");
	}
	protected void HandleError() {
		HttpServer.sendHeader("Location", "/login?msg=rublon-error");
	}
	protected void UserAuthenticated(String appUserId) {
		Session.setUser(User.getById(appUserId));
		HttpServer.sendHeader("Location", "/dashboard");
	}
}

...

Rublon rublon = new Rublon(
	"A69FC450848B4B94A040416DC4421523",
	"bLS6NDP7pGjg346S4IHqTHgQQjjSLw3CyApvz5iRjYzgIPN4e9EOi1cQJLrTlvLoHY8zeqg4ILrItYidKJ6JjEUZaA6pR1tZMwSZ"
);
	
try {

	RublonCallback callback = new RublonCallback(rublon);
	callback.Call();
	
} catch (CallbackException e) {
	// Please handle this error in the better way:
	HttpServer.setStatus(500);
	HttpServer.setResponse("There was an error, please try again later. " + e.getMessage());
}

Troubleshooting

If you encounter any issues with your Rublon integration, please contact Rublon Support.

Filed Under: Documentation

Primary Sidebar

Contents

  • Overview
  • Use Cases
  • Supported Authentication Methods
  • Before You Start
    • Get the SDK
    • Create an Application in the Rublon Admin Console
    • Optional: Install Rublon Authenticator
  • Configuration
    • INFO: Initial Assumptions
    • INFO: Modifying the Library
    • Initialize the Library
      • Example .NET Code
    • Perform Authentication
      • Example .NET Code
    • Finalize Authentication
      • Input Params
      • Handle Authentication Result
      • Example .NET Code
  • Troubleshooting
Try Rublon for Free
Start your 30-day Rublon Trial to secure your employees using multi-factor authentication.
No Credit Card Required


Footer

Product

  • Regulatory Compliance
  • Use Cases
  • Rublon Reviews
  • Authentication Basics
  • What is MFA?
  • Importance of MFA
  • User Experience
  • Authentication Methods
  • Rublon Authenticator
  • Remembered Devices
  • Logs
  • Single Sign-On
  • Access Policies
  • Directory Sync

Solutions

  • MFA for Remote Desktop
  • MFA for Windows Logon
  • MFA for Remote Access Software
  • MFA for Linux
  • MFA for Active Directory
  • MFA for LDAP
  • MFA for RADIUS
  • MFA for SAML
  • MFA for RemoteApp
  • MFA for Workgroup Accounts
  • MFA for Entra ID

Industries

  • Financial Services
  • Investment Funds
  • Retail
  • Technology
  • Healthcare
  • Legal
  • Education
  • Government

Documentation

  • 2FA for Windows & RDP
  • 2FA for RDS
  • 2FA for RD Gateway
  • 2FA for RD Web Access
  • 2FA for SSH
  • 2FA for OpenVPN
  • 2FA for SonicWall VPN
  • 2FA for Cisco VPN
  • 2FA for Office 365

Support

  • Knowledge Base
  • FAQ
  • System Status

About

  • About Us
  • Blog
  • Events
  • Co-funded by the European Union
  • Contact Us

  • Facebook
  • GitHub
  • LinkedIn
  • Twitter
  • YouTube

© 2025 Rublon · Imprint · Legal & Privacy · Security

  • English