Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i Authorization 1C on the site PHP_AUTH_USER on CentOS apache / ~#root -i
  • RU
  • UA
  • EN
  • Create an online store
  • Documentation
  • Blog
    • Unix ОS
    • Php
    • MySQL
    • JavaScript
    • Package Managers
    • Docker
    • Seo
  • Auxiliary services
    • Short Links
    • Exchange views YouTube
  • Sign in
  • Create Account
  • Home
  • Php
  • Authorization 1C on the site PHP_AUTH_USER on CentOS apache

Authorization 1C on the site PHP_AUTH_USER on CentOS apache

When synchronizing 1s with the site, to upload any information, you should resort to authorization. In order not to throw various unnecessary garbage on the site (at best).

So, after reading the literature, I realized that 1c exchanges headers with the site and prescribes PHP_AUTH_USER and PHP_AUTH_PW to it. But in my case, it was not possible to catch them in $_SERVER (maybe I didn’t set some settings in 1s).

Initially, it was planned to catch data after authorization like this :

<?php
$dbSeq = ['user' => 'test', 'pass' => 'test'];
$this->login = isset($_SERVER['PHP_AUTH_USER']) ? trim($_SERVER['PHP_AUTH_USER']) : null;
$this->password = isset($_SERVER['PHP_AUTH_PW']) ? trim($_SERVER['PHP_AUTH_PW']) : null;

if ($this->password == $dbSeq['pass'] && $this->login == $dbSeq['user']) {
return true;
}

But 1s did not give anything or the server could not accept this data (could not find the reason).

1с авторизация

My solution was to redirect HTTP:Authorization . I have used mod_rewrite on apache .

There must be a line in .htaccess :

RewriteEngine on

which enables the conversion mechanism in mod_rewrite.

In .htaccess, after all the rules, the RewriteRule was added :

RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]

REMOTE_USER - indicates that {HTTP:Authorization} will be written to $_SERVER['REDIRECT_REMOTE_USER'] .

The data arrived in base64.

var_dump($_SERVER['REDIRECT_REMOTE_USER']);

["REDIRECT_REMOTE_USER"]=>
string(18) "Basic dGVzdDp0ZXN0"

I did a little trick with them :

<?php
$dbSeq = ['user' => 'test', 'pass' => 'test'];

if ($_SERVER["REDIRECT_REMOTE_USER"]) {
    $info = base64_decode(end(explode(' ',$_SERVER["REDIRECT_REMOTE_USER"])));
    $info = explode(':', $info);
    $this->login = $info[0]; // Test login arrived
    $this->password = $info[1]; // Test password arrived
}

if ($this->password == $dbSeq['pass'] && $this->login == $dbSeq[ 'user']) {
    return true;
}

14 June 18
885
0

Comments

Name
E-mail
Rating
Review

Other articles from the category

25 April 2022

Create and download CSV in PHP

Consider the possibility of quickly creating a CSV file with automatic file download. Consider the formation, separators and header for the ability to download the file.

19 June 2019

ImageCMS Templates 4.10-4.12.1

Latest templates from ImageCMS 4.12, authorization is required to download.

26 January 2019

Long-term storage of the basket in the online store

Consider options for popular options for storing goods in a shopping cart in an online store. Let's outline the pros and cons of such storage. Consider options for long-term storage of the basket.

17 January 2019

License key for ImageCMS 4.9-4.12.1 Pro and Pre

Creating a key for imageCMS 4.9-4.12.1 Pro and Pre. You must be logged in to receive it.

07 December 2018

$_SERVER[DOCUMENT_ROOT] in CLI or Cron

When running the script from the console, there is no DOCUMENT_ROOT in $_SERVER. Let's try to get around this in our own ways, catch the file directory.

31 October 2018

Analysis of loaded parts of Php code with xhprof

After developing any tool in PHP, the question becomes how resourceful the created code is and what elements it still affects. Let's take a look at xhprof installation, configuration, and how to work with xhprof.

18 July 2018

Grouping conditions in an ORM Propel query (condition, combine)

Let's analyze the possibility of combining conditions in a query by groups in Propel. Consider an example of filtering by fields using ->condition() and ->combine().

21 May 2018

Joining an undeclared table in Propel or Join Custom Table Propel

The purpose of the article was to join (join) a table not declared in the schema (schema.xml) in propel2. Apparently a rare case or simply not enough documentation for this Propel ORM.

Categories

  • Unix OS
  • Php
  • MySQL
  • JavaScript
  • Package Managers
  • Docker
  • Seo

Latest comments

Добрый день, Сергей. Я на более новых версиях блют...
root-i
23.02.23
Пробовал на transmart колонке. Ничего из перечисле...
Сергей
20.02.23
HenryMit, может быть
root-i
07.02.23
Неофрейдизм — это… Определение, принципы, представ...
HenryMit
07.02.23

I share information in which I needed help and spent a lot of time figuring it out. If the information helped at least one person, then this site was not created in vain.

Thank you for the continuation of the site:
Contacts

Telegram Viber Mail

Search for articles

  • Sign in
  • Create Account

Powered by chmod -R