Saturday, 26 January 2019

Azure PHP App Service redirects on login action

Trying to learn more about other languages and Cloud, I downloaded An open source application written in PHP to run it on Azure: FoOlSlide2. It is also known that it runs without problem on XAMPP or WAMPP.

I was able to set up all App environment, create and connect a MySql database and run the app and play its method to install and configure the database without problems.

But every time when I try to login with valid credentials, it is not able to login me, just redirects me to the login page again. But when I try to input invalid credentials, there is not http redirect and also I receive feedback about the invalid attempt.

Doing some searches like here, it makes me think if could be a rewrite configuration error, since had to convert a .htaccess into a web.config file. Although, I did it using own IIS URL Rewrite to generate my rules and also tried online tools to make this conversion for me, but none of those worked.

I tried also to find some option inside Azure Portal - App Services, that could be troubleshooting a login action, without success. Php version is compatible with the project (5.6), and the App connects successfully with the database since its setup requires it and created all tables needed.

Bellow, all relevant info that I think could be used to discover the issue, and also I can provide more if necessary.

Login Attempt Scenery w/ Invalid Credentials (working as expected):

Request URL: https://xxxxxxxxxxxxx/account/auth/login/
Request Method: POST
Status Code: 200 OK
[...] Error response inside 

Login Attempt Scenery w/ Valid Credentials (Not working as expected):

Request URL: https://xxxxxxxxxxxxx/account/auth/login/
Request Method: POST
Status Code: 302 Moved Temporarily
[Header] Location: https://xxxxxxxxxxxxx/account/profile/

Request URL: https://xxxxxxxxxxxxx/account/profile/
Request Method: POST
Status Code: 302 Moved Temporarily
[Header] Location: https://xxxxxxxxxxxxx/account/auth/login/

Request URL: https://xxxxxxxxxxxxx/account/auth/login/
Request Method: GET
Status Code: 200 OK
[Here I am back to login form even inputted valid credentials]

My whole web.config (rules generated using IIS URL Rewriter):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions>
            <add input="{R:1}" pattern="^(index\.php|assets|content|robots\.txt|favicon\.ico)" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="./index.php?{R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>  
    <httpProtocol>
  <customHeaders>
    <remove name="ETag"/>
    <add name="Access-Control-Allow-Origin" value="*"/>
    <add name="X-UA-Compatible" value="IE=Edge,chrome=1"/>
    <remove name="X-Powered-By"/>
    <add name="Cache-Control" value="max-age=691200" />
  </customHeaders>
</httpProtocol>
<defaultDocument>
  <files>
    <clear />
    <add value="index.php" />
  </files>
</defaultDocument>
</system.webServer>
</configuration>

.htacess file from GitHub (who I used to generate my web.config rules)

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|content|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

** Updating with more info: **

I also tried to deploy another App Service in Azure, again in PHP, called MangaReader and also open source and that works fine in WAMPP / XAMPP. I am also having similar issues regarding login attempts - not redirect itself, but a successful status code without auth.

As before, I generated the web.config file using IIS URL Rewriter based on .htaccess file; and also was able to configure all database and ran the site setup. After that, my small doubt about to be a project error has gone.

It looks so to be:

  • A error while converting .htaccess file into web.config;
  • Some missing configuration inside Azure Portal App Service;
  • Some missing configuration on IIS;
  • Any unknown error.


from Azure PHP App Service redirects on login action

No comments:

Post a Comment