Skip to content

Log in to Google using the Identity Server

This page guides you through using WSO2 Identity Server to log in to Google.

Before you begin!

You need to have a Google domain. Click here for more information on creating the domain.


Configure Google

  1. Access your domain's admin console via https://admin.google.com.

  2. Click Security.

    Info

    Can't see the Security section? Click the MORE CONTROLS bar at the bottom and you can see the Security section.

    more-controls

  3. Click Set up single sign-on (SSO) with a third party IdP.

    third-party-idp

  4. Enter the following URLs to your third-party Identity Provider (IdP).

    • Sign-in page URL: https://<IS_HOSTNAME>:<IS_PORT>/samlsso

    • Sign-out page URL: https://<IS_HOSTNAME>:<IS_POST>/samlsso

    sso-fill-google.png

  5. Upload the Identity Server certificate:
    The certificate file must contain the public key for Google to verify the sign-in requests.

    1. Navigate to the <IS_HOME>/repository/resources/security directory via the terminal.
    2. Run the command given below to import the public certificate from the keystore to a .pem file.

      keytool -export -alias wso2carbon  -keystore wso2carbon.jks -storepass wso2carbon -file mycert.pem

      Info

      The mycert.pem file is created in the same directory mentioned in step a above. If you want to change the name of the file that is being generated, enter a preferred name instead of mycert in the above command.

    3. Click Replace certificate and upload the .pem file you just generated.

    4. Click Save.


Configure Email Address as the Username

Warning

Configuring the email address as the username in an already running Identity Server is not the production recommended way. Therefore, make sure to configure it before you begin working with WSO2 IS.

  1. Log in to the Management Console and click Claims > List > http://wso2.org/claims.

  2. Click the Edit link corresponding to the Username claim and configure the Mapped Attribute property to mail.

    email-as-username-attribute-mapping

  3. Click Update to save the changes.

  4. Open the <IS_HOME>/repository/conf/deployment.toml file.

  5. Add the following configuration to enable email authentication.

    [tenant_mgt]
    enable_email_domain= true
  6. Configure the following set of parameters in the userstore configuration, depending on the type of userstore you are connected to (LDAP/Active Directory/ JDBC).

    Parameter Description

    UserNameAttribute


    Set the mail attribute of the user. LDAP/Active Directory only

    [user_store]
    user_name_attribute = "mail"
    UserNameSearchFilter

    Use the mail attribute of the user instead of cn or uid . LDAP/Active Directory only
    For example:

     In LDAP,[user_store]
    user_name_search_filter = "(&amp;(objectClass=person)(mail=?))"

    In Active Directory, [user_store]
    user_name_search_filter = "(&amp;(objectClass=user)(mail=?))"
    UserNameListFilter

    Use the mail attribute of the user if necessary. LDAP/Active Directory only
    For example:

     In LDAP,[user_store]
    user_name_list_filter = "(&amp;(objectClass=person)(!(sn=Service)))"

    In Active Directory, [user_store]
    user_name_list_filter = "(&amp;(objectClass=user)(!(sn=Service)))"
    UsernameJavaScriptRegEx

    Change this property that is under the relevant userstore manager tag as follows. This property allows you to add special characters like "@" in the username.

    [user_store]
    username_java_script_regex = '^[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$'
    UsernameJavaRegEx

    This is a regular expression to validate usernames. By default, strings have a length of 5 to 30. Only non-empty characters are allowed. You can provide ranges of alphabets, numbers and also ranges of ASCII values in the RegEx properties.

    [user_store]
    username_java_regex = '^[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'
    Realm configurations

    The username must use the email attribute of the admin user.

    [super_admin]
    username = "[email protected]"
    password = "admin"

    Note

    Before this configuration, the user having the username admin and password admin was considered the super administrator. The super administrator user cannot be deleted.

    After this configuration, the user having the username [email protected] is considered the super administrator. The user having the username admin is considered as a normal administrator.

    Info

    • With these configuration users can log in to super tenant with both email username ([email protected]) or non-email usernames (larry). However, for tenants, only email usernames are allowed. ([email protected]@wso2.com).
    • You can configure email username without enabling the enable_email_domain property (step 5). Then users can log in to both the super tenant and the tenant using email and non-email usernames. However, super tenant users should always use @carbon.super at the end of usernames.
  7. Restart the server.


Create the service provider

To register your application as a service provider in the WSO2 Identity Server:

  1. Log in to the WSO2 Identity Server Management Console using administrator credentials.

  2. Go to Main > Identity > Service Providers > Add.

  3. Enter a Service Provider Name. Optionally, enter a Description.

  4. Click Register.


SAML Configurations

Make the following changes to the created service provider.

  1. Expand Inbound Authentication Configuration > SAML Configuration and click Configure.

  2. Fill in the value for Issuer and Assertion consumer URL as shown below.

    Field Value Description
    Issuer

    google.com

    This is the <saml:Issuer> element that contains the unique identifier of the service provider.
    Assertion Consumer URL
    https://www.google.com/a/<ENTER_YOUR_DOMAIN>/acs
    This is the URL to which the browser should be redirected to after the authentication is successful. This is the Assertion Consumer Service (ACS) URL of the service provider. The identity provider redirects the SAML2 response to this ACS URL. However, if the SAML2 request is signed and SAML2 request contains the ACS URL, the Identity Server will honor the ACS URL of the SAML2 request.

  3. Select Enable Response Signing to sign the SAML2 Responses returned after the authentication process.

  4. Select Enable Attribute Profile and Include Attributes in the Response Always so that the the identity provider will always include the attribute values related to the selected claims in the SAML2 attribute statement.

  5. Click Register.


Try it out

Now, you have successfully configured Google and WSO2 Identity Server.

Note

The admin users of your Google domain do not get redirected to WSO2 IS. Therefore, to try out the tutorial you need to use a user who is not an admin in your Google account.

  1. Create a user in WSO2 Identity Server. Make sure that the same user exists in your Google domain.
    In this example, [email protected] is in the Google domain. Therefore, we need to create the same user in WSO2 Identity Server.

    1. Log in to the WSO2 Identity Server Management Console (https://<IS_HOST>:<PORT>/carbon) using administrator credentials (admin:admin).
  2. Navigate to Main > Identity > Users and Roles > Add.

  3. Click Add New User and enter username and password.  When adding a new user, use an email address as the username. Since it is not mandatory to assign a role to a user in this tutorial, click Finish.

  4. Navigate to https://google.com/a/<ENTER_YOUR_DOMAIN>/acs and enter the email address (username) of the user you created.
    You are navigated to WSO2 Identity Server's sign in screen.

  5. Enter the username and password of the user you created.
    You are navigated to the G-Suite of that domain and you can select the application you need to use.

Tip

If you want to only access Gmail, navigate to mail.google.com, enter the username of the user, enter the username and password of the user on the WSO2 Identity Server sign in screen, and you are navigated to the user's mail account.

Top