3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00
Commit Graph

140 Commits

Author SHA1 Message Date
Karl Persson
8d9521fb6d
Refactor: Email verification ()
* Update template names

* Add verifier that we can use to start verify process

* Use userVerifier when verifying email on update

* Add tests
---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2024-03-14 13:25:28 +01:00
Xavi Lacasa
46c26bbd0b
Auth: Fix email verification bypass when using basic authentication () 2024-02-16 18:54:59 +01:00
linoman
ac84069071
Password policy ()
* add password service interface

* add password service implementation

* add tests for password service

* add password service wiring

* add feature toggle

* Rework from service interface to static function

* Replace previous password validations

* Add codeowners to password service

* add error logs

* update config files


---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2024-02-16 04:58:05 -06:00
Marcus Efraimsson
6768c6c059
Chore: Remove public vars in setting package ()
Removes the public variable setting.SecretKey plus some other ones. 
Introduces some new functions for creating setting.Cfg.
2024-01-23 12:36:22 +01:00
Dave Henderson
e0402115ea
Notifications: Optional trace propagation through SMTP ()
* Notifications: Optional trace propagation through SMTP

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* fix failing test

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* Add documentation

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
2024-01-22 10:50:05 -05:00
owensmallwood
d5b9602a79
Config: Can add static headers to email messages ()
* Can add allowed custom headers to an email Message. WIP.

* adds slug as a custom email header to all outgoing emails

* Headers are static - declared as key/value pairs in config. All static headers get added to emails.

* updates comment

* adds tests for parsing smtp static headers

* updates test to assert static headers are included when building email

* updates test to use multiple static headers

* updates test names

* fixes linting issue with error

* ignore gocyclo for loading config

* updates email headers in tests to be formatted properly

* add static headers first

* updates tests to assert that regular headers like From cant be overwritten

* ensures only the header is in a valid format for smtp and not the value

* updates comment and error message wording

* adds to docs and ini sample files

* updates smtp.static_headers docs examples formatting

* removes lines commented with semi colons

* prettier:write

* renames var
2023-12-14 12:59:43 -06:00
Ryan McKinley
025b2f3011
Chore: use any rather than interface{} () 2023-08-30 18:46:47 +03:00
Serge Zaitsev
b2ab57d14b
Chore: Remove result field from notifications ()
* remove result field from notifications

* fix test
2023-03-28 13:44:15 +02:00
Gilles De Mey
ed82f961dd
Email: Mark HTML comments as "safe" in email templates () 2023-03-28 13:05:21 +02:00
Michael Mandrus
8dab3bf36c
SMTP: Update email templates to include populated <title> tag ()
* add .TemplateData property to data in order to populate template <title> tags with the compiled subject value

* update all templates

* re-enable integration test and update implementation to check changes

* chore: fmt

* add HiddenSubject template func and update text templates

* slight performance improvement, only execute subject template once

* update template I missed

---------

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2023-01-30 16:56:23 -05:00
Serge Zaitsev
bc2813ef06
Chore: Fix goimports grouping in pkg/services ()
* fix goimports

* fix goimports order
2023-01-30 08:21:27 +00:00
Kristin Laemmert
f6e3252c00
chore: move notifications models into notifications service () 2023-01-17 14:47:31 -05:00
Michael Mandrus
9dc081e629
SMTP: Update SMTP TemplatesPatterns to do an 'or' filter instead of 'and' ()
update template path parsing to use 'or' logic instead of 'and'
2023-01-13 10:24:22 -05:00
idafurjes
d1c9b308bc
Chore: Move tempuser model to tempuser package ()
* Move tempuser model to tempuser package

* Add xorm tags for ID
2023-01-06 09:02:05 +01:00
idafurjes
325f7a789e
Chore: Delete duplicate models for user ()
* Delete duplicate models for user

* Use new models in some tests

* Add auth model conversion back
2023-01-03 15:25:35 +01:00
Gilles De Mey
ea27eca147
Email: Use MJML email templates ()
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-11-17 21:41:46 +01:00
Andreas Gerstmayr
8b22481aec
User management: Use HMAC-SHA256 to generate time limit codes (password reset tokens) ()
Signed-off-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: bergquist <carl.bergquist@gmail.com>
2022-08-18 16:01:09 +02:00
Jo
062d255124
Handle ioutil deprecations ()
* replace ioutil.ReadFile -> os.ReadFile

* replace ioutil.ReadAll -> io.ReadAll

