Skip to content

Add content validation endpoint

What does this MR do and why?

In JH we need to integrate with the Content Validation Service, here add a configurable content validation API endpoint.

This MR:

  • Add content_validation_endpoint_enabled to allow admin enable content validation feature
  • Add a configurable content_validation_endpoint_url that must be a valid URL to application settings
  • Add encrypted_content_validation_api_key and encrypted_content_validation_api_key_iv so that Content Validation can be provided a token which it can use to authenticate its requests

See related JH epic

gitlab-jh/-/epics/5273

See related JH issue

gitlab-jh/gitlab#248

See related JH Merge request

gitlab-jh/gitlab!135 (merged)

Database migration output

$ bundle exec rake db:migrate:up VERSION=20211013014228                                           
== 20211013014228 AddContentValidationEndpointToApplicationSettings: migrating
-- add_column(:application_settings, :content_validation_endpoint_url, :text, {:comment=>"JiHu-specific column"})
   -> 0.0041s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0003s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE application_settings\nADD CONSTRAINT check_5a84c3ffdc\nCHECK ( char_length(content_validation_endpoint_url) <= 255 )\nNOT VALID;\n")
   -> 0.0019s
-- current_schema()
   -> 0.0001s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- execute("ALTER TABLE application_settings VALIDATE CONSTRAINT check_5a84c3ffdc;")
   -> 0.0008s
-- execute("RESET statement_timeout")
   -> 0.0002s
-- add_column(:application_settings, :encrypted_content_validation_api_key, :binary, {:comment=>"JiHu-specific column"})
   -> 0.0011s
-- add_column(:application_settings, :encrypted_content_validation_api_key_iv, :binary, {:comment=>"JiHu-specific column"})
   -> 0.0012s
-- add_column(:application_settings, :content_validation_endpoint_enabled, :boolean, {:null=>false, :default=>false, :comment=>"JiHu-specific column"})
   -> 0.0041s
== 20211013014228 AddContentValidationEndpointToApplicationSettings: migrated (0.0244s)
$ bundle exec rake db:migrate:down VERSION=20211013014228
== 20211013014228 AddContentValidationEndpointToApplicationSettings: reverting
-- remove_column(:application_settings, :content_validation_endpoint_url)
   -> 0.0074s
-- remove_column(:application_settings, :encrypted_content_validation_api_key)
   -> 0.0026s
-- remove_column(:application_settings, :encrypted_content_validation_api_key_iv)
   -> 0.0025s
-- remove_column(:application_settings, :content_validation_endpoint_enabled)
   -> 0.0018s
== 20211013014228 AddContentValidationEndpointToApplicationSettings: reverted (0.0121s)
Edited by Dave Liu

Merge request reports