Commit Graph

82 Commits

Author SHA1 Message Date
Ieva
6885b3d577
Chore: remove checks for whether RBAC is disabled (#73812)
* remove checks for whether access control is disabled, as it is always enabled now

* linting
2023-08-25 14:19:58 +01:00
Karl Persson
124e0efe1f
Authn: external identity sync (#73461)
* Authn: Add interface for external identity sync

This interface is implemented by authnimpl.Service and just triggers PostAuthHooks and skipping last seen update by default

* Authn: Add SyncIdentity to fake and add a new mock
2023-08-18 11:11:44 +02:00
linoman
2e050f25bf
Auth: Allow to auto-assign empty role (#73326)
Allow to auto-assign empty role
2023-08-17 18:32:58 +02:00
linoman
1c7f89c41b
Auth: Add empty role usage metrics for service and user accounts (#73108)
* Add tests for service accounts metrics usage

* Add service account store implementation

* Add service account service implementation

* Add tests for org metrics usage

* Add org implementation

* Add service implementation
2023-08-16 10:56:47 +02:00
Jo
5d8e6aa162
Auth: Org Invite and Team API SignedInUser interfacing (#73085)
* fix ngalert Evaluate sig change

* interface for teams and org invites

* Update pkg/api/org_invite.go

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

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2023-08-09 12:33:35 +02:00
Jo
bd1a856d33
Auth: Add SignedIn user interface NamespacedID (#72944)
* wip

* scope active user to 1 org

* remove TODOs

* add render auth namespace

* import cycle fix

* make condition more readable

* convert Evaluate to user Requester

* only use active OrgID for SearchUserPermissions

* add cache key to interface definition

* change final SignedInUsers to interface

* fix api key managed roles fetch

* fix anon auth id parsing

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

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

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2023-08-09 09:35:50 +02:00
Ryan McKinley
7431c0ddb1
UserSync: Avoid UpdateLastSeenAt with invalid user ids (#72776)
* avoid user zero

* more errors

* more tests

* split
2023-08-03 08:26:02 +02:00
Jo
30274a4f88
Auth: Move Team service to SignedInUserInterface (#72674)
* move SignedInUser to specific file

* add primitive interface for signedInUser
2023-08-02 10:43:56 +02:00
Ieva
d3b481dac8
Auth: Lock down Grafana admin role updates if the role is externally synced (#72677)
* lock down server admin role updates on the frontend if the user is externally synced

* add tests

* lock Grafana Server admin role updates from the backend

* rename variables

* check that the user has auth info

* add LDAP to providers for which Grafana Server admin role can be synced

* linting
2023-08-01 16:39:08 +01:00
Jo
7d347cd428
Auth: remove org count from signedInUser (#72661)
* tweaks

* remove org count from signedinUser

* remove org count from signedinUser store

* fix broken tests

* restore frontend interface
2023-08-01 14:04:37 +02:00
Jo
ed780ce0e9
Auth: Fix Last Seen being updated on every request (#72036)
* make sure LastSeen hook has information to decide if update is necessary

* make user service check if it should update the user's last seen

* do not run last seen hook if is a login request

* make service return error when last seen is up to date

* fix err

* Update pkg/services/contexthandler/contexthandler.go

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

* fix golint

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2023-07-24 16:37:35 +02:00
Misi
5efc3386d3
AuthZ: Extend /api/search to work with self-contained permissions (#70749)
* Search sql filter draft, unfinished

* Search works for empty roles

* Add current AuthModule to SignedInUser

* clean up, changes to the search

* Use constant prefixes

* Change AuthModule to AuthenticatedBy

* Add tests for using the permissions from the SignedInUser

* Refactor and simplify code

* Fix sql generation for pg and mysql

* Fixes, clean up

* Add test for empty permission list

* Fix

* Fix any vs all in case of edit permission

* Update pkg/services/authn/authn.go

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

* Update pkg/services/sqlstore/permissions/dashboard_test.go

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

* Fixes, changes based on the review

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2023-07-12 12:31:36 +02:00
Jo
5ec0f82baa
Separate authn flow from analytics (#68327)
* separate authn flow from analytics

* lint fix
2023-05-15 18:38:54 +02:00
Jo
8df54a6daa
Users: Enable case insensitive login by default (#66134)
* enable case insensitive by default

* fix missing case-insensitive query

* fix missing case insensitive query

* fix missing case insensitive query in temp_user

* skip integration testing in mysql

* skip integration testing in mysql

* use t.cleanup

* lowercase only once

* aligned to only using sql as that is what we do in other parts

---------

Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
2023-04-28 16:38:58 +01:00
Eric Leijonmarck
6b8c77c70c
Usagestats: Add interface for stats for user.Service and add Usagestats for case_insensitive_login (#66742)
* add interface for stats

* add user service to registry
2023-04-18 14:34:40 +01:00
Ieva
ed11c32c1d
Support bundles: fix user collector permissions and format collector output (#64531)
* fix user collector permissions and format collector output

* lint
2023-03-09 11:43:18 -05:00
Ieva
1d1f58f0ed
Service accounts: fix usage of errutil errors and convert more errors to errutil (#64299)
* fix usage of errutil errors and convert more errors to errutil

* fix tests
2023-03-08 11:32:09 +00:00
Sofia Papagiannaki
e6e8351ee9
Chore: Remove CreateUserForTests() (#64125)
* Chore: Remove CreateUserForTests

* Apply suggestion from code review
2023-03-03 11:01:23 -05:00
Ashley Harrison
d61bcdf4ca
Chore: Pass signed user_hash to Intercom via Rudderstack (#63921)
* move analytics identifiers to backend

* implement hash function

* grab secret from env

* expose and retrieve intercom secret from config

* concat email with appUrl to ensure uniqueness

* revert to just using email

* Revert "revert to just using email"

This reverts commit 8f10f9b1bc.

* add docstring
2023-03-03 14:39:53 +00:00
Ieva
3fb1894739
Service accounts: Creation logic simplification (#63884)
* SA creation improvements

* PR feedback - put salt and rand back in and remove an unneeded line:
2023-03-01 16:31:20 +00:00
Jo
c8db771939
Users: Fix org user always getting org id = 1 on auto assign false (#63708)
* fix org user always getting org id = 1 on auto assign false

* make tests explicit

* use correct cfg in service accounts

* fix api tests

* fix database test of ac

* fix InsertOrgUser returning affected rows as orgID
2023-02-24 18:08:44 +01:00
Karl Persson
16b416b88b
AuthN: Extract enable disabled users logic to its own hook (#63628) 2023-02-23 13:06:06 +01:00
Eric Leijonmarck
c1c0daa13d
Service accounts: Fix err message suppressed (#63406)
fix: err message suppresed fix
2023-02-18 11:17:02 +00:00
Eric Leijonmarck
91b5337600
Auth: Refactoring of frontend skipOrgRoleSync logic to backend (#62921)
* WIP

* refactor: add function in login for externSynced

* refactor: make function to make ExternalSyncedInfo

- adds tests
- refactors strings into consts

* remove: console.log

* remove: unnessecary comment

* added exhaustive tests

* refactor: labelname

* removed unused code

* missspelling

* refactor: based on review comments

* add: comment to functions about authinfo behavior

* Update pkg/services/login/authinfo.go

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

* Update pkg/services/login/authinfo.go

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

* fix: tests

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2023-02-08 20:11:46 +00:00
Jo
f9163351fd
Support bundles: Refactor registry into separate service (#62945)
* add bundle registry service to avoid dependency cycles

* move user support bundle collector to user service

* move usage stat bundle implementation to usage stats

* add info for background service

* fix remaining imports

* whitespace
2023-02-06 17:50:03 +01:00
idafurjes
cbc10f9c5d
Chore: Delete password and search from models package (#62482)
* Chore: Delete password and search from models package

* Rename model to AdminCreateUserResponse
2023-01-31 11:04:55 +01:00
Serge Zaitsev
bc2813ef06
Chore: Fix goimports grouping in pkg/services (#62420)
* fix goimports

* fix goimports order
2023-01-30 08:21:27 +00:00
Kristin Laemmert
e8b8a9e276
chore: move dashboard_acl models into dashboard service (#62151) 2023-01-26 08:46:30 -05:00
idafurjes
b54b80f473
Chore: Remove Result from dashboard models (#61997)
* Chore: Remove Result from dashboard models

* Fix lint tests

* Fix dashboard service tests

* Fix API tests

* Remove commented out code

* Chore: Merge main - cleanup
2023-01-25 10:36:26 +01:00
idafurjes
68445a7c77
Chore: Remove dashboard ACL from models (#61749)
* Remove dashboard ACL from models

* Remove unused comment
2023-01-20 14:58:47 +01:00
idafurjes
b573b19ca3
Chore: Remove dashboards from models pkg (#61578)
* Copy dashboard models to dashboard pkg

* Use some models from current pkg instead of models

* Adjust api pkg

* Adjust pkg services

* Fix lint

* Chore: Remove dashboards models

* Remove dashboards from models pkg

* Fix lint in tests

* Fix lint in tests 2

* Fix for import in auth

* Remove newline

* Revert unused fix
2023-01-18 13:52:41 +01:00
idafurjes
f2ffce4351
Chore: Move team models to models pkg (#61262)
* Chore: Move team models to models pkg

* Fix ACL tests

* More ACL tests

* Change Id to ID in conflict user command test

* Remove team from models

* Fix ac test lint
2023-01-11 14:20:09 +01:00
Jo
0c8ad80575
Authn: JWT client (#61157)
* add jwt client

* alias JWT verifier

* debug implementation

* add tests for jwt client

* add constant for JWT module

* Feedback

Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Mihály Gyöngyösi <mgyongyosi@users.noreply.github.com>

Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Mihály Gyöngyösi <mgyongyosi@users.noreply.github.com>
2023-01-10 15:08:52 +01:00
idafurjes
bb35f37b66
Chore: Delete org model duplicates (#60940)
* Delete org model duplicates

* Fix lint

* Move OrgDetailsDTO to org pkg
2023-01-04 16:20:26 +01:00
Jo
a553040441
Authn: Refactor user sync and org sync as post auth hooks (#60504)
* add user sync

* add org user sync

* add client params

* merge remaining conflicts

* remove change to report.go

* update comments

* add basic tests for user ID population

* add tests for auth ID find

* add tests for user sync create and update

* add tests for orgsync

* satisfy lint

* add userID guards
2022-12-20 08:59:05 -05:00
Kristin Laemmert
ceb3d8d295
feature (user service): Add a validation check after the user record is created in the sqlstore. (#59968)
Add a validation check after the user record is created in the sqlstore.
2022-12-07 12:33:40 -05:00
Kristin Laemmert
70fbf47022
chore: remove CreateUser from sqlstore & replace with userService.CreateUserForTests (#59910) 2022-12-07 11:03:22 -05:00
idafurjes
d6275c58dd
Remove GetSignedInUserWithCacheCtx and GetSignedInUser from sqlstore (#59551)
* Remove GetSignedInUserWithCacheCtx and GetSignedInUser from sqlstore

* Delete removed method from test
2022-11-30 14:28:51 +01:00
idafurjes
a7b2943dd1
Chore: Delete SetUsingOrg from sqlstore (#59276)
* Chore: Delete SetUsingOrg drom sqlstore

* Adjust test

* Move test to dashboards

* Move test
2022-11-28 14:59:40 +01:00
Jo
d7a652ff7f
User: Optimize signed in user cache management (#59090)
* only access the cache if a user ID is set

* ignore all negative values
2022-11-23 12:04:38 +01:00
idafurjes
054d87e52e
Chore: Remove DeleteUser from sqlstore (#59180)
* Remove DeleteUser from sqlstore

* Use Delete instead of DeleteUser

* Remove unused method
2022-11-23 11:15:48 +01:00
Serge Zaitsev
b875ca08c6
SQLStore: Make addOrgUser private (#59142)
make addOrgUser private
2022-11-22 17:02:39 +00:00
Sofia Papagiannaki
9855e74b92
Chore: Refactor quota service (#58643)
Chore: Refactor quota service (#57586)

* Chore: refactore quota service

* Apply suggestions from code review
2022-11-14 21:08:10 +02:00
Sofia Papagiannaki
96cdf77995
Revert "Chore: Refactor quota service (#57586)" (#58394)
This reverts commit 326ea86a57.
2022-11-08 11:52:07 +02:00
Sofia Papagiannaki
326ea86a57
Chore: Refactor quota service (#57586)
* Chore: refactore quota service

* Apply suggestions from code review
2022-11-08 10:25:34 +02:00
Ryan McKinley
e6a9fa1cf9
ServiceAccounts: enable service accounts after IsRealUser change (#58263)
* suppor service accounts

* add: IsServiceAccount to scheduleUser in scheduler

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>
2022-11-04 15:53:35 -04:00
Eric Leijonmarck
72d0c6b428
Auth: add IsServiceAccount to IsRealUser (#58015)
* add: IsServiceAccount to SignedInUser and IsRealUser

* fix: linting error

* refactor: add function IsServiceAccountUser()

By adding the function IsServiceAccountUser() we use it to identify for
ServiceAccounts in the HasUniqueID() since caching is built up on having
a uniqueID, see comment: https://github.com/grafana/grafana/pull/58015#discussion_r1011361880
2022-11-04 12:39:54 +00:00
Todd Treece
d45fe6e25c
Chore: Add NewAnonymousSignedInUser to user service (#57537) 2022-11-03 14:03:29 +01:00
idafurjes
50fb47dba0
Chore: Remove methods from sqlstore (#57545)
* Remove methods from sqlstore

* Remove commented out code

* Remove GetUserById from tests

* Adjust fake for get user profile

* Adjust test

* Adjust go mod files

* Try fix test

* Test adjustment

* Adjust test 2

* Remove commented out code
2022-10-27 11:44:09 +02:00
Karl Persson
d55e5b8862
[main] Login email before username (#57400)
* Swap order of login fields

* Validate email field before validating the username field.

Co-authored-by: linoman <2051016+linoman@users.noreply.github.com>
2022-10-21 15:21:21 +02:00