* replace ioutil.TempFile -> os.CreateTemp

* replace ioutil.NopCloser -> io.NopCloser

* replace ioutil.WriteFile -> os.WriteFile

* replace ioutil.TempDir -> os.MkdirTemp

* replace ioutil.Discard -> io.Discard
2022-08-10 15:37:51 +02:00
Matthew Jacobson
efa0d90093
Alerting: Fix Teams notifier not failing on 200 response with error ()
Team's webhook API does not always use the status code to communicate errors.
There are cases where it returns 200 and an error message in the body.
For example, 429 - Too Many Requests or when the message is too large.
Instead, what we should be looking for is a response body = "1".

https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-messages-using-curl-and-powershell
2022-07-14 13:15:18 -04:00
idafurjes
6c43eb0b4d
Split Create User ()
* Split Create User

* Use new create user and User from package user

* Add service to wire

* Making create user work

* Replace user from user pkg

* One more

* Move Insert to orguser Service/Store

* Remove unnecessary conversion

* Cleaunp

* Fix Get User and add fakes

* Fixing get org id for user logic, adding fakes and other adjustments

* Add some tests for ourguser service and store

* Fix insert org logic

* Add comment about deprecation

* Fix after merge with main

* Move orguser service/store to org service/store

* Remove orguser from wire

* Unimplement new Create user and use User from pkg user

* Fix wire generation

* Fix lint

* Fix lint - use only User and CrateUserCommand from user pkg

* Remove User and CreateUserCommand from models

* Fix lint 2
2022-06-28 14:32:25 +02:00
Serge Zaitsev
ae9491c3a7
Chore: Make test tracer noop and return no errors () 2022-06-15 12:40:41 +02:00
Serge Zaitsev
0b55c41d05
Chore: Remove global bus variable ()
* Chore: Remove global bus variable

* fix bus in tests
2022-06-14 16:07:41 +02:00
Kat Yang
31630edf0c
Chore: Remove Wrapf ()
* Chore: Remove Wrapf

* Remove all Wrapf refs

* Remove last Wrapf ref

* Fix lint errors

* Remove Wrap and Wrapf definitions

