Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep linking to dynamic url #98

Open
ravibha opened this issue Dec 6, 2019 · 6 comments
Open

Deep linking to dynamic url #98

ravibha opened this issue Dec 6, 2019 · 6 comments

Comments

@ravibha
Copy link

ravibha commented Dec 6, 2019

Hi,
I have setup authentication for my react app with react-adal. However, if a user directly goes to a page other than what's set in reply urls, I get the following message:
AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application.

Is there a way to solve this issue using react-adal? Please note, I cannot add each url of the website to the reply url list, since these can be dynamic. Ex: https://localhost/orders/1, https://localhost/orders/2 etc.

Thanks
-Ravi

@salvoravida
Copy link
Owner

how hve you configured reply url?

@ravibha
Copy link
Author

ravibha commented Dec 6, 2019

The reply url is set in the Azure AD app that we use for authentication. I believe we cannot specify wildcards in the reply urls such as https://localhost/*. And I cannot have https://localhost/orders/1, https://localhost/orders/2 etc. there since these are dynamic.

@Abe-Froman
Copy link

We're having the same issue, let's call it on Application A, using 0.4.24. Another of our applications, Application B, is using 0.4.18 and does not have this issue. I haven't yet tried downgrading App A to 0.4.18 nor have I tried the latest 0.5.0 release. As far as I can tell, App A & B are configured the same in AAD though A is hosted in AKS and B is hosted in an App Service.

I'll try both 0.4.18 and 0.5.0 in App A to see if either resolves the issue but if there is a known issue with 0.4.24 it would be great to get confirmation.

@Abe-Froman
Copy link

Neither downgrading to 0.4.18 nor upgrading to 0.5.0 resolved this issue for me. =(

@Abe-Froman
Copy link

Abe-Froman commented Jan 8, 2020

I've solved it for our case. The solution was to provide a redirectUri value in adalConfig which points to the root of our application. For example:

export const adalConfig: AdalConfig = {
  tenant: <tenant_id>,
  clientId: <client_id>,
  endpoints: {
    api: <client_id>
  },
  cacheLocation: 'localStorage',
  redirectUri: https://<my_app_root> // <-- added this
}

@mazer-rakham
Copy link

mazer-rakham commented Mar 5, 2020

Just a little FYI if you used create-react-app you can write your code as follows

import { AuthenticationContext, adalFetch, withAdalLogin } from "react-adal";

let redirecttionURI;
process.env.NODE_ENV === "production"
  ? (redirecttionURI = "https://your-production-site-here/")
  : process.env.NODE_ENV === "test"
  ? (redirecttionURI = "https://your-staging-site-here/")
  : redirecttionURI = "http://localhost:xxxx/";

export const adalConfig = {
  tenant: "xxxxxxxxxxxxxxxxxxxxxxx",
  clientId: "xxxxxxxxxxxxxxxxxxxx",
  endpoints: {
    api: "https://graph.microsoft.com"
  },
  cacheLocation: "localStorage",
  redirectUri: redirecttionURI
};

export const authContext = new AuthenticationContext(adalConfig);

export const adalApiFetch = (fetch, url, options) =>
  adalFetch(authContext, adalConfig.endpoints.api, fetch, url, options);

export const withAdalLoginApi = withAdalLogin(
  authContext,
  adalConfig.endpoints.api
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants