All Products
Search
Document Center

Alibaba Cloud Service Mesh:Configure OIDC-based single sign-on on an ingress gateway

Last Updated:Mar 11, 2026

When multiple applications share a Service Mesh (ASM) ingress gateway, each application typically implements its own authentication logic -- duplicating effort and increasing security risk. OpenID Connect (OIDC), an identity layer built on OAuth 2.0, enables single sign-on (SSO) at the gateway level: users log in once, and the gateway forwards a verified JSON Web Token (JWT) to every backend application without any code changes.

How it works

  1. A user sends a request to the ingress gateway.

  2. The gateway checks for a valid session cookie. If none exists, it redirects the user to the identity provider (IdP) login page.

  3. After authentication, the IdP redirects the user back to the gateway callback URL (/oauth2/callback) with an authorization code.

  4. The gateway exchanges the code for tokens, sets a session cookie, and forwards the request to the backend with a JWT in the Authorization header.

  5. The backend reads user identity from the JWT payload -- no direct call to the IdP is needed.

Prerequisites

Before you begin, make sure that you have:

After the IdP is configured, collect the following values for the OIDC configuration:

redirect URI:   http://<ingress-gateway-ip>/oauth2/callback
issuer URL:     https://eiam-api-cn-hangzhou.aliyuncs.com/v2/<idaas-instance-id>/app_<app-id>/oidc
client ID:      <your-client-id>
client secret:  <your-client-secret>
Important

The redirect URI must exactly match the callback URL registered with your IdP. A mismatch causes authentication failures because the IdP rejects the callback request.

Note

The following procedure uses Alibaba Cloud IDentity as a Service (IDaaS) as the IdP. If you use a self-managed OIDC IdP such as Keycloak, see Integrate Keycloak with ASM to implement single sign-on.

Configure OIDC settings

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the target ASM instance. In the left-side navigation pane, choose ASM Gateways > Ingress Gateway.

  3. On the Ingress Gateway page, click the target ingress gateway. In the left-side navigation pane, choose Gateway Security > OIDC Single Sign-On.

  4. In the OIDC Config step, turn on Enable gateway OIDC Single Sign-On and configure the following parameters.

    Note

    To discover available endpoints and supported scopes, query your IdP's well-known configuration endpoint:

    curl <your-issuer-url>/.well-known/openid-configuration | jq
    ParameterDescription
    Redirect addressThe protocol and address for OIDC callbacks. In this example, select Use ingressgateway IP address and http.
    Callback AddressThe full URL to which the IdP redirects users after authentication.
    OIDC Issuer URLThe URL used to identify and authenticate the OIDC issuer. The gateway derives the discovery endpoint from this URL to fetch the IdP's public keys and endpoints.
    Client IDThe client ID assigned by the IdP when you registered the application.
    Client SecretThe client secret assigned by the IdP.
    Cookie SecretA seed string for secure session cookies, which can be Base64-encoded.
    Cookie ExpireHow long the session cookie remains valid. Set to 0 for cookies that do not expire.
    Cookie refresh intervalHow often the session cookie is refreshed. Set to 0 to disable automatic refresh.
    ScopesThe OIDC scopes to request from the IdP (for example, openid, email, profile). The IdP must support the specified scopes.

    OIDC configuration

  5. Click Next.

Configure path matching rules

  1. In the Matching Rule step, configure which request paths require OIDC authentication. In this example, select Auth If Matched and set the path to /productpage. Requests to /productpage are redirected to the IdP for authentication, while requests to other paths pass through without OIDC checks.

    ParameterDescription
    Match ModeControls how the path rule is applied. Valid values: Auth If Matched -- requests to the specified path require authentication. Bypass Auth If Matched -- requests to the specified path skip authentication.
    Add Match RuleTurn on the Path switch and specify the path. In this example, set the path to /productpage.
  2. Click Submit. The Complete step confirms that OIDC-based SSO is configured. The page displays the native Istio security resources generated by the wizard. Click YAML to review the resource configurations.

Verify the configuration

  1. Open a browser and go to http://<ingress-gateway-ip>/productpage. Replace <ingress-gateway-ip> with the IP address of your ingress gateway. If the configuration is correct, the browser redirects to the IdP login page. After you authenticate, the browser redirects back and displays the application page.

    OIDC verification

Set up logout

A complete SSO logout requires two actions: clearing the gateway session cookie and terminating the IdP session.

ActionHow to trigger
Clear the gateway session cookieVisit http://<ingress-gateway-ip>/oauth2/sign_out. The gateway clears the session cookie automatically.
End the IdP sessionVisit the logout URI exposed by your IdP.

Single-step logout (ASM v1.18.147 and later)

ASM v1.18.147 and later lets you combine both actions by configuring an IdP logout endpoint on the OIDC configuration page:

  1. Enter the IdP logout endpoint URL on the OIDC configuration page.

  2. Add a matching rule that sets the /oauth2/sign_out path to Bypass Auth If Matched so the sign-out path does not require authentication.

After this setup, visiting /oauth2/sign_out clears the session cookie and redirects to the IdP logout endpoint in a single step. For more information about IDaaS single logout, see SLO.

FAQ

Does my application need to handle OIDC authentication?

No. The ingress gateway handles the entire OIDC flow. Your application receives each request with an Authorization header containing a JWT issued by the IdP. The gateway has already validated this token, so your application can parse it directly to extract user information such as sub, email, or custom claims -- no additional call to the IdP is needed.

What is the session cookie used for?

The gateway uses the session cookie to track the authentication state of each user. Your application can safely ignore this cookie. To access user identity, read the JWT from the Authorization header instead.

How do I get extended user attributes from the IdP?

No additional ASM configuration is needed. Extended attributes depend on your IdP implementation. For Alibaba Cloud IDaaS, see Rules for OIDC id_token Extended Fields.

References