Authentication integration - OIDC

Updated at:
Note

This feature is available only in the AI Premium edition. For more information about different editions, see Version Introduction.

What is OIDC?

OIDC (OpenID Connect) is an authentication protocol built on top of OAuth 2.0. It complements OAuth 2.0 by standardizing features that the original specification left undefined. The authorization flows of both protocols are mostly identical, with two main differences:

  1. The OIDC authorization flow returns an additional ID Token.

  2. OIDC provides specifications for concepts that were not fully defined in OAuth 2.0, such as scope, service discovery, and user information fields.

How OIDC-based authentication integration works

To let users sign in to Alibaba Cloud Mail with your enterprise identity provider (IdP), the mail service and your IdP must exchange information by following the OIDC standard protocol.

The OIDC standard protocol supports multiple flows. This guide focuses on the authorization code grant.

Both the Alibaba Cloud Mail service and your enterprise IdP must implement the OIDC standard protocol. In this scenario, Alibaba Cloud Mail acts as the OIDC client, and your IdP acts as the OIDC server.

How to implement OIDC

For detailed information on implementing the OIDC authorization code grant, see the following standard protocol documents:

  1. OpenID Connect Core 1.0

  2. OpenID Connect Discovery 1.0

  3. OpenID Connect Session Management 1.0

  4. JSON Web Key (JWK)

  5. Proof Key for Code Exchange (PKCE)

  6. OAuth 2.0 Authorization Framework

You must strictly follow the instructions in this document for any parts of the protocol that are loosely defined (see "Step 2: Configure the OIDC client in domain management" > "Check the prerequisites on the OIDC Configuration page").

OIDC login flow

image.svg

Available modes

After configuration, you can choose from three modes.

image.png

Mode 1: Hybrid mode

Users can access your custom login address for Alibaba Cloud Mail and click the icon for your OIDC IdP under "More logon options".

When you first configure OIDC, you must use this mode for testing and verification to avoid disrupting user logins.

image.png

Mode 2: OIDC-first mode

When a user accesses the custom login address for your enterprise, they are automatically redirected to your enterprise IdP's login page.

image.png

In this mode, users can still bypass IdP authentication by signing in with their email and password on an official Alibaba Cloud Mail site.

Official Alibaba Cloud Mail sites:

image.png

Mode 3: OIDC-only mode

This mode is an enhanced version of the OIDC-first mode. Enabling it has two main effects:

  1. Users can no longer sign in with their email credentials on an official Alibaba Cloud Mail site. They are prompted to go to the company's designated login page to sign in through the enterprise IdP.

image

  1. Standard protocols (IMAP, POP, and SMTP) no longer support authentication with email credentials.

    1. For regular mailboxes accessed through clients like Outlook or Foxmail, users must create a security password in the webmail interface and use it to sign in.

    2. For system mailboxes that use standard email protocols in code to send automated emails, create a security password in the webmail interface and update the code to use it for authentication.

Important

Enable this mode with caution. Because it affects standard protocols, ensure all mailboxes that rely on them have switched to using a security password before you proceed.

image.png

Procedure

Step 1: Create an OIDC client in your IdP

If your enterprise uses a self-hosted IdP, contact the relevant internal team to create an OIDC client for Alibaba Cloud Mail.

If your enterprise uses a third-party IDaaS product, follow that product's documentation to create an OIDC client.

Key configuration parameters:

  1. Grant types for the token endpoint (grant_type): authorization_code, refresh_token

  2. Response type for the authorization endpoint (response_type): code

  3. Token endpoint authentication method: client_secret_post

  4. ID Token signing algorithm: RS256

  5. Authorization code expiration: Recommended at least 600 seconds

  6. ID Token expiration: Recommended 14 days (1,209,600 seconds)

  7. Access token expiration: Recommended 14 days (1,209,600 seconds)

  8. Refresh token expiration: Recommended 28 days (2,592,000 seconds)

  9. (Recommended) Supported scopes: openid, offline_access, email

  10. (Recommended) Supported claim: email

  11. Redirect URI: See the configuration page, as shown in the following figure.

