Commit Graph

239 Commits

Author SHA1 Message Date
Misi
d411ce2664
Auth: Use sessionStorage instead of cookie for automatic redirection (#92759)
* WIP: working as expected, has to be tested

* Rename query param, small changes

* Remove unused code

* Address feedback

* Cleanup

* Use the feature toggle to control the behaviour

* Use the toggle on the FE too

* Prevent the extra redirect/reload

 Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com>

* Return to login if user is not authenticated

* Add tracking issue

* Align BE redirect constructor to locationSvc
2024-09-24 18:38:09 +02:00
Claudiu Dragalina-Paraipan
a8b07b0c81
[authn] use authlib client+interceptors for in-proc mode (#93124)
* Add authlib gRPC authenticators for in-proc mode

* implement `StaticRequester` signing in the unified resource client
- [x] when the `claims.AuthInfo` value type is `identity.StaticRequester`, and there's no ID token set, create an internal token and sign it with symmetrical key. This is a workaround for `go-jose` not offering the possibility to create an unsigned token.
- [x] update `IDClaimsWrapper` to support the scenario above
- [x] Switch to using `claims.From()` in `dashboardSqlAccess.SaveDashboard()`

---------

Co-authored-by: gamab <gabriel.mabille@grafana.com>
2024-09-24 09:03:48 +03:00
Gabriel MABILLE
7714b65f32
Cfg: Deduplicate DefaultOrgID code (#93588)
Cfg: Expose DefaultOrgID function
2024-09-23 16:50:11 +02:00
Gabriel MABILLE
7ef13497a8
AuthN: Ext JWT support actions (#92486) 2024-09-19 14:25:43 +02:00
Karl Persson
56487d37db
Authn: No longer hash service account token twice during authentication (#92598)
* APIKey: Only decode and hash token once during authentication

* Only update last used every 5 minutes
2024-08-29 09:56:23 +02:00
Charandas
4f024d94d8
Authn: resolve issues with setting up a nil identity (#92620) 2024-08-29 00:49:41 +03:00
Charandas
af2e79aa83
K8s: namespace mapper should use authlib's util (#92332) 2024-08-27 15:01:42 -07:00
Ryan McKinley
2e60f28044
Auth: remove id token flag (#92209) 2024-08-21 16:30:17 +03:00
Dan Cech
9020eb4b17
Auth: Update oauthtoken service to use remote cache and server lock (#90572)
* update oauthtoken service to use remote cache and server lock

* remove token cache

* retry is lock is held by an in-flight refresh

* refactor token renewal to avoid race condition

* re-add refresh token expiry cache, but in SyncOauthTokenHook

* Add delta to the cache ttl

* Fix merge

* Change lockTimeConfig

* Always set the token from within the server lock

* Improvements

* early return when user is not authed by OAuth or refresh is disabled

* Allow more time for token refresh, tracing

* Retry on Mysql Deadlock error 1213

* Update pkg/services/authn/authnimpl/sync/oauth_token_sync.go

Co-authored-by: Dan Cech <dcech@grafana.com>

* Update pkg/services/authn/authnimpl/sync/oauth_token_sync.go

Co-authored-by: Dan Cech <dcech@grafana.com>

* Add settings for configuring min wait time between retries

* Add docs for the new setting

* Clean up

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

---------

Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2024-08-19 18:57:37 +02:00
Karl Persson
5105fb7f3a
Identity: remove GetIDClaims (#91901)
remove GetIDClaims
2024-08-15 11:39:13 +02:00
Karl Persson
8bcd9c2594
Identity: Remove typed id (#91801)
* Refactor identity struct to store type in separate field

* Update ResolveIdentity to take string representation of typedID

* Add IsIdentityType to requester interface

* Use IsIdentityType from interface

* Remove usage of TypedID

* Remote typedID struct

* fix GetInternalID
2024-08-13 10:18:28 +02:00
Ryan McKinley
21d4a4f49e
Auth: use IdentityType from authlib (#91763) 2024-08-12 09:26:53 +03:00
Ryan McKinley
243c0935fc
Auth: Use claims.AuthInfo in requester (#91739) 2024-08-09 19:46:56 +03:00
Karl Persson
bcfb66b416
Identity: remove GetTypedID (#91745) 2024-08-09 18:20:24 +03:00
Claudiu Dragalina-Paraipan
e2435f92f1
[authn]: add GetIDClaims() to Requester (#91387)
* authn: add GetIDClaims() to Requester

Co-Authored-By: Gabriel MABILLE <gamab@users.noreply.github.com>

* authn: update StaticRequester

Co-Authored-By: Gabriel MABILLE <gamab@users.noreply.github.com>

* update auth/idtest/mock

Co-Authored-By: Gabriel MABILLE <gamab@users.noreply.github.com>

* Fix test

Co-authored-by: Claudiu Dragalina-Paraipan <claudiu.dragalina@grafana.com>

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: gamab <gabriel.mabille@grafana.com>
2024-08-02 12:36:02 +03:00
Charandas
a3d3f9a1e4
Revert "Identity: Remove id token from extra info (#91169)" (#91350)
This reverts commit 10170cb839.
2024-07-31 21:27:46 +03:00
Ryan McKinley
10170cb839
Identity: Remove id token from extra info (#91169) 2024-07-31 09:14:13 +03:00
Vardan Torosyan
e20f8c566d
RBAC sync: Fix removal of roles which need to be added (#91152)
* RBAC sync: Fix removal of roles which need to be added

* Optimize code

* cleanup: appease the linter

---------

Co-authored-by: Victor Cinaglia <victor@grafana.com>
2024-07-30 09:00:47 +02:00
Ryan McKinley
728150bdbd
Identity: extend k8s user.Info (#90937) 2024-07-30 08:27:23 +03:00
Ryan McKinley
9db3bc926e
Identity: Rename "namespace" to "type" in the requester interface (#90567) 2024-07-25 12:52:14 +03:00
Vardan Torosyan
82236976ae
Add support ticket fixed roles to cloud role sync (#90864)
* Add support ticket fixed roles to cloud role sync

* Adding tests

* Fix the linter
2024-07-24 17:58:21 +02:00
Charandas
4abb4d1662
ExtJwt: don't log verify errors as they spam for grafana-agent (#90351)
* ExtJwt: don't log verify errors as they spam for grafana-agent

* remove dead code

* revert unintended change

* revert unintended change
2024-07-11 18:23:43 -07:00
Mihai Doarna
bbd1611265
SSO: Register LDAP service if LDAP is enabled in SSO settings (#90228)
register LDAP service if LDAP is enabled in SSO settings
2024-07-11 13:53:43 +03:00
Charandas
c210617735
K8s: use contexthandler in standalone handler chain (#90102) 2024-07-08 12:22:10 -07:00
Karl Persson
7a78ad3893
Authn: Remove response writer from auth req (#90110)
Authn: Remove response writer from request
2024-07-05 11:42:12 +02:00
Misi
f337da8e57
Chore: Add more context to logs of OAuthToken and OAuthTokenSync (#90071)
Chore: Add more context to oauth token sync
2024-07-05 09:37:36 +02:00
Jeff Levin
cfe8317d45
Add auth spans and remove deduplication code for scopes (#89804)
Adds more spans for timing in accesscontrol and remove permission deduplicating code after benchmarking

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2024-07-02 22:08:57 -08:00
Jeff Levin
ed13959e33
Optimize memory allocations in permissions cache (#89645)
This PR reduces the number of allocations made while caching permissions from the database, fixes the hierarchy of spans and adds new spans for tracing.

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
2024-06-26 23:03:13 +03:00
Karl Persson
7f4faaa45b
ExtJWT: Remove test (#89665)
Remove test
2024-06-26 17:25:26 +02:00
Ryan McKinley
99d8025829
Chore: Move identity and errutil to apimachinery module (#89116) 2024-06-13 07:11:35 +03:00
Misi
2e811c5438
Chore: Use OrgRoleMapper in Grafana.com client (#89013)
* Use OrgRoleMapper in Grafana.com client

* Clean up
2024-06-11 14:53:05 +02:00
Misi
9a44296bc2
Auth: Add org to role mappings support to AzureAD/Entra integration (#88861)
* Added implementation and tests

* Add docs, simplify implementation

* Remove unused func

* Update docs
2024-06-10 12:08:30 +02:00
Karl Persson
f3efd95bb4
Auth: Add org to role mappings support to Google integration (#88891)
* Auth: Implement org role mapping for google oauth provider

* Update docs

* Remove unused function

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
2024-06-07 14:07:35 +02:00
Misi
4f2a9a47f3
Auth: Add org to role mappings support to Okta integration (#88770)
* Add org mapping support to Okta

* Update docs and configs

* Prettier docs

* Apply suggestions from code review

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

* Improve tests

---------

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2024-06-06 10:35:06 +02:00
Karl Persson
f28905f8c4
Auth: Add org to role mappings support to Gitlab integration (#88751)
* Conf: Add org_mapping and org_attribute_path to github and gitlab conf

* Gitlab: Implement org role mapping

* Update docs
---------

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2024-06-05 16:15:53 +02:00
Misi
eacf6e0a4d
Auth: Add org to role mappings support to GitHub integration (#88537)
* wip: add extra tests for verifying current logic

* Add OrgRole mapping and tests

* Update docs

* Clean up

* Update docs/sources/setup-grafana/configure-security/configure-authentication/github/index.md

Co-authored-by: Mihai Doarna <mihai.doarna@grafana.com>

* Update docs with None role

* Apply suggestions from code review

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>

* Fix

* Prettier docs

* Cleanup tests

---------

Co-authored-by: Mihai Doarna <mihai.doarna@grafana.com>
Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
2024-06-03 14:24:58 +02:00
Misi
ed6b3e9e7c
Auth: Introduce pre-logout hooks + add GCOM LogoutHook (#88475)
* Introduce preLogoutHooks in authn service

* Add gcom_logout_hook

* Config the api token from the Grafana config file

* Simplify

* Add tests for logout hook

* Clean up

* Update

* Address PR comment

* Fix
2024-05-30 15:52:16 +02:00
Carl Bergquist
6c79f63c04
Auth: Pass ctx when updating last seen (#88496)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2024-05-30 14:25:54 +02:00
Mathieu Parent
b8c9ae0eb7
OIDC: Support Generic OAuth org to role mappings (#87394)
* Social: link to OrgRoleMapper

* OIDC: support Generic Oauth org to role mappings

Fixes: #73448
Signed-off-by: Mathieu Parent <math.parent@gmail.com>

* Handle when getAllOrgs fails in the org_role_mapper

* Add more tests

* OIDC: ensure orgs are evaluated from API when not from token

Signed-off-by: Mathieu Parent <math.parent@gmail.com>

* OIDC: ensure AutoAssignOrg is applied with OrgMapping without RoleAttributeStrict

Signed-off-by: Mathieu Parent <math.parent@gmail.com>

* Extend docs

* Fix test, lint

---------

Signed-off-by: Mathieu Parent <math.parent@gmail.com>
Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
2024-05-23 09:55:45 +02:00
Kristin Laemmert
16b1e285ea
Chore: Use cache for all signed in user lookups (#88133)
* GetSignedInUser unexported (renamed to getSignedInUser)
* GetSignedInUserWithCacheCtx renamed to GetSignedInUser
* added a check for a nil cacheservice (as defensive programming / test convenience)
2024-05-22 08:58:16 -04:00
Karl Persson
78d1b2a250
Authn: Share key retriever between id and access token verifiers (#87978) 2024-05-20 09:13:46 +02:00
Karl Persson
5c27f223af
Authn: Support access token wildcard namespace (#87816)
* Authn+ExtJWT: allow wildcard namespace for access tokens and restructure validation
2024-05-16 10:47:20 +02:00
Karl Persson
9977258d04
AuthN: Set uid during authentication (#87797)
* Identity: Remove GetNamespacedUID and use GetUID instead

* Authn: Set uid for users and service accounts
2024-05-14 14:13:50 +02:00
Karl Persson
0f3080ecb8
AuthN: Fix signout redirect url (#87631)
* Add missing return

* Use sign out redirect url from auth config if configured

* remove option from auth.jwt that is not used
2024-05-12 19:53:19 +02:00
Karl Persson
be5ced4287
Identity: Use typed version of namespace id (#87257)
* Remove different constructors and only use NewNamespaceID

* AdminUser: check typed namespace id

* Identity: Add convinient function to parse valid user id when type is either user or service account

* Annotations: Use typed namespace id instead
2024-05-08 14:03:53 +02:00
Charandas
a9da6ce1d5
ext_jwt: streamline expected aud in access tokens and id tokens (#87401) 2024-05-07 11:20:16 -07:00
Dan Cech
41bee274fd
Chore: Fix error handling in postDashboard, remove UserDisplayDTO, fix live redis client initialization (#87206)
* clean up error handling in postDashboard and remove UserDisplayDTO

* replace GetUserUID with GetUID and GetNamespacedUID, enforce namespace constant type

* lint fix

* lint fix

* more lint fixes
2024-05-06 14:17:34 -04:00
Charandas
0c59baf62d
ext_jwt: switch to new authlib (#87157) 2024-05-03 12:59:37 -07:00
Gabriel MABILLE
8802282ebc
RBAC: fix panic role not found permission sync (#87217) 2024-05-02 15:19:56 +02:00
Karl Persson
d8fbbdefea
Identity: Use typed namespace id (#87121)
* Use typed namespace id
2024-05-02 14:50:56 +02:00