From 501679cbdfe544ee20a9c26e55a23275287e3d94 Mon Sep 17 00:00:00 2001 From: Dale Smith Date: Thu, 25 Sep 2025 15:59:15 +1200 Subject: [PATCH] Add optional use_mfa header to user list display Change-Id: I14179213466be640aac9f9878181660fc4d90bb8 Signed-off-by: Dale Smith --- adjutantclient/osc/v1/users.py | 14 +++++++++++--- .../notes/add-mfa-display-2eeb55fbd40d671c.yaml | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add-mfa-display-2eeb55fbd40d671c.yaml diff --git a/adjutantclient/osc/v1/users.py b/adjutantclient/osc/v1/users.py index 5493778..96d8002 100644 --- a/adjutantclient/osc/v1/users.py +++ b/adjutantclient/osc/v1/users.py @@ -32,10 +32,18 @@ class UserList(command.Lister): project_users = client.users.list() headers = [ 'id', 'name', 'email', 'roles', 'cohort', 'status'] + optional_headers = ['has_mfa'] - rows = [[user.id, user.name, user.email, - user.roles, user.cohort, user.status] - for user in project_users] + rows = [] + for user in project_users: + # Check the first user for optional headers. + for opt in optional_headers: + if hasattr(user, opt): + headers.append(opt) + optional_headers = [] + rows.append([ + getattr(user, header) for header in headers + ]) return headers, rows diff --git a/releasenotes/notes/add-mfa-display-2eeb55fbd40d671c.yaml b/releasenotes/notes/add-mfa-display-2eeb55fbd40d671c.yaml new file mode 100644 index 0000000..4912d9b --- /dev/null +++ b/releasenotes/notes/add-mfa-display-2eeb55fbd40d671c.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add support for optionally displaying column use_mfa in user list if + Adjutant API returns this in the query. This may be added to responses if + Adjutant MFA server plugin is installed and the user has the appropriate + roles in the project otherwise it is omitted.