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.










share|improve this question




























    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.










    share|improve this question


























      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.










      share|improve this question















      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 azure web-config azure-web-app-service






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 5 at 11:38









      Uwe Keim

      27.2k30126209




      27.2k30126209










      asked Nov 5 at 2:05









      aplon

      178215




      178215
























          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="(.*)(&amp;?scope=.+&amp;?)(.*)" />
          </conditions>
          <action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
          </rule>





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            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
































            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="(.*)(&amp;?scope=.+&amp;?)(.*)" />
            </conditions>
            <action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
            </rule>





            share|improve this answer

























              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="(.*)(&amp;?scope=.+&amp;?)(.*)" />
              </conditions>
              <action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
              </rule>





              share|improve this answer























                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="(.*)(&amp;?scope=.+&amp;?)(.*)" />
                </conditions>
                <action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
                </rule>





                share|improve this answer












                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="(.*)(&amp;?scope=.+&amp;?)(.*)" />
                </conditions>
                <action type="Rewrite" url="google/redirect/url?{C:1}{C:3}" appendQueryString="false" />
                </rule>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 5 at 11:34









                aplon

                178215




                178215






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    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




















































































                    這個網誌中的熱門文章

                    Tangent Lines Diagram Along Smooth Curve

                    Yusuf al-Mu'taman ibn Hud

                    Zucchini