* Remove unnecessary colon
2022-06-06 22:30:31 +02:00
Kristin Laemmert
bda3dd24e4
chore: remove golang.org/x/net/context in favor of stdlib ()
This PR removes golang.org context imports under pkg/services/* and replaces them with the stdlib context.

Closes 
2022-04-11 08:46:21 -04:00
Serge Zaitsev
18e93c7077
Chore: Remove bus ()
* Chore: Remove bus

* remove unused const
2022-04-08 16:15:06 +02:00
Santiago
4b1af6fb06
Fix empty contact point URLs when template parsing fails ()
* fix empty URLs

* leave URL templating, use fallback

* better fix, new tests cases

* fix linting errors
2022-03-31 15:57:48 -03:00
Serge Zaitsev
4ce7978cd8
Chore: Remove bus from notification service ()
* Chore: Remove bus from notification service

* fix signature

* fix function signature in tests
2022-03-22 09:04:30 +01:00
Alexander Weaver
703d7deeda
Alerting: Add integration tests for dual-stage email templating ()
* Resolve merge conflicts

* Remove cruft from local exploration

* Move integration tests to intercept using new abstraction layer instead of channel

* Fix linter error after rebase
2022-03-01 10:49:49 -06:00
Kat Yang
f582e6c86a
Chore: Remove bus from password ()
* Chore: Remove bus from password

* Refactor: Remove bus from password.go and adjust tests

* remove sqlstore dependency from notifications

* Chore: Remove bus from password

* Refactor: Remove bus from password.go and adjust tests

* remove sqlstore dependency (again)

* remove fmt printf

* fix dependencies in http server

* fix renamed method in tests

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
2022-02-03 10:33:46 +01:00
idafurjes
12420260ef
Remove bus from org invite api ()
* Remove bus from org invite api

* Fix lint

* Remove comment
2022-01-31 17:24:52 +01:00
Serge Zaitsev
84a5910e56
Chore: Remove bus from ngalert ()
* pass notification service down to the notifiers

* add ns to all notifiers

* remove bus from ngalert notifiers

* use smaller interfaces for notificationservice

* attempt to fix the tests

* remove unused struct field

* simplify notification service mock

* trying to resolve issues in the tests

* make linter happy

* make linter even happier

* linter, you are annoying
2022-01-26 16:42:40 +01:00
Alexander Weaver
c68eefd398
Alerting: Add abstraction layer and testing hooks in front of SMTP dialer ()
* Add abstraction layer above SMTP communication

* Fix issues with attachments and sync command

* Tests for bad SMTP behavior

* Separate tests between async and sync entry points. Test difference between them

* Return interface so Wire can properly map types

* Address feedback from George
2022-01-13 15:19:15 -06:00
idafurjes
65e60759fb
Rename AddEventListenerCtx to AddEventListener and PublishCtx to Publish () 2022-01-04 09:36:01 +01:00
idafurjes
8e6d6af744
Rename DispatchCtx to Dispatch () 2021-12-28 17:36:22 +01:00
idafurjes
7936c4c522
Rename AddHandlerCtx to AddHandler () 2021-12-28 16:08:07 +01:00
idafurjes
9880a843ed
Add context to notifications () 2021-12-01 17:56:08 +01:00
idafurjes
a65e0be110
Replace AddEventListener with AddEventListenerCtx and Publish with PublishCtx () 2021-11-29 14:23:24 +01:00
Katarina Yang
c4306f9b3e
Chore: add context to login ()
* Chore: add context to login attempt file and tests

* Chore: add context

* Chore: add context to login and login tests

* Chore: continue adding context to login

* Chore: add context to login query
2021-11-08 15:53:51 +01:00
Serge Zaitsev
125e284da2
Chore: Refactor GoConvey in notification service package ()
* refactor goconvey in notification service package

* avoid return after t.skip
2021-10-26 18:08:04 +02:00
Arve Knudsen
78596a6756
Migrate to Wire for dependency injection ()
Fixes 

Co-authored-by: dsotirakis <sotirakis.dim@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: spinillos <selenepinillos@gmail.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
2021-08-25 15:11:22 +02:00
Djairho Geuens
4cadbba686
Email: Allow configuration of content types for email notifications ()
* Alerting: Allow configuration of content types for email notifications

* Fix lint error

* Improves email templates

* Improve configuration documentation

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Improve code comments

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Improve configuration documentation

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Improve email template

* Remove unnecessary predeclaration

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Adds handling for unrecognized content type

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Move utility function outside of util package

* Fixes syntax

* Remove unused package

* Fix lint error

* improve email templates

* Fix test

* Alerting: Allow configuration of content types for email notifications

* Fix lint error

* Improves email templates

* Improve configuration documentation

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Improve code comments

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Improve configuration documentation

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Improve email template

* Remove unnecessary predeclaration

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Adds handling for unrecognized content type

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Move utility function outside of util package

* Fixes syntax

* Remove unused package

* Fix lint error

* improve email templates

* Fix test

* Fix comment style

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>

* Fix template formatting

* Add test and improve error handling

* Fix test

* Fix formatting

* Fix formatting

* Improve documentation and regenerates txt template

* Update docs/sources/administration/configuration.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: Djairho Geuens <djairho.geuens@ae.be>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2021-07-19 13:31:51 +03:00
Carl Bergquist
06dc2b24bf
dont consider invalid email address a failed email ()
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-05-04 12:07:50 +02:00
Carl Bergquist
58a325a4e4
Instrumentation: Add success rate metrics for email notifications ()
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-04-27 11:15:07 +02:00
Ganesh Vernekar
0b788b5ce8
AlertingNG: Notification channel for emails ()
* Email notification channel in ngalert

Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>

* Use existing templating system

Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>

* Update template and add unit tests

Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
2021-03-18 14:55:11 +00:00
Arve Knudsen
47f13abf7a
Backend: Migrate to using non-global configuration ()
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-03-10 12:41:29 +01:00
Arve Knudsen
c2cad26ca9
Chore: Disable default golangci-lint filter ()
* Disable default golangci-lint filter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix linter warnings

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-15 09:32:06 +01:00
Arve Knudsen
3fdf4be529
Chore: Enable more go-ruleguard rules ()
* Chore: Enable more go-ruleguard rules

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-14 15:51:59 +01:00
Arve Knudsen
ac09baae7d
Chore: Use Header.Set method instead of Header.Add ()
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-14 15:13:01 +01:00
taciomcosta
10ff4eecef
Backend: fix IPv6 address parsing erroneous ()
* Backend: Fix parsing of client IP address

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-25 07:55:22 +01:00
Will Browne
d796c61946
Security: Fixes minor security issue with alert notification webhooks that allowed GET & DELETE requests 2020-11-24 10:42:54 +01:00