Strip URLs from querystring in web.config
up vote
0
down vote
favorite
I am using Google to authenticate users through OAuth2. The site is built in Angular 5 and hosted in an Azure App Service (IIS). When google authenticates the user, it sends back an URL which contains some URIs:
https://domain.azurewebsites.net/membership/oauth2?code=<authentication code>&scope=openid%20email%20https://www.googleapis.com/auth/plus.me%20https://www.googleapis.com/auth/userinfo.email
.
As you can see, after the &scope
, there are 2 URIs. azure websites returns an error indicating that
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
If I strip the query string from &scope
onwards, it works fine.
I have tried to strip that part in web.config with a rewrite rule:
<rule name="Remove paging parameters" stopProcessing="true">
<match url="^(.*)/membership/oauth2(.*)$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="^(.*)(scope=.+)(.*)$" />
</conditions>
<action type="Redirect" url="{C:1}{C:3}" appendQueryString="false" />
</rule>
However, nothing happens. Any help will be greatly appreciated.
Side Note: everything works fine in localhost, as it is nodejs that serves the Angular site. The problem arouses in the Azure App Service, as it is served by IIS.
angular

add a comment |
up vote
0
down vote
favorite
I am using Google to authenticate users through OAuth2. The site is built in Angular 5 and hosted in an Azure App Service (IIS). When google authenticates the user, it sends back an URL which contains some URIs:
https://domain.azurewebsites.net/membership/oauth2?code=<authentication code>&scope=openid%20email%20https://www.googleapis.com/auth/plus.me%20https://www.googleapis.com/auth/userinfo.email
.
As you can see, after the &scope
, there are 2 URIs. azure websites returns an error indicating that
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
If I strip the query string from &scope
onwards, it works fine.
I have tried to strip that part in web.config with a rewrite rule:
<rule name="Remove paging parameters" stopProcessing="true">
<match url="^(.*)/membership/oauth2(.*)$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="^(.*)(scope=.+)(.*)$" />
</conditions>
<action type="Redirect" url="{C:1}{C:3}" appendQueryString="false" />
</rule>
However, nothing happens. Any help will be greatly appreciated.
Side Note: everything works fine in localhost, as it is nodejs that serves the Angular site. The problem arouses in the Azure App Service, as it is served by IIS.
angular

add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using Google to authenticate users through OAuth2. The site is built in Angular 5 and hosted in an Azure App Service (IIS). When google authenticates the user, it sends back an URL which contains some URIs:
https://domain.azurewebsites.net/membership/oauth2?code=<authentication code>&scope=openid%20email%20https://www.googleapis.com/auth/plus.me%20https://www.googleapis.com/auth/userinfo.email
.
As you can see, after the &scope
, there are 2 URIs. azure websites returns an error indicating that
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
If I strip the query string from &scope
onwards, it works fine.
I have tried to strip that part in web.config with a rewrite rule:
<rule name="Remove paging parameters" stopProcessing="true">
<match url="^(.*)/membership/oauth2(.*)$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="^(.*)(scope=.+)(.*)$" />
</conditions>
<action type="Redirect" url="{C:1}{C:3}" appendQueryString="false" />
</rule>
However, nothing happens. Any help will be greatly appreciated.
Side Note: everything works fine in localhost, as it is nodejs that serves the Angular site. The problem arouses in the Azure App Service, as it is served by IIS.
angular

I am using Google to authenticate users through OAuth2. The site is built in Angular 5 and hosted in an Azure App Service (IIS). When google authenticates the user, it sends back an URL which contains some URIs:
https://domain.azurewebsites.net/membership/oauth2?code=<authentication code>&scope=openid%20email%20https://www.googleapis.com/auth/plus.me%20https://www.googleapis.com/auth/userinfo.email
.
As you can see, after the &scope
, there are 2 URIs. azure websites returns an error indicating that
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
If I strip the query string from &scope
onwards, it works fine.
I have tried to strip that part in web.config with a rewrite rule:
<rule name="Remove paging parameters" stopProcessing="true">
<match url="^(.*)/membership/oauth2(.*)$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="^(.*)(scope=.+)(.*)$" />
</conditions>
<action type="Redirect" url="{C:1}{C:3}" appendQueryString="false" />
</rule>
However, nothing happens. Any help will be greatly appreciated.
Side Note: everything works fine in localhost, as it is nodejs that serves the Angular site. The problem arouses in the Azure App Service, as it is served by IIS.
angular

angular

edited Nov 5 at 11:38
Uwe Keim
27.2k30126209
27.2k30126209
asked Nov 5 at 2:05
aplon
178215
178215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
For anyone facing the same issue in the future, I solved this following this answer by @kamranicus. The correct rewrite url showed in that post is as follows:
<rule name="Google Login - Remove scope parameter" stopProcessing="true">
<match url="google/redirect/url(.*)?$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="(.*)(&?scope=.+&?)(.*)" />
</conditions>
<action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
</rule>
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
For anyone facing the same issue in the future, I solved this following this answer by @kamranicus. The correct rewrite url showed in that post is as follows:
<rule name="Google Login - Remove scope parameter" stopProcessing="true">
<match url="google/redirect/url(.*)?$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="(.*)(&?scope=.+&?)(.*)" />
</conditions>
<action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
</rule>
add a comment |
up vote
0
down vote
For anyone facing the same issue in the future, I solved this following this answer by @kamranicus. The correct rewrite url showed in that post is as follows:
<rule name="Google Login - Remove scope parameter" stopProcessing="true">
<match url="google/redirect/url(.*)?$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="(.*)(&?scope=.+&?)(.*)" />
</conditions>
<action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
</rule>
add a comment |
up vote
0
down vote
up vote
0
down vote
For anyone facing the same issue in the future, I solved this following this answer by @kamranicus. The correct rewrite url showed in that post is as follows:
<rule name="Google Login - Remove scope parameter" stopProcessing="true">
<match url="google/redirect/url(.*)?$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="(.*)(&?scope=.+&?)(.*)" />
</conditions>
<action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
</rule>
For anyone facing the same issue in the future, I solved this following this answer by @kamranicus. The correct rewrite url showed in that post is as follows:
<rule name="Google Login - Remove scope parameter" stopProcessing="true">
<match url="google/redirect/url(.*)?$" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="(.*)(&?scope=.+&?)(.*)" />
</conditions>
<action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
</rule>
answered Nov 5 at 11:34
aplon
178215
178215
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147402%2fstrip-urls-from-querystring-in-web-config%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password