Projet

Général

Profil

0059-misc-fix-deprecated-method-pylint-error-56982.patch

Valentin Deniaud, 21 septembre 2021 17:09

Télécharger (5,32 ko)

Voir les différences:

Subject: [PATCH 59/59] misc: fix deprecated-method pylint error (#56982)

 src/authentic2/compat/misc.py                 | 28 -------------------
 .../disco_service/disco_responder.py          | 10 +++----
 src/authentic2/utils/misc.py                  |  5 ++--
 3 files changed, 7 insertions(+), 36 deletions(-)
 delete mode 100644 src/authentic2/compat/misc.py
src/authentic2/compat/misc.py
1
# authentic2 - versatile identity manager
2
# Copyright (C) 2010-2019 Entr'ouvert
3
#
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU Affero General Public License as published
6
# by the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU Affero General Public License for more details.
13
#
14
# You should have received a copy of the GNU Affero General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16

  
17
import inspect
18

  
19
if hasattr(inspect, 'signature'):
20

  
21
    def signature_parameters(func):
22
        return inspect.signature(func).parameters.keys()
23

  
24

  
25
else:
26

  
27
    def signature_parameters(func):
28
        return inspect.getargspec(func)[0]
src/authentic2/disco_service/disco_responder.py
76 76
    try:
77 77
        liberty_provider = LibertyProvider.objects.get(entity_id=entity_id)
78 78
    except Exception:
79
        logger.warn('get_disco_return_url_from_metadata: unknown service provider %s', entity_id)
79
        logger.warning('get_disco_return_url_from_metadata: unknown service provider %s', entity_id)
80 80
        return None
81 81
    dom = parseString(liberty_provider.metadata.encode('utf8'))
82 82
    endpoints = dom.getElementsByTagNameNS(
83 83
        'urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol', 'DiscoveryResponse'
84 84
    )
85 85
    if not endpoints:
86
        logger.warn('get_disco_return_url_from_metadata: no discovery service endpoint for %s', entity_id)
86
        logger.warning('get_disco_return_url_from_metadata: no discovery service endpoint for %s', entity_id)
87 87
        return None
88 88
    ep = None
89 89
    value = 0
......
100 100
                value = int(endpoint.attributes['index'].value)
101 101
                ep = endpoint
102 102
    if not ep:
103
        logger.warn("get_disco_return_url_from_metadata: no valid endpoint for %s", entity_id)
103
        logger.warning("get_disco_return_url_from_metadata: no valid endpoint for %s", entity_id)
104 104
        return None
105 105

  
106 106
    logger.debug('get_disco_return_url_from_metadata: found endpoint with index %s', value)
......
110 110
        logger.debug('get_disco_return_url_from_metadata: location is %s', location)
111 111
        return location
112 112

  
113
    logger.warn('get_disco_return_url_from_metadata: no location found for endpoint with index %s', value)
113
    logger.warning('get_disco_return_url_from_metadata: no location found for endpoint with index %s', value)
114 114
    return None
115 115

  
116 116

  
......
152 152

  
153 153
        if not is_known_idp(idp_selected):
154 154
            message = 'The idp is unknown.'
155
            logger.warn("disco: Unknown selected idp %s", idp_selected)
155
            logger.warning("disco: Unknown selected idp %s", idp_selected)
156 156
            save_key_values(request, entityID, _return, policy, returnIDParam, isPassive)
157 157
            return HttpResponseRedirect(reverse(idp_selection))
158 158

  
src/authentic2/utils/misc.py
16 16

  
17 17
import copy
18 18
import ctypes
19
import inspect
19 20
import logging
20 21
import random
21 22
import time
......
578 579
    from django.contrib.auth import BACKEND_SESSION_KEY, SESSION_KEY, load_backend
579 580
    from django.contrib.auth.models import AnonymousUser
580 581

  
581
    from authentic2.compat.misc import signature_parameters
582

  
583 582
    SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
584 583
    session = SessionStore(session_key=session_key)
585 584
    try:
......
587 586
        backend_path = session[BACKEND_SESSION_KEY]
588 587
        assert backend_path in settings.AUTHENTICATION_BACKENDS
589 588
        backend = load_backend(backend_path)
590
        if 'session' in signature_parameters(backend.get_user):
589
        if 'session' in inspect.signature(backend.get_user).parameters:
591 590
            user = backend.get_user(user_id, session) or AnonymousUser()
592 591
        else:
593 592
            user = backend.get_user(user_id) or AnonymousUser()
594
-