AuthConfiguration Class

Contains methods for configuring settings for users to log in to a Salesforce org using their authentication provider credentials instead of their Salesforce credentials. The authentication provider can be any authentication provider that supports the OpenID Connect protocol, such as Google, Facebook, or Twitter. Users log in to either a community subdomain of the force.com domain (https://subdomain.force.com) or a Salesforce subdomain created with My Domain (https://subdomain.my.salesforce.com).

Namespace

Auth

Example

This example shows how to call some methods on the Auth.AuthConfiguration class. Before you can run this sample, you must provide valid values for the URLs and developer name.

String communityUrl = '<Add URL>';
String startUrl = '<Add URL>';
Auth.AuthConfiguration authConfig = new Auth.AuthConfiguration(communityUrl,startUrl);
List<AuthProvider> authPrvs = authConfig.getAuthProviders();
String bColor = authConfig.getBackgroundColor();
String fText = authConfig.getFooterText();

String sso = Auth.AuthConfiguration.getAuthProviderSsoUrl(communityUrl, startUrl, 'developerName');

AuthConfiguration Constructors

The following are constructors for AuthConfiguration.

AuthConfiguration(communityOrCustomUrl, startUrl)

Creates an instance of the AuthConfiguration class using the specified URL for a community or a My Domain subdomain and the start URL for authenticated users.

Signature

public AuthConfiguration(String communityOrCustomUrl, String startUrl)

Parameters

communityOrCustomUrl
Type: String
The URL for the domain, which can be a Salesforce subdomain created with My Domain (my.salesforce.com) or a subdomain of a community (force.com).
startUrl
Type: String
The page users see after successfully logging in to the community or My Domain subdomain.

AuthConfiguration(networkId, startUrl)

Creates an instance of the AuthConfiguration class using the specified community ID and authenticated-user starting URL.

Signature

public AuthConfiguration(Id networkId, String startUrl)

Parameters

networkId
Type: Id
The ID of the community.
startUrl
Type: String
The page users see after successfully logging in to the community.

AuthConfiguration Methods

The following are methods for AuthConfiguration. Use these methods to manage and customize authentication for a Salesforce community.

  • getAllowInternalUserLoginEnabled()
    Indicates whether the community allows internal users to log in using the community login page. To enable, admins configure the setting Allow internal users to log in directly to the community on the Login & Registration page in Community Workspaces. It’s disabled by default.
  • getAuthConfig()
    Returns the AuthConfig sObject, which represents the authentication options for a community or Salesforce My Domain subdomain.
  • getAuthConfigProviders()
    Returns the list of authentication providers configured for a community or Salesforce My Domain subdomain.
  • getAuthProviders()
    Returns the list of authentication providers available for a community or Salesforce My Domain subdomain.
  • getAuthProviderSsoUrl(communityUrl, startUrl, developerName)
    Returns the single sign-on URL for a community or Salesforce My Domain subdomain.
  • getBackgroundColor()
    Returns the color for the background of the login page for a community.
  • getDefaultProfileForRegistration()
    Returns the profile ID assigned to new community users.
  • getFooterText()
    Returns the text at the bottom of the login page for a community.
  • getForgotPasswordUrl()
    Returns the URL for the standard or custom Forgot Password page that is specified for a community or portal by the administrator.
  • getLogoUrl()
    Returns the location of the icon image at the bottom of the login page for a community.
  • getRightFrameUrl()
    Returns the URL for the right-frame content to display on the right side of the community login page. The admin supplies the URL.
  • getSamlProviders()
    Returns the list of SAML-based authentication providers available for a community or Salesforce My Domain subdomain.
  • getSamlSsoUrl(communityUrl, startURL, samlId)
    Returns the single sign-on URL for a community or Salesforce My Domain subdomain.
  • getSelfRegistrationEnabled()
    Indicates whether the current community allows new users to create their own account by filling out a registration form.
  • getSelfRegistrationUrl()
    Returns the location of the self-registration page for new users to sign up for an account with a community.
  • getStartUrl()
    Returns the start page of a community or Salesforce My Domain subdomain. This URL is the first page that users see when they log in.
  • getUsernamePasswordEnabled()
    Indicates whether the current community is set to display a login form asking for a username and password. You can configure the community not to request a username and password if it is for unauthenticated users or users logging in with a third-party authentication provider.
  • isCommunityUsingSiteAsContainer()
    Returns true if the community uses Site.com pages; otherwise, returns false.

getAllowInternalUserLoginEnabled()

Indicates whether the community allows internal users to log in using the community login page. To enable, admins configure the setting Allow internal users to log in directly to the community on the Login & Registration page in Community Workspaces. It’s disabled by default.

Signature

public Boolean getAllowInternalUserLoginEnabled()

Return Value

Type: Boolean

Usage

If true, internal users log in to a community from the community login page with their internal credentials. If they navigate to their internal org from the community, they don't have to log in again.

getAuthConfig()

Returns the AuthConfig sObject, which represents the authentication options for a community or Salesforce My Domain subdomain.

Signature

public AuthConfig getAuthConfig()

Return Value

Type: AuthConfig

The AuthConfig sObject for the community or Salesforce My Domain subdomain.

getAuthConfigProviders()

Returns the list of authentication providers configured for a community or Salesforce My Domain subdomain.

Signature

public List<AuthConfigProviders> getAuthConfigProviders()

Return Value

Type: List<AuthConfigProviders>

A list of authentication providers (AuthConfigProviders sObjects), which are children of the AuthProvider sObject.

getAuthProviders()

Returns the list of authentication providers available for a community or Salesforce My Domain subdomain.

Signature

public List<AuthProvider> getAuthProviders()

Return Value

Type: List<AuthProvider>

A list of authentication providers (AuthProvider sObjects) for the community or My Domain subdomain.

getAuthProviderSsoUrl(communityUrl, startUrl, developerName)

Returns the single sign-on URL for a community or Salesforce My Domain subdomain.

Signature

public static String getAuthProviderSsoUrl(String communityUrl, String startUrl, String developerName)

Parameters

communityUrl
Type: String
The URL for the community or My Domain subdomain. If not null and not specified as an empty string, you get the URL for a community. If null or specified as an empty string, you get the URL for a custom domain.
startUrl
Type: String
The page that users see after logging in to the community or My Domain subdomain.
developerName
Type: String
The unique name of the authentication provider.

Return Value

Type: String

The Single Sign-On Initialization URL for the community or Salesforce My Domain subdomain.

getBackgroundColor()

Returns the color for the background of the login page for a community.

Signature

public String getBackgroundColor()

Return Value

Type: String

getDefaultProfileForRegistration()

Returns the profile ID assigned to new community users.

Signature

public String getDefaultProfileForRegistration()

Return Value

Type: String

The profile ID.

getFooterText()

Returns the text at the bottom of the login page for a community.

Signature

public String getFooterText()

Return Value

Type: String

The text string displayed at the bottom of the login page, for example “Log in with an existing account.”

getForgotPasswordUrl()

Returns the URL for the standard or custom Forgot Password page that is specified for a community or portal by the administrator.

Signature

public String getForgotPasswordUrl()

Return Value

Type: String

URL for the standard or custom Forgot Password page.

getLogoUrl()

Returns the location of the icon image at the bottom of the login page for a community.

Signature

public String getLogoUrl()

Return Value

Type: String

The path to the icon image.

getRightFrameUrl()

Returns the URL for the right-frame content to display on the right side of the community login page. The admin supplies the URL.

Signature

public String getLoginRightFrameUrl()

Return Value

Type: String

URL for the right-frame content of the community login page. Salesforce creates an inline (IFrame) on the right side of the login page to display the contents specified by the URL.

getSamlProviders()

Returns the list of SAML-based authentication providers available for a community or Salesforce My Domain subdomain.

Signature

public List<SamlSsoConfig> getSamlProviders()

Return Value

Type: List<SamlSsoConfig>

A list of SAML-based authentication providers, which are SamlSsoConfig sObjects.

getSamlSsoUrl(communityUrl, startURL, samlId)

Returns the single sign-on URL for a community or Salesforce My Domain subdomain.

Signature

public static String getSamlSsoUrl(String communityUrl, String startURL, String samlId)

Parameters

communityUrl
Type: String
The URL for the community or My Domain subdomain. If not null and not specified as an empty string, you get the URL for a community. If null or specified as an empty string, you get the URL for a My Domain subdomain.
startUrl
Type: String
The page users see after successfully logging in to the community or My Domain subdomain
samlId
Type: String
The unique identifier of the SamlSsoConfig standard object for the community or My Domain subdomain

Return Value

Type: String

The Single Sign-On Initialization URL for the community or Salesforce My Domain subdomain.

getSelfRegistrationEnabled()

Indicates whether the current community allows new users to create their own account by filling out a registration form.

Signature

public Boolean getSelfRegistrationEnabled()

Return Value

Type: Boolean

getSelfRegistrationUrl()

Returns the location of the self-registration page for new users to sign up for an account with a community.

Signature

public String getSelfRegistrationUrl()

Return Value

Type: String

The location of the self-registration page.

getStartUrl()

Returns the start page of a community or Salesforce My Domain subdomain. This URL is the first page that users see when they log in.

Signature

public String getStartUrl()

Return Value

Type: String

The location of the start page for the community or My Domain subdomain.

getUsernamePasswordEnabled()

Indicates whether the current community is set to display a login form asking for a username and password. You can configure the community not to request a username and password if it is for unauthenticated users or users logging in with a third-party authentication provider.

Signature

public Boolean getUsernamePasswordEnabled()

Return Value

Type: Boolean

isCommunityUsingSiteAsContainer()

Returns true if the community uses Site.com pages; otherwise, returns false.

Signature

public Boolean isCommunityUsingSiteAsContainer()

Return Value

Type: Boolean