Auth: Adds validation and ingestion of conflict file (#53014)

* add users-manager command

* add users-manager command

* rename files

* refactor: imports and renaming

* Command: add conflict merge user command

- MergeUser will
	- replace all user_ids from conflicting users to the chosen userId
	- delete users whose user_ids are not the chosen user
- SameIdentification will
	- update chosen user with chosen email,login details
	- delete users whose user_ids are not the chosen user

* refactor: clean up

* refactor: create structure for read, validate, ingest

* feat: ls and generate-file for conflicting users

* remove usagestats

* added back pkg/services/login/authinfoservice/database/stats.go

* Revert "added back pkg/services/login/authinfoservice/database/stats.go"

This reverts commit 2ba6e3c4d602122bda86911c56934407904eb268.

* Revert "remove usagestats"

This reverts commit 1e3fa978100eed48f4bead0f631b8bd03e01588b.

* cherry pick

* Revert "cherry pick"

This reverts commit 461626c306b9501e3e4eed05a5919caa7a3de884.

* validation of picked merge user

* fix test

* make lint

* make test run

* tests for ingest working

* clean up and refactored to align with downstream refactoring

* formatting

* refactor: name list instead of ls

* fix: static lint error use trimprefix

* WIP: permissions for validation

* fix: remove unused functions in sqlstore

* fix: remove unused function

* handling of multiple users and resolve discarded users

* fix tests

* fix: bug that did not exclude the blocks

* ioutil is blacklisted

* WIP: validation

* tests for merging a user working

* add latest changes to output print

* refactor: removed conflictEmail and conflictLogin that was not used

* refactor: code clean up, showChanges working

* test and linting fixes

* test and linting fixes

* refactor: removed logging of config and added more info for vlidation command

* refactor: fix order of code

* fix time now

* refactor: no longer need for check casesensitive login/email

* removed unnessecary loop

* refactor: move functions around

* test: working

* docs: add docuemntationf for file

* Add failing test for generating the conflict login block

* Fix regex

* Fix some stuff/tests

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>

* add: docs for conflict file

* add: conflict_email, conflict_login fields

* add: conflict_email, conflict_login fields

* WIP

* fix: tests working as intended

* Update pkg/cmd/grafana-cli/commands/conflict_user_command.go

Co-authored-by: linoman <2051016+linoman@users.noreply.github.com>

* review comments

* Update pkg/cmd/grafana-cli/commands/conflict_user_command.go

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>

* Update pkg/cmd/grafana-cli/commands/conflict_user_command.go

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>

* missspelling

* trailing new line

* update to use userimpl store

* remove newline

* remove newline

* refactor: initializing of resolver for conflicts

* fix: test sqlStore

* refactor: removed lines

* refactor: remove TODOs

Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
Co-authored-by: linoman <2051016+linoman@users.noreply.github.com>
This commit is contained in:
Eric Leijonmarck
2022-09-29 14:26:24 +02:00
committed by GitHub
parent 9a68f8704f
commit 1e8f8dff4b
6 changed files with 937 additions and 198 deletions

View File

@ -208,9 +208,19 @@ var adminCommands = []*cli.Command{
},
{
Name: "generate-file",
Usage: "creates a conflict users file.. Safe to execute multiple times.",
Usage: "creates a conflict users file. Safe to execute multiple times.",
Action: runGenerateConflictUsersFile(),
},
{
Name: "validate-file",
Usage: "validates the conflict users file. Safe to execute multiple times.",
Action: runValidateConflictUsersFile(),
},
{
Name: "ingest-file",
Usage: "ingests the conflict users file",
Action: runIngestConflictUsersFile(),
},
},
},
},