Skip to main content

Authentication

The Reveal SDK allows you to provide various methods of authentication such as Username/Password and Bearer Token authentication credentials to your data sources by using an authentication provider and registering that provider with the Reveal SDK.

The authentication provider is used to check which data source is requesting authentication credentials, and then return the correct authentication credentials for that specific data source.

Step 1 - Create the authentication provider.

public class AuthenticationProvider: IRVAuthenticationProvider
{
public Task<IRVDataSourceCredential> ResolveCredentialsAsync(IRVUserContext userContext, RVDashboardDataSource dataSource)
{
...
}
}

Step 2 - Register the authentication provider with the Reveal SDK.

builder.Services.AddControllers().AddReveal( builder =>
{
builder.AddAuthenticationProvider<AuthenticationProvider>();
});

Username/Password Authentication

If your data source requires the use of a username and password, then you must return an instance of the RVUsernamePasswordDataSourceCredential class. The RVUsernamePasswordDataSourceCredential class provides constructor overloads to define the username, the password, and optionally the domain.

public class AuthenticationProvider: IRVAuthenticationProvider
{
public Task<IRVDataSourceCredential> ResolveCredentialsAsync(IRVUserContext userContext, RVDashboardDataSource dataSource)
{
IRVDataSourceCredential userCredential = null;
if (dataSource is RVPostgresDataSource)
{
userCredential = new RVUsernamePasswordDataSourceCredential("username", "password");
}
else if (dataSource is RVSqlServerDataSource)
{
userCredential = new RVUsernamePasswordDataSourceCredential("username", "password", "domain");
}
return Task.FromResult<IRVDataSourceCredential>(userCredential);
}
}

If your data source is using an anonymous login, without authentication, you can use the RVUsernamePasswordDataSourceCredential with its empty constructor.

if (dataSource is RVSqlServerDataSource)
{
userCredential = new RVUsernamePasswordDataSourceCredential();
}

The RVUsernamePasswordDataSourceCredential is supported for the following data sources:

  • Amazon Redshift
  • Microsoft Analysis Services Server
  • Microsoft Dynamics CRM (On-Premises and Online)
  • Microsoft SQL Server
  • MySQL
  • OData Services
  • Oracle
  • PostgreSQL
  • REST Services
  • Sybase
  • Web Resources

Bearer Token Authentication

If your data source requires the use of security tokens, then you must return an instance of the RVBearerTokenDataSourceCredential class. The RVBearerTokenDataSourceCredential class provides constructor overloads to define the token, and the user id.

public class AuthenticationProvider: IRVAuthenticationProvider
{
public Task<IRVDataSourceCredential> ResolveCredentialsAsync(IRVUserContext userContext, RVDashboardDataSource dataSource)
{
IRVDataSourceCredential userCredential = null;
if (dataSource is RVGoogleDriveDataSource)
{
userCredential = new RVBearerTokenDataSourceCredential("token", "userid");
}
return Task.FromResult<IRVDataSourceCredential>(userCredential);
}
}

The RVBearerTokenDataSourceCredential is supported for the following data sources:

  • Box
  • Dropbox
  • Google Analytics
  • Google Big Query
  • Google Drive
  • OData Services
  • OneDrive
  • REST Services
  • SharePoint Online
  • Web Resources

Amazon Web Services

If your data source uses Amazon Web Services (AWS), then you must return an instance of the RVAmazonWebServicesCredentials class. The RVAmazonWebServicesCredentials class provides constructor overloads to define the key, and the secret.

public class AuthenticationProvider: IRVAuthenticationProvider
{
public Task<IRVDataSourceCredential> ResolveCredentialsAsync(IRVUserContext userContext, RVDashboardDataSource dataSource)
{
IRVDataSourceCredential userCredential = null;
if (dataSource is RVS3DataSource)
{
userCredential = new RVAmazonWebServicesCredentials("key", "secret");
}
return Task.FromResult<IRVDataSourceCredential>(userCredential);
}
}

The RVAmazonWebServicesCredentials is supported for the following data sources:

  • Amazon Athena
  • Amazon S3