Authentication provider type (.NET)

Authentication Provider Types are types of authentication flows that the system can be configured to allow users to authenticate. Authentication Provider Types cannot be added or removed from a system, but they can be enabled or disabled.

The IAuthProviderTypeManager interface enables programmatic enabling and disabling of the authentication protocols in use by Relativity. You can also use the Auth Provider Type Manager REST service for cross-platfrom and browser-based applications. See Authentication provider type (REST).

This page contains the following information:

The Relativity.Identity.SDK contains this API. For compatibility and package installation instructions, see Download the SDKs and NuGet packages.

Authentication provider type fundamentals

Before programmatically interacting with authentication provider types, familiarize yourself with the Relativity authentication provider user interface and review the information in the RelativityOne Documentation site.

Use these guidelines when working with authentication providers:

  • Wrap the IAuthProviderTypeManager interface proxy in a using block.
  • An authentication provider type is comprised of a unique, read only name and a boolean that flags whether it is enabled or disabled. Disabled provider types will prevent users from using that type for authentication. Avoid disabling all types or types used to primary log into the Relativity instance. Doing so may lock all users out of the instance.

Methods

Read an authentication provider type

To read a single authentication provider type by name, call the ReadAsync() method of the IAuthProviderTypeManager interface.

  • Task<IEnumerable<AuthProviderType>> ReadAllAsync()

The method returns an AuthProviderType object with the specified name and the following fields:

  • Name (string) - name of the protocol.
  • IsEnabled (boolean) - whether the authentication provider type is enabled (true or false).
  • Type (Protocol Type enum) - protocol type where user enters credentials.
    • Local - a protocol type where the user will enter credentials on the login page.
    • External - a protocol type where the user is authenticated with an external identity provider.
  • Description (string) - description of the protocol.

Read all authentication provider types

To read all available authentication provider types, call the ReadAllAsync() method of the IAuthProviderTypeManager interface.

  • Task<IEnumerable<AuthProviderType>> ReadAllAsync()

Update an authentication provider type

To update a single provider type to be enabled or disabled, use the UpdateAsync() method of the IAuthProviderTypeManager interface:

  • Task UpdateAsync(string name, bool isEnabled)
    Notes:
  • To enable an authentication provider type, call the UpdateAsync() method and pass it the provider name and the true parameter.
  • To disable an authentication provider, call the UpdateAsync() method and pass it the provider name and the false parameter.

Code sample

The following code sample ensures that only Password and OpenIDConnect types are enabled.

using (Relativity.Identity.{versionNumber}.Services.IAuthProviderTypeManager authProviderTypeManager = new ServiceFactory(settings).CreateProxy<IAuthProviderTypeManager>())
{
    IEnumerable<AuthProviderType> providerTypes = await authProviderTypeManager.ReadAllAsync();
 
    foreach(AuthProviderType type in providerTypes)
    {
        if(!(type.Name.Equals("Password") || type.Name.Equals("OpenID Connect")) && type.IsEnabled)
        {
            authProviderTypeManager.UpdateAsync(type.Name, false);
        }
    }
}