Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit c8fc700

Browse files
authored
Merge pull request #15 from diberry/diberry/0630-env-var
Move from hard-coded strings to react supported environment variables.
2 parents af658af + 4171418 commit c8fc700

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

4-Deployment/2-deploy-static/App/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
REACT_APP_AAD_APP_CLIENT_ID=
2+
REACT_APP_AAD_APP_TENANT_ID=
3+
REACT_APP_AAD_APP_REDIRECT_URI=
4+
REACT_APP_AAD_APP_FUNCTION_SCOPE_URI=

4-Deployment/2-deploy-static/App/src/authConfig.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { LogLevel } from "@azure/msal-browser";
1212
*/
1313
export const msalConfig = {
1414
auth: {
15-
clientId: "Enter_the_Application_Id_Here", // This is the ONLY mandatory field that you need to supply.
16-
authority: "https://login.microsoftonline.com/Enter_the_Tenant_Info_Here", // Defaults to "https://login.microsoftonline.com/common"
17-
redirectUri: "/", // You must register this URI on Azure Portal/App Registration. Defaults to window.location.origin
18-
postLogoutRedirectUri: "/", // Indicates the page to navigate after logout.
15+
clientId: `${process.env["REACT_APP_AAD_APP_CLIENT_ID"]}`, // This is the ONLY mandatory field that you need to supply.
16+
authority: `https://login.microsoftonline.com/${process.env["REACT_APP_AAD_APP_TENANT_ID"]}`, // Defaults to "https://login.microsoftonline.com/common"
17+
redirectUri: `${process.env["REACT_APP_AAD_APP_REDIRECT_URI"]}`, // You must register this URI on Azure Portal/App Registration. Defaults to window.location.origin
18+
postLogoutRedirectUri: `${process.env["REACT_APP_AAD_APP_REDIRECT_URI"]}`, // Indicates the page to navigate after logout.
1919
navigateToLoginRequestUrl: false, // If "true", will navigate back to the original request location before processing the auth code response.
2020
},
2121
cache: {
@@ -68,6 +68,6 @@ export const protectedResources = {
6868
},
6969
functionApi: {
7070
endpoint: "/api/hello",
71-
scopes: ["Enter_the_Web_Api_Scope_Here"], // e.g. api://xxxxxx/access_as_user
71+
scopes: [`${process.env["REACT_APP_AAD_APP_FUNCTION_SCOPE_URI"]}/access_as_user`], // e.g. api://xxxxxx/access_as_user
7272
}
7373
}

4-Deployment/2-deploy-static/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ Open the project in your IDE (like Visual Studio or Visual Studio Code) to confi
9393

9494
> In the steps below, "ClientID" is the same as "Application ID" or "AppId".
9595
96-
1. Open the `App/src/authConfig.js` file.
97-
1. Find the key `Enter_the_Application_Id_Here` and replace the existing value with the application ID (clientId) of `msal-react-spa` app copied from the Azure portal.
98-
1. Find the key `Enter_the_Tenant_Info_Here` and replace the existing value with your Azure AD tenant ID.
99-
1. Find the key `Enter_the_Web_Api_Scope_Here` and replace the existing value with APP ID URI that you've registered earlier, e.g. `api://****-****-********-********/access_as_user`
96+
1. Open the `App/src/.env` file.
97+
1. Find the `REACT_APP_AAD_APP_CLIENT_ID` environment variable and add the application ID (clientId) of `msal-react-spa` app copied from the Azure portal.
98+
1. Find the `REACT_APP_AAD_APP_TENANT_ID` environment variable and add your Azure AD tenant ID.
99+
1. Find the `REACT_APP_AAD_APP_REDIRECT_URI` environment variable and add the APP ID URI that you've registered earlier, e.g. `api://****-****-********-********/`
100100

101101
## Deployment
102102

0 commit comments

Comments
 (0)