1
0
mirror of https://github.com/quay/quay.git synced 2026-01-27 18:42:52 +03:00

28 Commits

Author SHA1 Message Date
jbpratt
963a90ecdd fix(ldap): eliminate redundant conn in user search methods (PROJQUAY-7057) (#4720)
Each LDAP user search was creating two connections: one just to verify
admin credentials worked, then another for the actual search. This
doubled the load on LDAP servers. Consolidated into a single connection
block with proper error handling for INVALID_CREDENTIALS.

Affected methods:
- _ldap_user_search(): Core search used by most LDAP operations
- at_least_one_user_exists(): User existence checks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Brady Pratt <bpratt@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-15 09:56:03 -06:00
Jordi Piriz
747d1694cd revert: tracing improving otlp handling (PROJQUAY-8902) (#4438)
Revert "tracing: improving otlp handling (PROJQUAY-8902) (#4198)"

This reverts commit 89e758846f.
2025-11-03 16:17:32 +01:00
Michaela Lang
89e758846f tracing: improving otlp handling (PROJQUAY-8902) (#4198)
improve OpenTelemetry implementation
2025-10-23 12:20:34 -04:00
Michaela Lang
0e91a7aec0 federationuser(ldap): avoid doing LDAP lookups for Robot accounts (PROJQUAY-5137) (#2505)
BREAKING CHANGE: LDAP lookup of robot accounts in the UI for granting permission has been dropped in context of permissions granting. This impacts Users from LDAP if they have not logged in to Quay already (pre provisioning) as a Federation User will only be available after logging in or being part of a Team.
2025-07-25 09:05:22 -04:00
Brandon Caton
65e727086a ldap: allow global readonly superuser to be filtered (PROJQUAY-7044) (#2917)
Allow global readonly superuser to be specified via LDAP.
2024-06-04 15:19:37 -04:00
Michaela Lang
4719f46c2c federationuser(ldap): adding keepalive settings for LDAP connections (PROJQUAY-5137) (#1975)
* - added env option to select if we want to follow LDAP referrals
- added check on LDAP if the result is a list, it is an LDAP referral

* - change to config.yaml parameter option for enabling/disabling LDAP
  referral lookups
- removed the per/method parameter and moved the referral into the Base
  class

- verified behavior with changing the config.yaml option
  `LDAP_FOLLOW_REFERRALS`

    ```
    $ grep LDAP_FOLLOW_REFERRALS config.yaml
    LDAP_FOLLOW_REFERRALS: 0

    $ ./update_bundle
    secret "quay-config-secret" deleted
    secret/quay-config-secret created
    deployment.apps/quay restarted

    $ oc -n quay logs -f deploy/quay | grep referrals
    gunicorn-web stdout | 2023-05-25 09:41:36,524 [74] [DEBUG] [data.users] LDAPUsers return referrals value 0
    gunicorn-secscan stdout | 2023-05-25 09:41:38,093 [73] [DEBUG] [data.users] LDAPUsers return referrals value 0
    gunicorn-registry stdout | 2023-05-25 09:41:38,410 [72] [DEBUG] [data.users] LDAPUsers return referrals value 0

    $ sed -i -e " s#LDAP_FOLLOW_REFERRALS: 0#LDAP_FOLLOW_REFERRALS: 1#; " config.yaml
    $ grep LDAP_FOLLOW_REFERRALS config.yaml
    LDAP_FOLLOW_REFERRALS: 1

    $ ./update_bundle
    secret "quay-config-secret" deleted
    secret/quay-config-secret created
    deployment.apps/quay restarted

    $ oc -n quay logs -f deploy/quay  | grep referrals
    gunicorn-secscan stdout | 2023-05-25 09:42:22,466 [72] [DEBUG] [data.users] LDAPUsers return referrals value 1
    gunicorn-web stdout | 2023-05-25 09:42:22,496 [73] [DEBUG] [data.users] LDAPUsers return referrals value 1
    gunicorn-registry stdout | 2023-05-25 09:42:23,658 [71] [DEBUG] [data.users] LDAPUsers return referrals value 1
    ```

* reformatted LDAPConnectionBulder call according to PEP

* fixed the formatting change according to pip black

* BREAKING CHANGE: LDAP lookup of robot accounts in the UI for granting
                 permission has been dropped. This impacts Users from LDAP
                 if they have not logged in already (pre provisioning).

the functions:

* _ldap_single_user_search
* _ldap_user_search

have been updated to provide `context` for dropping the LDAP query. As
the functions are used during login as well as during setting
permissions it is mandatory to be able to distinguish the context.

the functions:

* get_nonrobot_user
* find_user_by_email

from the module `data.model.user` have been utilized to identify, if the
user should be looked up in LDAP or not.

* Adding keepalive setting for LDAP connection in complex network
scenarios.

* removed PROJQUAY-5137 (part one) to simplify merging and rollback
-> Revert "BREAKING CHANGE: LDAP lookup of robot accounts in the UI for granting"

This reverts commit 8765093d73.

* fixed black
2023-10-17 17:36:24 +02:00
Marcus Kok
dd96025ff5 user: Support custom LDAP memberOf attribute (PROJQUAY-5928) (#2406)
* user: Support custom LDAP memberOf attribute (PROJQUAY-3235)
* rebase of [PR 1120](https://github.com/quay/quay/pull/1120)

---------

Co-authored-by: Marius Bakke <marius.bakke@usit.uio.no>
2023-10-16 09:33:30 -04:00
Kenny Lee Sin Cheong
5f63b3a7bb chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -04:00
Michaela Lang
7ecf97b9fc authentication(LDAP): allow LDAP referrals to not be followed (PROJQUAY-5291) (#1905) 2023-06-02 19:32:18 +02:00
Kenny Lee Sin Cheong
16e5321108 permissions: lazy-load superuser permissions (PROJQUAY-5117) (#1761) 2023-03-06 10:29:55 -05:00
Ivan Bazulic
95a5932528 security: Change error messages in UI during LDAP login (PROJQUAY-4845) (#1767)
* Change error messages in UI during LDAP login (PROJQUAY-4845)

Previously, on installations where LDAP is used, we were telling users whether the username or password was failing when login attempts were made. This might pose a security risk, a malicious user could, via the returned message, identify which users have access to Quay and which don't.
With this change, we return a general message saying the user used wrong credentials instead of providing any details.

* Fixed tests.

* Fix some more tests.

* Readd accidental removal of one assertion.
2023-03-02 11:49:11 -05:00
Kenny Lee Sin Cheong
dba302b5f1 users: default to true if LDAP_RESTRICTED_USER_FILTER is not set (PROJQUAY-4776) (#1645)
When LDAP is used and FEATURE_RESTRICTED_USERS is set, if
LDAP_RESTRICTED_USER_FILTER is set, then, by default, all ldap users
are restricted.
2022-11-25 13:39:07 -05:00
Kenny Lee Sin Cheong
c84067a4d6 users: add restricted users' filter (PROJQUAY-1245) (#1551)
- Similar to LDAP_SUPERUSER_FILTER, add a specific filter to define
restricted users, based on the LDAP_USER_FILTER
- restrict writes on restricted users' own namespace. Normal
permissions applies on organization membership
- add global readonly superuser GLOBAL_READONLY_SUPER_USERS (PROJQUAY-2604)
- Removes RESTRICTED_USER_INCLUDE_ROBOTS, FEATURE_RESTRICTED_READ_ONLY_USERS
2022-10-28 13:38:37 -04:00
Kenny Lee Sin Cheong
14e87bd41e users: fix missing references in ldap for superusers (#1542) 2022-09-26 16:15:52 -04:00
Kenny Lee Sin Cheong
070f464b14 users: superuser group in federated identity provider (PROJQUAY-3924) (#1464) 2022-08-11 15:36:10 -04:00
Oleg Bulatov
5eaf0584db chore: Run mypy as CI job (#1363)
* Run mypy as CI job

* Fix peewee.pyi and configure pyright
2022-06-13 11:01:17 +02:00
thomasmckay
f9126ea375 PROJQUAY-1258 - correct ldap python3 call (#600) 2020-11-18 15:20:42 -05:00
thomasmckay
bf83ddee4b PROJQUAY-1273 - ldap bytes-like strings (#598) 2020-11-12 14:07:37 -05:00
Kurtis Mullins
52b86ac9fd [PROJQUAY-822] security: Hide sensitive LDAP log data (#562) 2020-10-06 12:44:07 -04:00
Kenny Lee Sin Cheong
71a2ba052c Fix ldap user login (#509)
* Fix typo

* Make sure python-ldap uses str instead of bytes
2020-08-07 16:08:36 -04:00
Kurtis Mullins
38be6d05d0 Python 3 (#153)
* Convert all Python2 to Python3 syntax.

* Removes oauth2lib dependency

* Replace mockredis with fakeredis

* byte/str conversions

* Removes nonexisting __nonzero__ in Python3

* Python3 Dockerfile and related

* [PROJQUAY-98] Replace resumablehashlib with rehash

* PROJQUAY-123 - replace gpgme with python3-gpg

* [PROJQUAY-135] Fix unhashable class error

* Update external dependencies for Python 3

- Move github.com/app-registry/appr to github.com/quay/appr
- github.com/coderanger/supervisor-stdout
- github.com/DevTable/container-cloud-config
- Update to latest mockldap with changes applied from coreos/mockldap
- Update dependencies in requirements.txt and requirements-dev.txt

* Default FLOAT_REPR function to str in json encoder and removes keyword assignment

True, False, and str were not keywords in Python2...

* [PROJQUAY-165] Replace package `bencode` with `bencode.py`

- Bencode is not compatible with Python 3.x and is no longer
  maintained. Bencode.py appears to be a drop-in replacement/fork
  that is compatible with Python 3.

* Make sure monkey.patch is called before anything else (

* Removes anunidecode dependency and replaces it with text_unidecode

* Base64 encode/decode pickle dumps/loads when storing value in DB

Base64 encodes/decodes the serialized values when storing them in the
DB. Also make sure to return a Python3 string instead of a Bytes when
coercing for db, otherwise, Postgres' TEXT field will convert it into
a hex representation when storing the value.

* Implement __hash__ on Digest class

In Python 3, if a class defines __eq__() but not __hash__(), its
instances will not be usable as items in hashable collections (e.g sets).

* Remove basestring check

* Fix expected message in credentials tests

* Fix usage of Cryptography.Fernet for Python3 (#219)

- Specifically, this addresses the issue where Byte<->String
  conversions weren't being applied correctly.

* Fix utils

- tar+stream layer format utils
- filelike util

* Fix storage tests

* Fix endpoint tests

* Fix workers tests

* Fix docker's empty layer bytes

* Fix registry tests

* Appr

* Enable CI for Python 3.6

* Skip buildman tests

Skip buildman tests while it's being rewritten to allow ci to pass.

* Install swig for CI

* Update expected exception type in redis validation test

* Fix gpg signing calls

Fix gpg calls for updated gpg wrapper, and add signing tests.

* Convert / to // for Python3 integer division

* WIP: Update buildman to use asyncio instead of trollius.

This dependency is considered deprecated/abandoned and was only
used as an implementation/backport of asyncio on Python 2.x
This is a work in progress, and is included in the PR just to get the
rest of the tests passing. The builder is actually being rewritten.

* Target Python 3.8

* Removes unused files

- Removes unused files that were added accidentally while rebasing
- Small fixes/cleanup
- TODO tasks comments

* Add TODO to verify rehash backward compat with resumablehashlib

* Revert "[PROJQUAY-135] Fix unhashable class error" and implements __hash__ instead.

This reverts commit 735e38e3c1d072bf50ea864bc7e119a55d3a8976.
Instead, defines __hash__ for encryped fields class, using the parent
field's implementation.

* Remove some unused files ad imports

Co-authored-by: Kenny Lee Sin Cheong <kenny.lee@redhat.com>
Co-authored-by: Tom McKay <thomasmckay@redhat.com>
2020-06-05 16:50:13 -04:00
Benjamin Merot
bab908d8f2 Defined found_results before try block so it's always assigned (#376)
Up until now, the "if not found_results" line could throw an UnboundLocalError because the variable was assigned inside a try block which could fail but the variable was later referenced.
2020-05-12 10:59:41 -04:00
Joseph Schorr
2f171889e4 Fix search filter for LDAP user lookup when no user filter is specified (#346)
The LDAP class defined the filter using a default Python parameter, so
we need to mimic it
2020-04-22 16:44:32 -04:00
Joseph Schorr
3e8ef9574c Ensure that all user-provided filters are wrapped in parens (#322)
Also adds tests and fixes some issues with our existing filter

Fixes https://issues.redhat.com/browse/PROJQUAY-551
2020-04-07 17:30:12 -04:00
Joseph Schorr
5619452776 Add ability to filter user lookups in LDAP user system (#252)
This allows customers to specify additional restrictions on the users
that are allowed to be used

Fixes https://issues.redhat.com/browse/PROJQUAY-226
2020-03-16 11:38:14 -04:00
alecmerdler
3dd5f045ff fix all the docstrings 2020-02-05 19:55:07 -08:00
Tom McKay
e6ae94db8b 'make black' results 2019-12-02 12:23:08 -05:00
Jimmy Zelinskie
9c0dd3b722 initial import for Open Source 🎉 2019-11-12 11:09:47 -05:00