Commit Graph

34 Commits

Author SHA1 Message Date
Mihai Doarna
12e4a94d63
SSO: Use removeSecrets() instead of setting.RedactedValue() (#88180)
* use removeSecrets() instead of setting.RedactedValue()

* replace with redacted value only if secret is not empty
2024-05-28 17:03:54 +03:00
Ieva
167151b211
Chore: Remove use of deprecated method in AC code (#87541)
* switch from using cfg to using featuremgmt for checking a feature toggle in AC code

* merge test fixes
2024-05-10 11:56:52 +01:00
Mihai Doarna
76d94b35c9
SSO: fix settings merge for SAML fields (#86970)
* fix sso settings merge for saml fields

* change func name
2024-04-30 15:10:27 +03:00
Mihai Doarna
4bf9405ce4
SSO: add SSO settings to secrets migrator (#86913)
* add sso settings to secrets migrator

* unify SSO settings in all log lines
2024-04-25 18:30:23 +03:00
Kristin Laemmert
9553923eb7
Chore: Fix failing ssosettingimpl test (#86792)
Chore: Fix failing ssosetting test
2024-04-23 11:36:34 -04:00
Mihai Doarna
bf15329492
SSO: run the validation on upsert with all secrets in settings (#86579)
* run the validation on upsert with all secrets in settings

* rename social to reloadable
2024-04-23 16:50:16 +03:00
Mihai Doarna
4d9e35ba57
SSO: add configurableProviders list to SSO service (#86622)
* add configurableProviders list to sso service

* address feedback
2024-04-23 10:00:43 +03:00
Mihai Doarna
57848bbe23
Auth: encrypt/decrypt SAML secrets in SSO settings service (#85253)
encrypt/decrypt saml secrets in sso settings service
2024-04-18 15:16:59 +03:00
Mihai Doarna
fad6dc4db1
SSO: fix reloading settings when a provider contains empty settings (#85102)
* fix reloading settings when a provider contains empty settings

* do not increment reloadFailures if settings are empty
2024-03-25 19:12:19 +02:00
linoman
fc205db466
samlsettings: api integration (#84300)
* add strategy and tests

* use settings provider service and remove multiple providers strategy

* Move SAML strategy to ssosettings service

* Update codeowners file

* reload from settings provider

* add saml as configurable provider

* Add new SAML strategy

* rename old saml settings interface

* update saml string references

* use OSS license

* validate saml provider depends on license for List

* add tests for list rendering including saml

* change the licensing validation to service init

* replace service struct for provider
2024-03-25 10:54:45 +01:00
Mihai Doarna
2acd48d1c2
SSO: fix mergeSettings() in case the DB contains empty URLs (#84290)
* fix mergeSettings() in case the db contains empty strings

* use correct github urls in test

* overwrite only urls

* update comment for mergeSettings()
2024-03-13 10:31:17 +02:00
Misi
b1dc505a2b
Auth: Validate admin assignment in SSO Settings (#82233)
* Add validation for allowAssignGrafanaAdmin

* Update default values

* Do not render hidden fields

* Change error message

* Improve tests

---------

Co-authored-by: Clarity-89 <homes89@ukr.net>
2024-02-09 13:10:23 +01:00
Diego Augusto Molina
a6342fa576
Chore: Fix data race within tests and enable a few parallel tests in ssosettingsimpl (#81837)
* Chore: Fix data race within tests of SSO Setting implementation

* Chore: fix data race within tests to allow parallel testing

* Chore: rollback changes runtime code to test a different approach

* Chore: Fix data race in SSO Setting implementation Upsert method

* Chore: fix typo in comment
2024-02-05 16:41:38 -03:00
Misi
7e96a2be56
Auth: Reload OAuth provider after deletion of the current settings (#81374)
* Reload after deletion of the current settings

* Add grafana_ssosettings_setting_reload_failure_total counter

* Returns successfully if data reload failed
2024-01-29 12:02:04 +01:00
Misi
c47b55ae10
Auth: Add SSO settings usage stats (#81143)
* Add usage stats

* UsageStats test + svc rename

* Fix test
2024-01-24 15:39:50 +01:00
Misi
8246d97587
Auth: Introduce configurable_providers config option for SSO settings (#80911)
* Add SSOSettingsConfigurableProviders config option

* Add check to Delete and ListWithRedactedSecrets

* Add check to GET, small improvements
2024-01-23 15:48:06 +01:00
Misi
20bb0a3ab1
AuthN: Support reloading SSO config after the sso settings have changed (#80734)
* Add AuthNSvc reload handling

* Working, need to add test

* Remove commented out code

* Add Reload implementation to connectors

* Align and add tests, refactor

* Add more tests, linting

* Add extra checks + tests to oauth client

* Clean up based on reviews

* Move config instantiation into newSocialBase

* Use specific error
2024-01-22 14:54:48 +01:00
colin-stuart
e241188f00
Auth: Implement the SSO Settings List endpoint (#80769)
* add list endpoint & initial tests

* add tests and ETag

* format service_test.go

* add list swagger param, generate openAPI, remove ETag, use RedactedPassword

* correct swagger param name

* Align tests to latest changes

* use setting.RedactedValue()

* add string assertion

* lint & require no error on res.Body.Close()

* add custom response type

---------

Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
2024-01-19 14:39:09 -05:00
Misi
da6926f6f7
Auth: SSOSettings handle secret update (#80591)
* first touches

* Merge missing SSO settings to support Advanced Auth pages

* fix

* Update secrets correctly

* Add test for upsert with redactedsecret

* Verify decryption in the List tests
2024-01-17 15:55:55 +02:00
Misi
c196bde2e0
Auth: Include missing SSO settings from system settings on read paths (#80421)
* first touches

* Merge missing SSO settings to support Advanced Auth pages

* fix
2024-01-12 15:20:50 +01:00
Mihai Doarna
39e4f8ec1b
Auth: configure SSO settings reload interval from the ini file (#80290)
* configure sso reload interval from ini file

* change section name to sso_settings
2024-01-12 10:24:16 +02:00
Mihai Doarna
772e5993b6
Auth: reload SSO settings for HA setups (#80231)
* reload SSO settings for HA setups

* remove check for grafana HA

* add unit tests

* fetch all sso settings with one sql query

* register background service
2024-01-10 16:01:37 +02:00
Ryan McKinley
1caaa56de0
FeatureFlags: Use interface rather than manager (#80000) 2024-01-09 10:38:06 -08:00
colin-stuart
062e772bb2
Auth: Implement the SSO Settings GET endpoint (#79144)
* Return data in camelCase from the OAuth fb strategy

* changes

* wip

* Add defaults for oauth fb strategy

* revert other changes

* basic includeDefaults query param implementation

* basic secret removal and etag implementation

* correct imports

* rebase

* move default settings filter to models

* only replace ClientSecret value if set

* first GetForProvider test & use FNV for ETag to avoid Blocklisted import error

* add tests

* add annotation for the openapi spec & generate spec

* remove TODO

* use IsSecret, improve tests, remove DefaultOAuthSettings

* add comment explaining generateFNVETag

* add error handling for generateFNVETag

* run go generate

* Update pkg/services/ssosettings/api/api.go

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

* move isSecret to service, create GetForProviderWithRedactedSecrets func

* add unit test for GetForProviderWithRedactedSecrets & remove duplicated code

* regen openapi/swagger

* revert dependency bumps

---------

Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
Co-authored-by: Mihai Doarna <mihai.doarna@grafana.com>
2024-01-08 09:35:14 -05:00
Mihai Doarna
359b118e6a
Auth: fix camelCase in getFallbackStrategyFor() func (#80061)
fix camelCase in getFallbackStrategyFor() func
2024-01-05 12:25:59 +02:00
Mihai Doarna
ade91e5038
Auth: Implement the SSO Settings update endpoint (#79676)
* merge with system settings before storing them in the db

* add base for validating sso settings

* add unit tests for sso settings validation

* call Reload() from sso service upsert()

* remove actual validation because it was moved in a separate pr

* use constant to fix lint error

* check if provider is configurable in service Upsert() method

* add unit tests for update provider settings api method

* fix lint error
2024-01-03 13:04:35 +02:00
Mihai Doarna
15d8a1f94d
Auth: Remove types from SSOSettings struct in SSO service (#79459)
* replace SSOSettings with SSOSettingsDTO

* fix database tests

* fix oauth strategy

* fix sso settings service tests

* add secrets encryption on update

* rename SSOSettingsDTO to SSOSettings

* remove extraKeys from strategy

* change back settings type from createOAuthConnector to OAuthInfo

* do not parse multi-value fields in oauth strategy
2023-12-15 16:00:52 +02:00
Misi
50f4e78a39
Auth: Use SSO settings service to load social connectors + refactor (#79005)
* Refactor to prevent cyclic dependencies

* Move list authorization to the API layer

* Init connectors using the SSO settings service in case the ssoSettingsApi feature toggle is enabled

* wip, need to handle the cyclic dep

* Remove cyclic dependency

* Align tests + refactor

* Move back OAuthInfo to social

* Delete pkg/login/social/constants

* Move reloadable registration to the social providers

* Rename connectors.Error to connectors.SocialError
2023-12-08 11:20:42 +01:00
Mihai Doarna
d7641b0ecb
Auth: encrypt secrets for oauth providers in SSO settings API service (#79081)
encrypt secrets for oauth providers
2023-12-06 14:37:10 +02:00
Misi
d3a269ab3b
Auth: Load ini/env vars settings in the fallback strategy (#78495)
* Return data in camelCase from the OAuth fb strategy

* changes

* wip

* Add defaults for oauth fb strategy

* revert other changes

* Add tests

* Add Defaults to cfg and use it in OAuthStrategy

* Return *OAuthInfo from OAuthStrategy

* lint

* Remove unnecessary Defaults

* Introduce const for fields, fix import order

* Align failing tests

* clean up

* Changes requested by @gamab

* Update pkg/services/ssosettings/strategies/oauth_strategy_test.go

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

* Load data on startup

* Rename + simplify

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2023-12-01 15:35:44 +01:00
Mihai Doarna
2e2b1cd9e4
Refactor SSOSettings to use types (#78675)
* refactor SSOSettings to use types

* test struct

* refactor SSOSettings struct to use types

* fix database tests

* fix populateSSOSettings() to accept an SSOSettings param

* fix all tests from the database layer

* handle errors for converting to/from SSOSettings

* add json tag on OAuthInfo fields

* use continue instead of if/else

* add the source field to SSOSettingsDTO conversion

* remove omitempty from json tags in OAuthInfo struct
2023-11-29 18:02:04 +02:00
Mihai Doarna
875ea092df
Add more unit tests for removeSSOSettings method (#78329)
* add more unit tests for remove sso settings

* add unit tests for the service method
2023-11-21 10:11:52 +02:00
Ryan McKinley
f69fd3726b
FeatureToggles: Add context and and an explicit global check (#78081) 2023-11-14 12:50:27 -08:00
Misi
5285e9503b
Auth: SSO settings foundations (#77724)
* inital changes, db migration

* changes

* Implement basic GetAll, Delete

* Add first batch of tests

* Add more tests

* Add service tests for GetForProvider, List

* Update http_server.go + wire.go

* Lint + update fixed role

* Update CODEOWNERS

* Change API init

* Change roles, rename

* Review with @kalleep

* Revert a mistakenly changed part

* Updates based on @dmihai 's feedback

---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2023-11-08 10:50:01 +01:00