The post has been translated automatically. Original language: Russian
An employee opens their work page and reads: "Session expired". The login and password are correct, and signing in again is useless: the session is alive, the employee simply has no rights to treasury.
That is how our portal on top of a copy of 1C:Holding Management behaved. For an accountant it is one more call to support. For an AI chat that reads 1C under the employee's login it is already a wrong answer: instead of "this is not shown to you" the person hears "sign in again".
Where it broke
The portal read 1C through OData, the platform's standard web interface. For the list of payment requests the server returned HTTP 401. The portal took the code literally: the sign-in was not accepted, so the session had ended.
We made a second request, with a deliberately wrong password. The same 401 came back. The codes matched, the response bodies did not.
| What happened | Code | What is in the response body |
| Wrong password | 401 | HTML page from the web server |
| Correct password, no rights | 401 | OData error with code 20, «Доступ запрещен» (Access denied) |
In the first case the person was not let in. In the second they were let in, but 1C refused the data.
What we changed
The portal now reads the response body. If a 401 carries an OData error, the portal treats it as an access denial, 403. If it carries HTML, it is still a sign-in problem. The "session expired" message remains only where the session has really expired. The fix is covered by automated tests.
These are two cases on one publication. Your web server may answer differently, so check your own.
What this has to do with an AI chat
I am now building a service that connects an AI chat to 1C. The main question there is the same: through whose eyes the chat looks at the database. I did not invent a second system of rights: the employee signs in with their own 1C login, and the chat sees what 1C shows that employee. If 1C does not show salaries, the chat will not see them either. How it works.
An inconvenient thing follows from this: a refusal from 1C becomes an ordinary answer, and you have to be able to read it. An empty list, an access denial and a wrong password mean different things to a person.
A half-hour check
Take a copy of the database and an employee for whom one type of document is closed. Ask the same question four times:
- As an employee who can open the documents. Write down what they see in ordinary 1C: this is the reference.
- As an employee who cannot open them. A refusal should come back.
- With a wrong password. A request to sign in should come back.
- As an employee with rights, but with a filter that matches no documents. An empty list should come back.
If the second, third and fourth answers sound the same, your contractor has something to fix before acceptance. Save the code and body of each response: they show who refused, the web server or 1C.
The decision about access still belongs to whoever sets up the rights in 1C. The chat only retells it, and it must retell it accurately.
What does your integration answer when an employee has no rights?
Сотрудник открывает свою рабочую страницу и читает: «Сеанс истёк». Логин и пароль верные, входить заново бесполезно: сеанс жив, просто у сотрудника нет прав на казначейство.
Так вёл себя наш портал поверх копии «1С:Управление холдингом». Для бухгалтера это лишний звонок в поддержку. Для ИИ-чата, который читает 1С под логином сотрудника, это уже неверный ответ: вместо «вам это не показывают» человек услышит «войдите ещё раз».
Где сломалось
Портал читал 1С через OData, стандартный веб-интерфейс платформы. На список заявок сервер вернул HTTP 401. Портал понял код буквально: вход не принят, значит, сеанс кончился.
Мы сделали второй запрос, с заведомо неверным паролем. Пришёл тот же 401. Коды совпали, а тела ответов нет.
| Что произошло | Код | Что в теле ответа |
| Пароль неверный | 401 | HTML-страница веб-сервера |
| Пароль верный, прав нет | 401 | Ошибка OData с кодом 20, «Доступ запрещен» |
В первом случае человека не впустили. Во втором впустили, но 1С отказала в данных.
Что изменили
Портал стал читать тело ответа. Если при 401 внутри лежит ошибка OData, он считает это отказом в правах, 403. Если HTML, это по-прежнему вход. Сообщение об истёкшем сеансе осталось только там, где сеанс действительно истёк. Исправление закрыли автоматическими тестами.
Это два случая на одной публикации. У вас веб-сервер может отвечать иначе, поэтому проверьте свой.
При чём тут ИИ-чат
Сейчас я делаю сервис, который подключает ИИ-чат к 1С. Главный вопрос там тот же: чьими глазами чат смотрит в базу. Второй системы прав я придумывать не стал: сотрудник входит под своим логином 1С, и чат видит то, что 1С показывает этому сотруднику. Не показывает зарплаты, значит, их не увидит и чат. Как это устроено.
Из этого следует неудобная вещь: отказ 1С становится обычным ответом, и его надо уметь прочитать. Пустой список, отказ в правах и неверный пароль для человека означают разное.
Проверка на полчаса
Возьмите копию базы и сотрудника, которому закрыт один вид документов. Задайте один и тот же вопрос четыре раза:
- Под сотрудником, которому документы открыты. Запишите, что он видит в обычной 1С: это эталон.
- Под сотрудником, которому они закрыты. Должен прийти отказ.
- С неверным паролем. Должна прийти просьба войти.
- Под сотрудником с правами, но с отбором, по которому документов нет. Должен прийти пустой список.
Если второй, третий и четвёртый ответы звучат одинаково, подрядчику есть что исправить до приёмки. Сохраните код и тело каждого ответа: по ним видно, кто отказал, веб-сервер или 1С.
Решение о доступе при этом остаётся у того, кто настраивает права в 1С. Чат его только пересказывает, и пересказать должен точно.
А что отвечает ваша интеграция, когда у сотрудника нет прав?
Comments 0
Newest Popular