Add error tracking client key
What does this MR do?
Adds error tracking client key that is required by sentry sdk. Check public key is valid in collector.
Key points:
- We are building sentry compatible backend.
- We pass URL to sentry sdk. This URL is called DSN. DSN contains hash known as public key.
- Sentry sdk will call our API every time exception is triggered. It will pass the public key in header.
- To do some basic protection against abuse, we check if public key is valid.
This merge request is part of a bigger plan. Issue => #329596 (closed)
To read more about sentry DSN => https://docs.sentry.io/product/sentry-basics/dsn-explainer
Collector was implemented in !65767 (merged). This MR adds is somewhat a follow-up to it.
FYI: The feature is behind a feature flag while its in active development stage.
Database
The table will contain client keys for those of projects that have error tracking feature enabled (disabled by default). Usually it will be only 1-2 keys per project.
rake db:migrate
== 20210720130006 CreateErrorTrackingClientKeys: migrating ====================
-- create_table(:error_tracking_client_keys, {})
-- quote_column_name(:public_key)
-> 0.0000s
-> 0.0083s
-- quote_table_name("check_840b719790")
-> 0.0000s
-- quote_table_name(:error_tracking_client_keys)
-> 0.0000s
-- execute("ALTER TABLE \"error_tracking_client_keys\"\nADD CONSTRAINT \"check_840b719790\" CHECK (char_length(\"public_key\") <= 255)\n")
-> 0.0006s
== 20210720130006 CreateErrorTrackingClientKeys: migrated (0.0156s) ===========
rake db:rollback
== 20210720130006 CreateErrorTrackingClientKeys: reverting ====================
-- drop_table(:error_tracking_client_keys)
-> 0.0060s
== 20210720130006 CreateErrorTrackingClientKeys: reverted (0.0060s) ===========
Security
- This merge request stores
public_key
token in database as plain text => !66466 (comment 632113638) - This MR checks
public_key
from auth headers against one stored in database => !66466 (comment 632114618) - Because auth mechanism is easily exposed, we limit its use only to submission of new events. We don't return any information. Its basically spam protection, rather than auth.
Screenshots or Screencasts (strongly suggested)
No UI changes
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team