<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>53010</bug_id>
          
          <creation_ts>2025-02-09 23:22:45 +0300</creation_ts>
          <short_desc>Не работает OpenID аутентификация с Authentik</short_desc>
          <delta_ts>2025-02-09 23:40:08 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>pve-manager</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrey Limachko">liannnix</reporter>
          <assigned_to name="Alexey Shabalin">shaba</assigned_to>
          <cc>andy</cc>
    
    <cc>darisishe</cc>
    
    <cc>shaba</cc>
    
    <cc>shrek</cc>
    
    <cc>tyaplyapych</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>258934</commentid>
    <comment_count>0</comment_count>
    <who name="Andrey Limachko">liannnix</who>
    <bug_when>2025-02-09 23:22:45 +0300</bug_when>
    <thetext>Сервер с PVE:
libproxmox-rs-perl-0.3.4-alt3.x86_64
libpve-rs-perl-0.9.1-alt3.x86_64
pve-manager-8.3.1-alt1.x86_64

Контейнер с Authentik:
Развернуты оригинальные docker контейнеры через docker-compose.
Версия: 2024.12.3

Настраивал по инструкции: https://docs.goauthentik.io/integrations/services/proxmox-ve/

При попытке аутентификации в Web GUI пишет:
OpenID login failed, please try again
authentication failure (401)

journalctl при этом говорит:
pvedaemon[855370]: openid authentication failure; rhost=::ffff:10.0.9.1 msg=Failed to contact token endpoint: Failed to parse server response

Небольшой дебаг показал следующее:
Аутентификация обрабатывается в файле /usr/share/perl5/PVE/API2/OpenId.pm . Там кусок кода, обёрнутый в eval начиная с 162 строки.
Проюлемы начинаются со строки
my $info = $openid-&gt;verify_authorization_code($param-&gt;{code}, $private_auth_state);

$openid получается так:
my $openid = PVE::RS::OpenId-&gt;discover($openid_config, $redirect_url);

Это приводит нас к очередному модулю на Rust, чтоб его...
https://git.proxmox.com/?p=proxmox.git;a=blob;f=proxmox-openid/src/lib.rs;h=fe65fded5fd01ea2bcf4463f03de31870040c02a;hb=HEAD
На строке 194 начинается функция verify_authorization_code, на которой и обрывается процесс. Видим там такой код:

// Exchange the code with a token.
let token_response = self
    .client
    .exchange_code(code)
    .set_pkce_verifier(private_auth_state.pkce_verifier())
    .request(http_client)
    .map_err(|err| format_err!(&quot;Failed to contact token endpoint: {}&quot;, err))?; 

Где-то здесь оно и падает. Толи не может адекватно распарсить полученный ответ, толи что-то с HTTP клиентом. format_err намекает, что json-нина ему не нравится, но вот что именно в ней не так - не понятно.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258935</commentid>
    <comment_count>1</comment_count>
    <who name="Andrew Vasilyev">andy</who>
    <bug_when>2025-02-09 23:30:38 +0300</bug_when>
    <thetext>(Ответ для Andrey Limachko на комментарий #0)
&gt; Сервер с PVE:
&gt; pve-manager-8.3.1-alt1.x86_64

  А если обновить до pve-manager-8.3.1-alt2 ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>258936</commentid>
    <comment_count>2</comment_count>
    <who name="Andrey Limachko">liannnix</who>
    <bug_when>2025-02-09 23:39:45 +0300</bug_when>
    <thetext>Отбой тревоги. Все работает.

Я в настройках Authentik добавил лишнюю опцию. В настройках провайдера есть две опции: Signing Key и Encryption Key. Так вот, Rust модуль зашифрованный токен не понимает, да и не очень понятно, чем его нужно расшифровывать. В общем, оставляем поле пустым и все заработает.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>