image

Step 2: Configure the OIDC client in domain management

  1. In Alibaba Cloud Mail domain management, navigate to Integration > Identity Source Management > Authentication Integration, and then click Start Configuration to open the Select Authentication Protocol page.

image

  1. Click the OIDC identity source button to open the OIDC Configuration page.

image

  1. On the OIDC Configuration page, check that you meet the prerequisites.

image

Condition

Description

Required

Add a custom login address

Path: Domain > Login Address > Add Domain

A custom login address is required to correctly route and redirect users to their enterprise OIDC IdP.

Configure CNAME for the custom login address

Path: Domain > Login Address > CNAME Settings

Ensures that your custom login address for Alibaba Cloud Mail functions correctly.

Complete ICP filing for the custom login address

Path: Domain > Login Address > ICP Filing Settings

Ensures that your custom login address for Alibaba Cloud Mail functions correctly.

Recommended

Set the custom login address as the default link

Path: Domain > Login Address > Set as Functional Email Link

In some scenarios, you may need to instruct employees to use the custom enterprise login address.

Add an SSL certificate for the custom login address

Path: Domain > SSL Certificate Management > Upload Certificate

Allows your custom login address to be accessed over HTTPS for enhanced security.

Enforce HTTPS

Path: Domain > SSL Certificate Management > Enforce HTTPS

Improves security by establishing an HTTPS connection by default when accessing the custom login address.

Enforce security passwords for all users / Disallow third-party clients for all users

Path:

1. Security > Account Security > Password Policy > Enforce Security Password / Allow Third-party Clients

2. Security > Account Security > Access Policy > Disable Third-party Client Access Policy

If you want to enable the Only allow login via this identity source option in the OIDC IdP configuration, you must enforce security passwords to ensure standard protocols (SMTP, IMAP, and POP) continue to function.

Strongly recommended: Most account security issues stem from standard protocols. Enforcing security passwords or disabling third-party clients can eliminate these security risks and prevent account compromise or financial loss.

Note: After you enforce security passwords, email credentials will no longer work for standard protocol authentication. Users must create a security password to use with standard protocols. Plan your rollout carefully to minimize disruption, especially for system mailbox accounts.

  1. On the OIDC Configuration page, fill in the required fields.

Note: During the initial setup and testing phase, keep the Set as default login method option disabled to prevent service disruption for your employees.

Parameter

Description

Basic configuration

Display Name

This name is displayed on the button on the user login page.

Application Logo

This icon is displayed on the login page as the entry point for OIDC login.

client ID

The client ID provided by your enterprise OIDC IdP.

client secret

The client secret provided by your enterprise OIDC IdP.

issuer URL

The issuer URL provided by your enterprise OIDC IdP.

Redirect URI

You must add all of these URIs to the allowed redirect URIs in your enterprise OIDC IdP's configuration.

Login configuration

Enable identity source

You must enable this switch to test or use this identity source for login.

When enabled, an OIDC login button that uses this identity source is added to the login page.

Set as default login method

When enabled, accessing your enterprise's custom login address for Alibaba Cloud Mail automatically redirects to your enterprise IdP's login page.

Important: Before you enable this option, ensure that you can successfully sign in using this identity source. Otherwise, your employees will be unable to access their mailboxes.

Only allow login via this identity source

We recommend that new enterprises enable this option. Existing enterprises with many active mailboxes should enable it with caution.

When enabled, employees can only authenticate through this identity source. They cannot use other methods, such as their email credentials. For example:

  1. Users cannot sign in with their email credentials on the official Alibaba Cloud Mail website.

  2. Standard protocols and third-party clients (such as Outlook and Foxmail) cannot authenticate with email credentials. You must enable the security password feature, and users must use a generated security password for authentication.

