grafana/pkg/services/sqlstore
Eric Leijonmarck 9c11040c3e
Serviceaccounts: Filtering service accounts from user queries (#41410)
* Add extra fields to OSS types to support enterprise

* WIP service accounts

* Update public/app/features/api-keys/ApiKeysForm.tsx

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>

* Create a service account at the same time as the API key

* Use service account credentials when accessing API with APIkey

* Throw better error

* Use Boolean for "create service account button"

* Add GetRole to service, merge RoleDTO and Role structs

This patch merges the identical OSS and Enterprise data structures, which improves the code for two reasons:

1.  Makes switching between OSS and Enterprise easier
2.  Reduces the chance of incompatibilities developing between the same functions in OSS and Enterprise

* Start work cloning permissions onto service account

* If API key is not linked to a service account, continue login as usual

* Fallback to old auth if no service account linked to key

* Commented

* Add CloneUserToServiceAccount

* Update mock.go

* Put graphical bits behind a feature toggle

* Start adding LinkAPIKeyToServiceAccount

* Update pkg/models/user.go

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

* Update pkg/api/apikey.go

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

* Update pkg/api/apikey.go

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

* Finish LinkAPIKeyToServiceAccount

* Update comment

* Handle api key link error

* Update pkg/services/sqlstore/apikey.go

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Feature toggle

* Update pkg/services/accesscontrol/accesscontrol.go

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>

* Not needed (yet)

* Better error messages for OSS accesscontrol

* Set an invalid user id as default

* ServiceAccountId should be string

* Re-arrange field names

* ServiceAccountId is integer

* Update ossaccesscontrol.go

* Linter

* Remove fronend edits

* Remove console log

* Update ApiKeysForm.tsx

* feat: add serviceaccount deletion

* feat: make sure we do not accidently delete serviceaccount

* feat: ServiceAccount Type

* refactor: userDeletions function

* refactor: serviceaccount deletions\

* refactor: error name and removed attribute for userDeletecommand

* refactor:: remove serviceaccount type for now

* WIP

* add mocked function

* Remove unnecessary db query, move to right place

* Update pkg/services/accesscontrol/mock/mock.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

* Update pkg/services/accesscontrol/mock/mock.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

* Update pkg/services/accesscontrol/mock/mock.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

* Better error messages

* Better and correcter error messages

* add mocked function

* refactor: move function call, add error msg

* add IsServiceAccount and fix table

* add service accounts package

* WIP

* WIP

* working serviceaccountsapi registration

* WIP tests

* test

* test working

* test running for service

* moved the error out of the models package

* fixed own review

* linting errors

* Update pkg/services/serviceaccounts/database/database.go

Co-authored-by: Jeremy Price <Jeremy.price@grafana.com>

* tests running for api

* WIP

* WIP

* removed unused secrets background svc

* removed background svc for serviceaccount infavor or wire.go

* serviceaccounts manager tests

* wip

* Filtering service accounts from the user queries in frontend

* clean up

* Update pkg/services/sqlstore/org_test.go

* methods on same type should have same receiver

* _ unused variable and comment

* add additional join for results query

* remove unused code

* remove error fmt

* refactor: change to only have false

* no new variable to the left hand side

* refactor: create serviceaccount cmd

* dialect fix

Co-authored-by: Jeremy Price <jeremy.price@grafana.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2021-11-23 23:06:40 +00:00
..
migrations Access Control: adding group field to roles (#41465) 2021-11-12 10:42:47 +00:00
migrator Migrate to Wire for dependency injection (#32289) 2021-08-25 15:11:22 +02:00
permissions Chore: Start harmonizing linting with plugin SDK (#25854) 2020-06-29 14:08:32 +02:00
searchstore Chore: update all +build statements (#38782) 2021-09-01 17:38:56 +03:00
sqlutil Chore: Add CloudWatch HTTP API tests (#29691) 2021-01-07 11:36:13 +01:00
alert_notification_test.go add context in the alert_notification (#41307) 2021-11-05 16:41:24 +08:00
alert_notification.go add context in the alert_notification (#41307) 2021-11-05 16:41:24 +08:00
alert_test.go Chore: Fix pass context for SetAlertStateCommand (#42135) 2021-11-23 16:40:09 +01:00
alert.go Chore: Fix pass context for SetAlertStateCommand (#42135) 2021-11-23 16:40:09 +01:00
annotation_cleanup_test.go Instrumentation: Start tracing database requests (#34572) 2021-05-27 13:55:33 +02:00
annotation_cleanup.go Annotations: Prevent orphaned annotation tags cleanup when no annotations were cleaned (#33957) 2021-05-12 10:44:00 +02:00
annotation_test.go Chore: update all +build statements (#38782) 2021-09-01 17:38:56 +03:00
annotation.go Chore: Replace util.DynMap with structs (#36332) 2021-07-01 10:23:33 +02:00
apikey_test.go Chore: Add context apikey (#41698) 2021-11-18 09:50:03 +01:00
apikey.go Chore: Add context apikey (#41698) 2021-11-18 09:50:03 +01:00
dashboard_acl_test.go Chore: Remove GoConvey from sqlstore package (#40753) 2021-10-21 14:09:19 +02:00
dashboard_acl.go Chore: Propagate context for dashboard guardian (#39201) 2021-09-23 17:43:32 +02:00
dashboard_folder_test.go Chore: Propagate context for search (#41010) 2021-10-28 11:29:07 +02:00
dashboard_provisioning_test.go Chore: Remove GoConvey from sqlstore package (#40753) 2021-10-21 14:09:19 +02:00
dashboard_provisioning.go Chore: Add context for dashboards (#39844) 2021-10-05 13:26:24 +02:00
dashboard_snapshot_test.go Encryption: Use secrets service (#40251) 2021-11-04 18:47:21 +02:00
dashboard_snapshot.go Chore: Refactor securedata to remove global encryption calls from dashboard snapshots (#38714) 2021-09-01 13:05:15 +02:00
dashboard_test.go Chore: Propagate context for search (#41010) 2021-10-28 11:29:07 +02:00
dashboard_version_test.go Chore: Add context dashboard version (#41672) 2021-11-17 10:57:37 +01:00
dashboard_version.go Chore: Add context dashboard version (#41672) 2021-11-17 10:57:37 +01:00
dashboard.go Chore: Propagate context for search (#41010) 2021-10-28 11:29:07 +02:00
database_wrapper.go Packaging: Dependency updates (#40534) 2021-10-18 19:50:10 +02:00
datasource_test.go Chore: Propagate context for data source provisioning (#40235) 2021-10-18 17:06:19 +02:00
datasource.go Chore: Propagate context for data source provisioning (#40235) 2021-10-18 17:06:19 +02:00
health_test.go Context: Add context to /api/health calls (#40031) 2021-10-11 14:35:03 +02:00
health.go Context: Add context to /api/health calls (#40031) 2021-10-11 14:35:03 +02:00
logger.go Chore: Update the xorm dependency (#22376) 2020-04-01 15:57:21 +02:00
login_attempt_test.go Chore: add context to login (#41316) 2021-11-08 15:53:51 +01:00
login_attempt.go Chore: add context to login (#41316) 2021-11-08 15:53:51 +01:00
org_test.go Serviceaccounts: Filtering service accounts from user queries (#41410) 2021-11-23 23:06:40 +00:00
org_users.go Serviceaccounts: Filtering service accounts from user queries (#41410) 2021-11-23 23:06:40 +00:00
org.go Chore: Add context to org (#40685) 2021-11-03 11:31:56 +01:00
playlist_test.go Chore: Add context to playlist (#41337) 2021-11-19 14:32:14 +01:00
playlist.go Chore: Add context to playlist (#41337) 2021-11-19 14:32:14 +01:00
plugin_setting.go Chore: Propagate context for plugin settings (#41166) 2021-11-02 13:42:55 +01:00
preferences_test.go Admin: Fix so Timezone is saved when saving preferences (#41583) 2021-11-11 11:13:01 +01:00
preferences.go Admin: Fix so Timezone is saved when saving preferences (#41583) 2021-11-11 11:13:01 +01:00
quota_test.go Chore: Add context to org (#40685) 2021-11-03 11:31:56 +01:00
quota.go Alerting: Remove ngalert feature toggle and introduce two new settings for enabling Grafana 8 alerts and disabling them for specific organisations (#38746) 2021-09-29 16:16:40 +02:00
session.go Instrumentation: Start tracing database requests (#34572) 2021-05-27 13:55:33 +02:00
sqlbuilder_test.go Chore: update all +build statements (#38782) 2021-09-01 17:38:56 +03:00
sqlbuilder.go LibraryPanels: Adds permissions to getAllHandler (#31416) 2021-02-24 14:06:22 +01:00
sqlstore_test.go Chore: update all +build statements (#38782) 2021-09-01 17:38:56 +03:00
sqlstore.go Chore: Add context to playlist (#41337) 2021-11-19 14:32:14 +01:00
sqlstore.goconvey feat(invite): small progress 2015-07-17 14:42:49 +02:00
star.go Chore: Add context to star and stats (#39591) 2021-09-28 17:54:45 +02:00
stars_test.go Chore: Add context to star and stats (#39591) 2021-09-28 17:54:45 +02:00
stats_integration_test.go Chore: Add context to star and stats (#39591) 2021-09-28 17:54:45 +02:00
stats_test.go Chore: Add context to org (#40685) 2021-11-03 11:31:56 +01:00
stats.go Add monthlyActiveUsers to stats API and usage report (#41289) 2021-11-03 18:59:05 -03:00
tables.go Began work on real sql schema definitions, and migration engine 2015-01-17 21:40:22 +01:00
tags_test.go Chore: Remove GoConvey from sqlstore package (#40753) 2021-10-21 14:09:19 +02:00
tags.go Chore: Enable Go linter gocritic (#26224) 2020-07-16 14:39:01 +02:00
team_test.go Chore: Add context to team (#40504) 2021-10-18 14:02:39 +02:00
team.go Chore: Add context to team (#40504) 2021-10-18 14:02:39 +02:00
temp_user_test.go Chore: Add context to temp user (#41284) 2021-11-04 11:17:07 +01:00
temp_user.go Chore: Add context to temp user (#41284) 2021-11-04 11:17:07 +01:00
tls_mysql.go Chore: Fix staticcheck issues (#28854) 2020-11-05 11:57:20 +01:00
transactions_test.go Chore: Add context apikey (#41698) 2021-11-18 09:50:03 +01:00
transactions.go remove the global log error/warn etc functions (#41404) 2021-11-08 17:56:56 +01:00
user_test.go Chore: Add context to org (#40685) 2021-11-03 11:31:56 +01:00
user.go Serviceaccounts: Filtering service accounts from user queries (#41410) 2021-11-23 23:06:40 +00:00