AuthConfiguration Class

Contains methods for configuring the settings for users to log in to a community, or a custom domain created using My Domain, with an authentication provider, such as Facebook©.

Namespace

Auth

Example

This example shows how to call some methods on the Auth.AuthConfiguration class. Before you can run this sample, you need to 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 a new instance of the AuthConfiguration class using the specified community or custom domain URL and starting URL for authenticated users.

Signature

public AuthConfiguration(String communityOrCustomUrl, String startUrl)

Parameters

communityOrCustomUrl
Type: String
The URL for the community or custom domain.
startUrl
Type: String
The page users see after successfully logging in to the community or custom domain.

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. Admins configure the setting Allow internal users to log in directly to the community on the Login & Registration page in Community Management. 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 custom domain that was created by using My Domain.

Signature

public AuthConfig getAuthConfig()

Return Value

Type: AuthConfig

The AuthConfig sObject for the community or custom domain.

getAuthConfigProviders()

Returns the list of authentication providers configured for a community or custom domain.

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 custom domain.

Signature

public List<AuthProvider> getAuthProviders()

Return Value

Type: List<AuthProvider>

A list of authentication providers (AuthProvider sObjects) for the community or custom domain.

getAuthProviderSsoUrl(communityUrl, startUrl, developerName)

Returns the single sign-on URL for a community or a custom domain created using My Domain.

Signature

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

Parameters

communityUrl
Type: String
The URL for the community or custom domain. 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 custom domain.
developerName
Type: String
The unique name of the authentication provider.

Return Value

Type: String

The Single Sign-On Initialization URL for the community or custom domain.

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.

getSamlProviders()

Returns the list of SAML-based authentication providers available for a community or custom domain.

Signature

public List<SamlSsoConfig> getSamlProviders()

Return Value

Type: List<SamlSsoConfig>

A list of SAML-based authentication providers (SamlSsoConfig sObjects).

getSamlSsoUrl(communityUrl, startURL, samlId)

Returns the single sign-on URL for a community or a custom domain created using My Domain.

Signature

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

Parameters

communityUrl
Type: String
The URL for the community or custom domain created using My Domain. 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 users see after successfully logging in to the community or custom domain.
samlId
Type: String
The unique identifier of the SamlSsoConfig standard object for the community or custom domain.

Return Value

Type: String

The Single Sign-On Initialization URL for the community or custom domain.

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 page of a community or custom domain displayed after a user logs in.

Signature

public String getStartUrl()

Return Value

Type: String

The location of the community or custom domain start page.

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