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

Allow to rename api.php #2132

Merged
merged 6 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ git add -A && git commit

[More Information](http://openmage.github.io/magento-lts/install.html)

## Secure your installation

Do not use /admin (or /nimda...) for backend url. Do not add it into your _robots.txt_, keep it secret. You can change it from your backend (System / Configuration / Admin / Admin Base Url) or from your _app/etc/local.xml_:

```xml
<config>
<admin>
<routers>
<adminhtml>
<args>
<frontName><![CDATA[admin]]></frontName>
</args>
</adminhtml>
</routers>
</admin>
</config>
```

Do not use /api.php (or /ipa.php...) for OpenMage API url. Do not add it into your _robots.txt_, keep it secret with your partners. You can rename the file as you want. Don't forgot to also update server configuration:
* htaccess: `RewriteRule ^api/rest api.php?type=rest [QSA,L]`
* nginx: `rewrite ^/api/(\w+).*$ /api.php?type=$1 last;`

## Changes

Most important changes will be listed here, all other changes since `19.4.0` can be found in
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function getServiceUrl($routePath = null, $routeParams = null, $htmlSpeci
$uri = Zend_Uri_Http::fromString($url);
$uri->setHost($request->getHttpHost());
if (!$urlModel->getRouteFrontName()) {
$uri->setPath('/' . trim($request->getBasePath() . '/api.php', '/'));
$uri->setPath('/' . trim($request->getBasePath() . '/' . basename(getenv('SCRIPT_FILENAME')), '/'));
} else {
$uri->setPath($request->getBaseUrl() . $request->getPathInfo());
}
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Api2/Model/Route/ApiType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Mage_Api2_Model_Route_ApiType extends Mage_Api2_Model_Route_Abstract imple
{
/**
* API url template with API type variable
* @deprecated
*/
const API_ROUTE = 'api/:api_type';

Expand All @@ -56,6 +57,6 @@ public function __construct(
Zend_Translate $translator = null,
$locale = null
) {
parent::__construct(array(Mage_Api2_Model_Route_Abstract::PARAM_ROUTE => self::API_ROUTE));
parent::__construct(array(Mage_Api2_Model_Route_Abstract::PARAM_ROUTE => str_replace('.php', '', basename(getenv('SCRIPT_FILENAME'))) . '/:api_type'));
}
}