Bug #71788
Problème de déconnexion lors de connexions à certain SP en SAML2
0%
Description
Chez un client, nous rencontrons un souci de déconnexion en cours de connexion à certains SP SAML2 (avec trois fournisseurs de services SAS différents) :
- avec un navigateur déjà connecté sur Authentic, nous déclenchons une authentification depuis un des SP problématiques
- l'utilisateur est bien redirigé vers l'IDP avec une requête d'authentification SAML qui a priori semble correcte et correspondre aux metadatas connus par l'IDP pour ce SP (cf. fichiers joints)
- dans les logs Authentic, on retrouve ce qui suit (je précise que j'ai modifié le logger.debug('processAuthnRequestMsg not successful') en un logger.exception pour plus de détails) :
Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG processing sso request 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c2FtbDJwOkF1dGhuUmVxdWVzdCBBc3NlcnRpb25Db25zdW1lclNlcnZpY2VVUkw9Imh0dHBzOi8vYXV0aC5waWdtZW50LmFwcC9zc28vc2FtbDIvMG9hNXBjcm8za1BKVWNRRlc0MTciIERlc3RpbmF0aW9uPSJodHRwczovL2Nvbm5leGlvbi1wcmVwcm9kLmVuZXJjb29wLm9yZy9pZHAvc2FtbDIvc3NvIiBGb3JjZUF1dGhuPSJmYWxzZSIgSUQ9ImlkODcwOTQ0OTk4ODc5NTIyODE4MTI3Nzg3MjAiIElzc3VlSW5zdGFudD0iMjAyMi0xMS0yOFQxNDozODo0OC42ODdaIiBWZXJzaW9uPSIyLjAiIHhtbG5zOnNhbWwycD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOnByb3RvY29sIj48c2FtbDI6SXNzdWVyIHhtbG5zOnNhbWwyPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXNzZXJ0aW9uIj5odHRwczovL3d3dy5va3RhLmNvbS9zYW1sMi9zZXJ2aWNlLXByb3ZpZGVyL3NwemRzbHRiZW1xb2NqcnB3dHd6PC9zYW1sMjpJc3N1ZXI+PG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lNpZ25hdHVyZT48c2FtbDJwOk5hbWVJRFBvbGljeSBGb3JtYXQ9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpuYW1laWQtZm9ybWF0OnRyYW5zaWVudCIvPjwvc2FtbDJwOkF1dGhuUmVxdWVzdD4=' Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1455) lasso_node_impl_init_from_xml <AuthnRequest> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1424) Matching node Issuer vs snippet Issuer: SUCCESS namespace URIs match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:2475) Processing node 'Issuer' with type 'LassoSaml2NameID' Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1455) lasso_node_impl_init_from_xml <Issuer> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1865) lasso_node_impl_init_from_xml </Issuer> rc=0 Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1424) Matching node Signature vs snippet Signature: SUCCESS namespace URIs match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet Extensions: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet PrivateKeyFile: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet CertificateFile: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet Subject: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1419) Matching node NameIDPolicy vs snippet NameIDPolicy: SUCCESS namespace prefixes match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:2475) Processing node 'NameIDPolicy' with type '(null)' Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:2475) Processing node 'NameIDPolicy' with type 'LassoSamlp2NameIDPolicy' Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1455) lasso_node_impl_init_from_xml <NameIDPolicy> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1865) lasso_node_impl_init_from_xml </NameIDPolicy> rc=0 Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1865) lasso_node_impl_init_from_xml </AuthnRequest> rc=0 Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 ERROR processAuthnRequestMsg not successful#012Traceback (most recent call last):#012 File "/usr/lib/python3/dist-packages/authentic2/idp/saml/saml2_endpoints.py", line 533, in sso#012 login.processAuthnRequestMsg(force_str(message))#012 File "/usr/lib/python3/dist-packages/lasso.py", line 2284, in processAuthnRequestMsg#012 Error.raise_on_rc(rc)#012 File "/usr/lib/python3/dist-packages/lasso.py", line 62, in raise_on_rc#012 raise exception#012lasso.ServerProviderNotFoundError: <lasso.ServerProviderNotFoundError(-201): The identifier of a provider is unknown to #LassoServer. To register a provider in a #LassoServer object, you must use the methods lasso_server_add_provider() or lasso_server_add_provider_from_buffer().> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG {'issuer': 'https://www.okta.com/saml2/service-provider/spzdsltbemqocjrpwtwz', 'forceAuthn': False, 'isPassive': False, 'protocolBinding': None, 'nameIdPolicy': {'allowCreate': False, 'format': 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient', 'spNameQualifier': None}} Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG loading provider https://www.okta.com/saml2/service-provider/spzdsltbemqocjrpwtwz Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG loaded provider https://www.okta.com/saml2/service-provider/spzdsltbemqocjrpwtwz Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG provider https://www.okta.com/saml2/service-provider/spzdsltbemqocjrpwtwz loaded with success Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1455) lasso_node_impl_init_from_xml <AuthnRequest> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1424) Matching node Issuer vs snippet Issuer: SUCCESS namespace URIs match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:2475) Processing node 'Issuer' with type 'LassoSaml2NameID' Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1455) lasso_node_impl_init_from_xml <Issuer> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1865) lasso_node_impl_init_from_xml </Issuer> rc=0 Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1424) Matching node Signature vs snippet Signature: SUCCESS namespace URIs match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet Extensions: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet PrivateKeyFile: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet CertificateFile: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1414) Matching node NameIDPolicy vs snippet Subject: FAILURE names don't match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1419) Matching node NameIDPolicy vs snippet NameIDPolicy: SUCCESS namespace prefixes match Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:2475) Processing node 'NameIDPolicy' with type '(null)' Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:2475) Processing node 'NameIDPolicy' with type 'LassoSamlp2NameIDPolicy' Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1455) lasso_node_impl_init_from_xml <NameIDPolicy> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1865) lasso_node_impl_init_from_xml </NameIDPolicy> rc=0 Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG 2022-11-28 15:38:48 (xml.c/:1865) lasso_node_impl_init_from_xml </AuthnRequest> rc=0 Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG nameID policy is <samlp:NameIDPolicy xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" AllowCreate="false"/> Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG nameID format transient Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG default nameID format none Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG nameID format accepted ['none', 'transient', 'email', 'uuid'] Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG NameIDFormat is transient Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG nonce is id87094499887952281812778720 Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG login required Nov 28 15:38:48 gavotte-pp authentic2[2542317]: 176.159.32.89 - r:7F0F21895F70 DEBUG redirect to login page with next url /idp/saml2/continue?nonce=id87094499887952281812778720
- Suite à cela, l'utilisateur se retrouve sur le formulaire de connexion et il est déconnecté du point de vue d'Authentic (confirmable en ouvrant Authentic dans un autre onglet).
- Si l'utilisateur se connecte en saisissant ses identifiants, il sera alors bien connecté et redirigé vers le SP qui accepte l'authentification alors sans souci.
L'erreur retournée par Lasso est donc :
lasso.ServerProviderNotFoundError(-201): The identifier of a provider is unknown to #LassoServer. To register a provider in a #LassoServer object, you must use the methods lasso_server_add_provider() or lasso_server_add_provider_from_buffer().
Mon problème ici est double :
- je ne comprends pas ce qui ne plaît pas au premier abord dans la requête d'Authentification
- l'utilisateur se retrouve déconnecté et forcé de se connecter à nouveau (même si l'authentification fonctionne ensuite)
Je précise que j'avais rencontré le problème avec la version 4.43-1~eob110+1 et qu'après une mise à jour en 4.49-1~eob110+1, j'ai toujours le problème. Côté lasso, je suis sur la version 2.8.0.1.g7aa6-1~eob110+1 du paquet liblasso3 et c'est la dernière disponible actuellement.
Fichiers
Demandes liées
Historique
Mis à jour par Benjamin Dauvergne il y a plus d'un an
- Assigné à mis à Benjamin Renard
C'est normal ça n'est pas une erreur (d'ailleurs le log est en debug dans le code, à raison), on traite une première fois la requête sans rien charger, ça lève une erreur, on lit le nom du SP, on le charge et on retraite.
Il y a deux raisons pour lancer une authentification, soit on est connecté est le flag forceAuthn est posé (ce n'est pas le cas ici), soit on n'est plus connecté.
Ici il semblerait donc que le cookie de session soit perdu ou invisible au moment du traitement de la requête vraisemblablement pour une histoire de politique SameOrigin, peux-tu vérifier que le cookie de session est bien en SameOrigin=None ? (et que dans le debugger du navigateur il est bien envoyé lors du traitement de l'AuthnRequest).
Mis à jour par Benjamin Renard il y a plus d'un an
Benjamin Dauvergne a écrit :
Ici il semblerait donc que le cookie de session soit perdu ou invisible au moment du traitement de la requête vraisemblablement pour une histoire de politique SameOrigin, peux-tu vérifier que le cookie de session est bien en SameOrigin=None ? (et que dans le debugger du navigateur il est bien envoyé lors du traitement de l'AuthnRequest).
Le cookie est en SameSite=Lax :
Set-Cookie: sessionid=f2nz1j2ijy7uid84dn7srav6obc6jnu6; HttpOnly; Path=/; SameSite=Lax
Et effectivement, lors de la requête SSO, le cookie n'est pas envoyé.
Comment contrôler les paramètres du cookie de session d'Authentic ? C'est possible ou c'est hard-codé ? Par ailleurs, il faudra faire attention à ajouter Secure si on passe en SameSite=none (cf. https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Set-Cookie/SameSite#samesitenone_requiert_secure).
Mis à jour par Benjamin Dauvergne il y a plus d'un an
Dans le cadre de Publik on pose toujours SESSION_COOKIE_SECURE=True et on a un middleware qui corrige le SameSite à None dans tous les cas, comme on utilise plus le paquet standalone, il y a certainement un souci ici.
À partir de Django 3.1 on peut poser directement SESSION_COOKIE_SAMESITE = 'None'
sans ça il faudra l'équivalent de notre middleware (https://git.entrouvert.org/hobo.git/tree/hobo/middleware/cookies_samesite.py).
Mis à jour par Benjamin Dauvergne il y a plus d'un an
PS: ça doit être une AuthnRequest passé en binding POST parce qu'en Lax normalement le cookie est posé sur un redirect.
Mis à jour par Benjamin Renard il y a plus d'un an
Benjamin Dauvergne a écrit :
Dans le cadre de Publik on pose toujours SESSION_COOKIE_SECURE=True et on a un middleware qui corrige le SameSite à None dans tous les cas, comme on utilise plus le paquet standalone, il y a certainement un souci ici.
À partir de Django 3.1 on peut poser directement
SESSION_COOKIE_SAMESITE = 'None'
sans ça il faudra l'équivalent de notre middleware (https://git.entrouvert.org/hobo.git/tree/hobo/middleware/cookies_samesite.py).
Ok pour SESSION_COOKIE_SECURE. Pour SESSION_COOKIE_SAMESITE, on est sous Buster et donc Django 2.2.28 qui interdit la valeur None. J'ai donc tenté le coup du middleware : Je tombe cependant sur un OS, car le cookie de session n'est pas détecté par mon middleware alors que le cookie CSRF l'est bien. Il y aurait-il une particularité pour l'activation de ce middleware afin qu'il soit inséré au bon moment dans la chaîne de traitement ? Je n'ai pas trouvé d'exemple d'activation avec le votre. Personnellement, j'ai simplement ajouté un fichier /etc/authentic2/settings.d/99-authentic2-cookiefix-middleware.py qui contient :
MIDDLEWARE += ('authentic2_cookiefix_middleware.fix_cookies',)
Benjamin Dauvergne a écrit :
PS: ça doit être une AuthnRequest passé en binding POST parce qu'en Lax normalement le cookie est posé sur un redirect.
Effectivement, on est en POST avec ces SPs.
Mis à jour par Benjamin Dauvergne il y a plus d'un an
Il faut poser ton middleware au début de la liste, avant le SessionMiddleware qui pose le cookie dans la réponse. MIDDLEWARE = ('...',) + MIDDLEWARE
Mis à jour par Benjamin Renard il y a plus d'un an
Benjamin Dauvergne a écrit :
Il faut poser ton middleware au début de la liste, avant le SessionMiddleware qui pose le cookie dans la réponse.
MIDDLEWARE = ('...',) + MIDDLEWARE
Top, ça fonctionne, merci !
Mis à jour par Benjamin Dauvergne il y a plus d'un an
- Lié à Development #71880: Poser une configuration minimale correcte pour les cookies CSRF et de session ajouté
Mis à jour par Benjamin Dauvergne il y a plus d'un an
Benjamin Renard a écrit :
À partir de Django 3.1 on peut poser directement
SESSION_COOKIE_SAMESITE = 'None'
sans ça il faudra l'équivalent de notre middleware (https://git.entrouvert.org/hobo.git/tree/hobo/middleware/cookies_samesite.py).Ok pour SESSION_COOKIE_SECURE. Pour SESSION_COOKIE_SAMESITE, on est sous Buster et donc Django 2.2.28 qui interdit la valeur None.
Si jamais vous aviez le projet de passer en stable, django 3.2 est disponible dans bullseye-backports. C'est ce que je conseillerai de faire, car django 2.x n'est plus maintenu. Coté authentic j'ai ouvert un ticket pour avoir les settings minimaux pour que ça fonctionne à partir de 3.1.
Mis à jour par Benjamin Renard il y a plus d'un an
Benjamin Dauvergne a écrit :
Benjamin Renard a écrit :
À partir de Django 3.1 on peut poser directement
SESSION_COOKIE_SAMESITE = 'None'
sans ça il faudra l'équivalent de notre middleware (https://git.entrouvert.org/hobo.git/tree/hobo/middleware/cookies_samesite.py).Ok pour SESSION_COOKIE_SECURE. Pour SESSION_COOKIE_SAMESITE, on est sous Buster et donc Django 2.2.28 qui interdit la valeur None.
Si jamais vous aviez le projet de passer en stable, django 3.2 est disponible dans bullseye-backports. C'est ce que je conseillerai de faire, car django 2.x n'est plus maintenu. Coté authentic j'ai ouvert un ticket pour avoir les settings minimaux pour que ça fonctionne à partir de 3.1.
Je viens de tenter le coup, mais malheureusement, avec django 3.2, Authentic ne démarre plus :
Dec 01 15:34:35 gavotte-pp systemd[1]: Starting Authentic 2... Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: Traceback (most recent call last): Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/authentic2/manage.py", line 20, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: execute_from_command_line(sys.argv[:1] + argv) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 419, in execute_from_command_line Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: utility.execute() Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 413, in execute Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: self.fetch_command(subcommand).run_from_argv(self.argv) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 354, in run_from_argv Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: self.execute(*args, **cmd_options) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 398, in execute Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: output = self.handle(*args, **options) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 89, in wrapped Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: res = handle_func(*args, **kwargs) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py", line 75, in handle Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: self.check(databases=[database]) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 419, in check Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: all_issues = checks.run_checks( Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/checks/registry.py", line 76, in run_checks Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: new_errors = check(app_configs=app_configs, databases=databases) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line 13, in check_url_config Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: return check_resolver(resolver) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/core/checks/urls.py", line 23, in check_resolver Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: return check_method() Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line 416, in check Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: for pattern in self.url_patterns: Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/utils/functional.py", line 48, in __get__ Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: res = instance.__dict__[self.name] = self.func(instance) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line 602, in url_patterns Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/utils/functional.py", line 48, in __get__ Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: res = instance.__dict__[self.name] = self.func(instance) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/urls/resolvers.py", line 595, in urlconf_module Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: return import_module(self.urlconf_name) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: return _bootstrap._gcd_import(name[level:], package, level) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap_external>", line 790, in exec_module Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/authentic2/urls.py", line 105, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: re_path(r'^manage/', include('authentic2.manager.urls')), Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django/urls/conf.py", line 34, in include Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: urlconf_module = import_module(urlconf_module) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: return _bootstrap._gcd_import(name[level:], package, level) Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap_external>", line 790, in exec_module Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/authentic2/manager/urls.py", line 20, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: from authentic2.apps.authenticators.manager_urls import urlpatterns as authenticator_urlpatterns Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/authentic2/apps/authenticators/manager_urls.py", line 19, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: from . import views Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/authentic2/apps/authenticators/views.py", line 34, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: from authentic2.manager.journal_views import BaseJournalView Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/authentic2/manager/journal_views.py", line 38, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: from . import views Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/authentic2/manager/views.py", line 51, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: from . import app_settings, forms, utils, widgets Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/authentic2/manager/forms.py", line 32, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: from django_select2.forms import HeavySelect2Widget Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: File "/usr/lib/python3/dist-packages/django_select2/forms.py", line 60, in <module> Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: from django.utils.six.moves.cPickle import PicklingError as cPicklingError Dec 01 15:34:36 gavotte-pp authentic2-manage[2855064]: ModuleNotFoundError: No module named 'django.utils.six' Dec 01 15:34:36 gavotte-pp systemd[1]: authentic2.service: Control process exited, code=exited, status=1/FAILURE Dec 01 15:34:36 gavotte-pp systemd[1]: authentic2.service: Failed with result 'exit-code'. Dec 01 15:34:36 gavotte-pp systemd[1]: Failed to start Authentic 2.
Je précise que la lib django-select2 provient de votre paquet python3-django-select2 version 5.10.0-1~eob110+2. Peut-être qu'une mise à jour de ce paquet s'impose.
Mis à jour par Paul Marillonnet il y a plus d'un an
- Lié à Development #72028: mettre à jour notre paquet debian python3-django-select2 (?) ajouté
Mis à jour par Frédéric Péters il y a plus d'un an
Benjamin, il y a une version 5.10.0-1~eob110+3 de python3-django-select2 dans le dépôt bullseye-eobuilder, qui fonctionne avec 3.2.
Mis à jour par Benjamin Renard il y a plus d'un an
Frédéric Péters a écrit :
Benjamin, il y a une version 5.10.0-1~eob110+3 de python3-django-select2 dans le dépôt bullseye-eobuilder, qui fonctionne avec 3.2.
Effectivement, je viens de faire le test et ça fonctionne. Merci !