Important: Ensure you have enforced security passwords for all users (go to Security > Account Security > Password Policy > Enforce Security Password). Otherwise, standard protocols and third-party clients (such as Outlook and Foxmail) will not work.

  1. After you complete the configuration, click Save.

  2. If the configuration fails to save, check whether your issuer URL meets the requirements.

image.png

Note: For "Recommended" conditions, your enterprise OIDC IdP must implement the specified capabilities for the authentication flow to succeed, even if the issuer URL response does not list them.

Condition

Description

Required

Must provide authorization_endpoint

The OIDC authorization endpoint, which is the login page URL of your enterprise OIDC IdP.

Must provide token_endpoint

The OIDC token endpoint, used to exchange an authorization code for a token or a refresh token for a new access token.

Must provide jwks_uri

The OIDC token endpoint returns an ID Token (in JWT format). The keys to parse the JWT are retrieved from the jwks_uri.

Recommended

Provide introspection_endpoint

Used to parse access token information, determine if the access token is valid, and get the current user's email. You only need to implement either the introspection_endpoint or the userinfo_endpoint.

Provide userinfo_endpoint

Used to exchange an access token for user information to get the current user's email. You only need to implement either the introspection_endpoint or the userinfo_endpoint.

Provide end_session_endpoint

Used for browser-based logouts. Ensures that when a user signs out of Alibaba Cloud Mail, they are also signed out of their enterprise account.

grant_types_supported must include authorization_code and refresh_token

The grant_type parameter of the OIDC token endpoint request must support authorization_code and refresh_token values.

response_types_supported must include code

The response_type parameter of the OIDC authorization endpoint request must support the code value for the authorization code grant.

claims_supported must include the email claim

The ID Token (in JWT format) returned by the OIDC token endpoint must include the email claim.

scopes_supported must include openid, email, and offline_access

The scope parameter of the OIDC authorization endpoint request must support openid, email, and offline_access values.

id_token_signing_alg_values_supported must include RS256

The signing algorithm for the ID Token (in JWT format) returned by the OIDC token endpoint must support RS256.

token_endpoint_auth_methods_supported must include client_secret_post

The OIDC token endpoint must support client authentication by passing the client_id and client_secret parameters in the POST request body.

introspection_endpoint_auth_methods_supported must include client_secret_post

The OIDC introspection endpoint must support client authentication by passing the client_id and client_secret parameters in the POST request body.

If PKCE is supported, code_challenge_methods_supported must include S256

If your enterprise OIDC IdP supports PKCE, the code_challenge encoding method must support S256.

A typical response from an issuer URL should include at least the following information:

{
    "authorization_endpoint": "https://mail.example.com/oidc/auth",
    "token_endpoint": "https://mail.example.com/oidc/token",
    "jwks_uri": "https://mail.example.com/oidc/.well-known/jwks.json",
    "claims_supported": [
        "email"
    ],
    "code_challenge_methods_supported": [
        "S256"
    ],
    "end_session_endpoint": "https://mail.example.com/oidc/session/end",
    "grant_types_supported": [
        "authorization_code",
        "refresh_token"
    ],
    "response_types_supported": [
        "code"
    ],
    "scopes_supported": [
        "openid",
        "offline_access",
        "email"
    ],
    "token_endpoint_auth_methods_supported": [
        "client_secret_post"
    ],
    "userinfo_endpoint": "https://mail.example.com/oidc/me",
    "introspection_endpoint": "https://mail.example.com/oidc/token/introspection",
    "introspection_endpoint_auth_methods_supported": [
        "client_secret_post"
    ],
    "id_token_signing_alg_values_supported": [
        "RS256"
    ]
}
  1. After you complete the configuration, click Save.

Step 3: Verify the integration

After you save the configuration, a confirmation message appears. Verify that you can successfully sign in to Alibaba Cloud Mail through your enterprise OIDC IdP.

Browser: Copy the address and open it in an incognito or private window. Click the OIDC icon to be redirected to your enterprise IdP to sign in.

image

image.png