IAM: Add email, login field validation to User create/update API (#112391)

* wip

* wip

* wip

(cherry picked from commit 8cedf25892)

* Search seems to be working, the validation is still wip

* Use keyword.Name analyzer for Filterable fields

* Only string fields should be indexed with keyword analyzer

* Change search query for email and login fields to use term query
* Remove unnecessary Exact from the resource protobuf definitions

Co-Authored-By: Ryan McKinley <ryantxu@gmail.com>

* Add legacy search support to the API

* Tests for legacy search, validate and integration tests for user

* Lint

* Add snapshot tests to userDocumentBuilder

* Address CodeQL issues

* Improvements, handle Mode2, tests should pass

* Change default limit from 0 to 1 for requests

* Cleanup

* Add fixme

* Update pkg/registry/apis/iam/register.go

Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>

* Update pkg/registry/apis/iam/user/legacy_search.go

Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
Misi
2025-10-23 11:29:02 +02:00
committed by GitHub
co-authored by Ryan McKinley Stephanie Hingtgen
parent f191acf811
commit ad9d8098ef
26 changed files with 1269 additions and 45 deletions
@@ -0,0 +1,11 @@
apiVersion: iam.grafana.app/v0alpha1
kind: User
metadata:
namespace: default
name: testuser-email-2
spec:
email: testuser-email-1@example
login: testuser-email-2
name: Test User Email 2
provisioned: false
role: None
@@ -0,0 +1,11 @@
apiVersion: iam.grafana.app/v0alpha1
kind: User
metadata:
namespace: default
name: testuser-email-1
spec:
email: testuser-email-1@example
login: testuser-email-1
name: Test User Email 1
provisioned: false
role: None
@@ -0,0 +1,11 @@
apiVersion: iam.grafana.app/v0alpha1
kind: User
metadata:
namespace: default
name: testuser-login-2
spec:
email: testuser-login-2@example.com
login: testuser-login-1
name: Test User Login 2
provisioned: false
role: None
@@ -0,0 +1,11 @@
apiVersion: iam.grafana.app/v0alpha1
kind: User
metadata:
namespace: default
name: testuser-login-1
spec:
email: testuser-login-1@example.com
login: testuser-login-1
name: Test User Login 1
provisioned: false
role: None
+1 -1
View File
@@ -4,7 +4,7 @@ metadata:
namespace: default
name: abcdefghijkl
spec:
email: testuser1@example123.com
email: testuser1@example123
login: testuser1
name: Test User 1
provisioned: false
+11
View File
@@ -0,0 +1,11 @@
apiVersion: iam.grafana.app/v0alpha1
kind: User
metadata:
namespace: default
name: testuser2
spec:
name: Test User 2
login: testuser2
email: testuser2@example
provisioned: false
role: Viewer