Soru

Zorluk: OrtaApp Registrations and Service Principals

You are developing a client-side React single-page application (SPA) that will run in users' web browsers. The application must authenticate users against Microsoft Entra ID and access a secure downstream web API. You need to configure the authentication and identity settings for the React application. Which configuration should you implement in Microsoft Entra ID?

  1. Register the application in Microsoft Entra ID, configure a redirect URI with the Single-page application (SPA) platform type, and use the authorization code flow with PKCE.Cevap
  2. B
    Configure a system-assigned managed identity for the React application to authenticate the user session and retrieve tokens from the browser.
  3. C
    Register the application as a Web platform client type, configure a client secret, and use the client credentials flow to authenticate users.
  4. D
    Generate a Shared Access Signature (SAS) token in Azure Storage and embed it in the React application configuration to authenticate users.

Cevap

Register the application in Microsoft Entra ID, configure a redirect URI with the Single-page application (SPA) platform type, and use the authorization code flow with PKCE.
The correct option is to register the application in Microsoft Entra ID with the platform type set to Single-page application (SPA) and use the authorization code flow with PKCE. Because the React app runs in the user's browser, it is a public client and cannot secure a client secret. PKCE eliminates the need for a client secret while protecting the flow against authorization code interception attacks. Furthermore, registering as an SPA enables the necessary CORS support on Entra ID token endpoints.

Adım Adım Çözüm

1
Analyze the client application architecture.
The application is a client-side React Single-Page Application (SPA) running entirely in the user's web browser.
Understanding the execution environment is crucial to determine if the client is public (cannot protect secrets) or confidential (can protect secrets).
2
Determine the appropriate authentication flow.
The Authorization Code Flow with Proof Key for Code Exchange (PKCE) is the standard and secure flow for client-side applications.
PKCE protects the authorization code from interception without requiring a client secret.
3
Configure the platform type in Microsoft Entra ID App Registration.
Register the Redirect URI under the Single-page application (SPA) platform type.
The SPA platform type ensures Microsoft Entra ID issues tokens using the authorization code flow with PKCE and supports the required Cross-Origin Resource Sharing (CORS) headers.

Anahtar Kavram

Selecting the correct platform registration and authentication flow in Microsoft Entra ID for public client applications.
Bu soruyu puanla