HomeGuides
Submit Documentation FeedbackJoin Developer CommunityLog In

Security - use cases

This topic describes security cases for external login providers and IssuerUri.

Adding external login providers

B2B Commerce Cloud supports Google and Facebook login out of the box for versions 4.1+. Additional login providers could likely be added by adding the relevant OWIN middleware to the ConfigureIdentityProviders method within Startup.Auth.cs. Additional providers can be found at the following links:

Configuring Google/Facebook logins

These logins are enabled by setting the following Application Settings. Changes to these settings will not take place until after the application pool has been recycled.

Application SettingValue TypeDescription
ExternalProvider_Facebook_AppIdstringThe app id identified by your Facebook application used for Facebook login.
ExternalProvider_Facebook_AppSecretstringThe app secret identified by your Facebook application used for Facebook login.
ExternalProvider_Facebook_Enabledtrue/falseIf true, a Facebook button will appear on the sign in page.
ExternalProvider_Google_ClientIdstringThe client id identified by your Google application used for Google login.
ExternalProvider_Google_ClientSecretstringThe client secret identified by your Google application used for Google login.
ExternalProvider_Google_Enabledtrue/falseIf true, a Google button will appear on the sign in page.

Setting up a Google application to generate a ClientId and ClientSecret

  1. In a browser go to https://console.developers.google.com (log in if you are not logged in already).
  2. Go to API Manager > Credentials.
  3. Click New credentials and select OAuth 2.0 client ID.
  4. Select Web Application.
  5. Name the application (This will be displayed when users are redirected to Google to login. Once they log in, it will prompt the users and say "{application name} would like to access your profile" or something like that).
  6. Set the Authorized JavaScript origins to the website URL.
  7. Set the redirect URLs to the following, replacing the mywebsite part: https://www.mywebsite.com/identity/externalcallback
  8. Click Create.
  9. You should now have the clientid and clientsecret.
  10. Go to the Overview tab.
  11. In the Social APIs section click Google+ Api and enable it.
  12. Enter clientid and clientsecret within the Google External Provider Application Settings.

Setting up a Facebook Application to generate an AppId and AppSecret

  1. In a browser go to https://developers.facebook.com/ (login if you are not logged in already).
  2. Select My Apps in the header and select Add an app.
  3. Select WWW.
  4. Name the application (This will be displayed when users are redirected to Google to login. Once they log in, it will prompt the users and say "{application name} would like to access your profile" or something like that).
  5. Select a category and create the app.
  6. Enter your website and click Next.
  7. Refresh the page.
  8. In the header select My Apps and the app you just created.
  9. Click Settings to see your app id and app secret.
  10. Under Settings set the contact email.
  11. Under the Status and Review section, set your app to be Live.
  12. Then in the same section, enable the email and public_profile items.
  13. Verify on the Dashboard that the API version is 2.5, if it is not, you may need to modify some code in Startup.Auth.cs.

After everything is configured, restart the IIS App Pool to enable the new configuration.

Configuring IssuerUri for IndentityServer on Webfarms

The purpose of the IssuerUri option on the IdentityServer is to create tokens and generate the TokenValidationParameters. On token generation, the values for token audience and the issuer is set from the IssuerUri option. On token validation audienceUri is created from the IssuerUri. It doesn't have to be a valid URI, it can be something unique to your company.

A common implementation mistake is made when setting the IdentityServerUrl. If it is set in the app.config to the IP address of the server, then each server would have a unique issuer uri on the access token. If the request is then redirected to a server where the access token doesn't exist, a token error is generated. To correct this, configure the issuerUri with the same values on each server across the webfarm.

For Insite, the issuerUri is set in the startup.auth.cs file. Update the following line of the startup.auth.cs file to a unique URL:

IssuerUri = ConfigurationManager.AppSettings["IdentityServerUrl"], to IssuerUri = "https://youwebsiteuniqueurl.com"

SecurityOptions.IdentityServerOptions = new IdentityServerOptions
    {
        SiteName = "Insite Commerce - Identity Server",
        IssuerUri = ConfigurationManager.AppSettings["IdentityServerUrl"],                      CspOptions = new CspOptions { Enabled = false },
        SigningCertificate = Certificate.Get(),
        Factory = Factory.Configure(ConnectionStringProvider.Current.ConnectionStringName),
        CorsPolicy = Thinktecture.IdentityServer.Core.Configuration.CorsPolicy.AllowAll,
        AuthenticationOptions = new AuthenticationOptions
        {
            IdentityProviders = ConfigureIdentityProviders
        },
#if DEBUG
        RequireSsl = false,
#endif

Did this page help you?