diff --git a/canaille/account.py b/canaille/account.py index 25e08c65..5b0c0054 100644 --- a/canaille/account.py +++ b/canaille/account.py @@ -159,7 +159,7 @@ def firstlogin(uid): @bp.route("/users") @permissions_needed("manage_users") def users(user): - users = User.filter() + users = User.all() return render_template("users.html", users=users, menuitem="users") diff --git a/canaille/commands.py b/canaille/commands.py index b66eb4bf..b8730abf 100644 --- a/canaille/commands.py +++ b/canaille/commands.py @@ -27,11 +27,11 @@ def clean(): setup_backend(current_app) - for t in Token.filter(): + for t in Token.all(): if t.is_expired(): t.delete() - for a in AuthorizationCode.filter(): + for a in AuthorizationCode.all(): if a.is_expired(): a.delete() diff --git a/canaille/groups.py b/canaille/groups.py index 3e284986..741d77c7 100644 --- a/canaille/groups.py +++ b/canaille/groups.py @@ -19,7 +19,7 @@ bp = Blueprint("groups", __name__, url_prefix="/groups") @bp.route("/") @permissions_needed("manage_groups") def groups(user): - groups = Group.filter() + groups = Group.all() return render_template("groups.html", groups=groups, menuitem="groups") diff --git a/canaille/ldap_backend/ldapobject.py b/canaille/ldap_backend/ldapobject.py index 0ddcd22b..5cd5cbeb 100644 --- a/canaille/ldap_backend/ldapobject.py +++ b/canaille/ldap_backend/ldapobject.py @@ -276,6 +276,10 @@ class LDAPObject: except (IndexError, ldap.NO_SUCH_OBJECT): return None + @classmethod + def all(cls, conn=None): + return cls.filter(conn=conn) + @classmethod def filter(cls, base=None, filter=None, conn=None, **kwargs): conn = conn or cls.ldap() diff --git a/canaille/models.py b/canaille/models.py index e1105d22..e86e0d2f 100644 --- a/canaille/models.py +++ b/canaille/models.py @@ -194,7 +194,7 @@ class Group(LDAPObject): except KeyError: return [] - groups = cls.filter(conn=conn) + groups = cls.all(conn=conn) Group.ldap_object_attributes(conn=conn) return [(group[name_attribute][0], group.dn) for group in groups] diff --git a/canaille/oidc/authorizations.py b/canaille/oidc/authorizations.py index 18691b9c..3ae47e1d 100644 --- a/canaille/oidc/authorizations.py +++ b/canaille/oidc/authorizations.py @@ -10,7 +10,7 @@ bp = Blueprint("authorizations", __name__, url_prefix="/admin/authorization") @bp.route("/") @permissions_needed("manage_oidc") def index(user): - authorizations = AuthorizationCode.filter() + authorizations = AuthorizationCode.all() return render_template( "oidc/admin/authorization_list.html", authorizations=authorizations, diff --git a/canaille/oidc/clients.py b/canaille/oidc/clients.py index ae8001d0..557763ae 100644 --- a/canaille/oidc/clients.py +++ b/canaille/oidc/clients.py @@ -21,14 +21,14 @@ bp = Blueprint("clients", __name__, url_prefix="/admin/client") @bp.route("/") @permissions_needed("manage_oidc") def index(user): - clients = Client.filter() + clients = Client.all() return render_template( "oidc/admin/client_list.html", clients=clients, menuitem="admin" ) def client_audiences(): - return [(client.dn, client.name) for client in Client.filter()] + return [(client.dn, client.name) for client in Client.all()] class ClientAdd(FlaskForm): diff --git a/canaille/oidc/tokens.py b/canaille/oidc/tokens.py index 7482d436..1569ac19 100644 --- a/canaille/oidc/tokens.py +++ b/canaille/oidc/tokens.py @@ -13,7 +13,7 @@ bp = Blueprint("tokens", __name__, url_prefix="/admin/token") @bp.route("/") @permissions_needed("manage_oidc") def index(user): - tokens = Token.filter() + tokens = Token.all() items = ( (token, Client.get(token.client), User.get(dn=token.subject)) for token in tokens diff --git a/tests/conftest.py b/tests/conftest.py index d4b8b149..afadfc62 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -333,7 +333,7 @@ def cleanup_users_and_groups(slapd_connection): yield User.ldap_object_classes(slapd_connection) Group.ldap_object_classes(slapd_connection) - for user in User.filter(conn=slapd_connection): + for user in User.all(conn=slapd_connection): user.delete(conn=slapd_connection) - for group in Group.filter(conn=slapd_connection): + for group in Group.all(conn=slapd_connection): group.delete(conn=slapd_connection) diff --git a/tests/oidc/conftest.py b/tests/oidc/conftest.py index 57ad626d..5145218a 100644 --- a/tests/oidc/conftest.py +++ b/tests/oidc/conftest.py @@ -130,5 +130,5 @@ def consent(slapd_connection, client, user): @pytest.fixture(autouse=True) def cleanup_consents(slapd_connection): yield - for consent in Consent.filter(conn=slapd_connection): + for consent in Consent.all(conn=slapd_connection): consent.delete(conn=slapd_connection) diff --git a/tests/oidc/test_authorization_code_flow.py b/tests/oidc/test_authorization_code_flow.py index 525e8275..995c6ded 100644 --- a/tests/oidc/test_authorization_code_flow.py +++ b/tests/oidc/test_authorization_code_flow.py @@ -331,7 +331,7 @@ def test_code_challenge(testclient, slapd_connection, logged_user, client): def test_authorization_code_flow_when_consent_already_given( testclient, slapd_connection, logged_user, client ): - assert not Consent.filter(conn=slapd_connection) + assert not Consent.all(conn=slapd_connection) res = testclient.get( "/oauth/authorize", @@ -388,7 +388,7 @@ def test_authorization_code_flow_when_consent_already_given( def test_authorization_code_flow_when_consent_already_given_but_for_a_smaller_scope( testclient, slapd_connection, logged_user, client ): - assert not Consent.filter(conn=slapd_connection) + assert not Consent.all(conn=slapd_connection) res = testclient.get( "/oauth/authorize",