Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/cloud_connector/service_access_token.rb')
-rw-r--r--app/models/cloud_connector/service_access_token.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/cloud_connector/service_access_token.rb b/app/models/cloud_connector/service_access_token.rb
new file mode 100644
index 00000000000..e026b10ec0c
--- /dev/null
+++ b/app/models/cloud_connector/service_access_token.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module CloudConnector
+ class ServiceAccessToken < ApplicationRecord
+ self.table_name = 'service_access_tokens'
+
+ scope :expired, -> { where('expires_at < :now', now: Time.current) }
+ scope :active, -> { where('expires_at > :now', now: Time.current) }
+
+ attr_encrypted :token,
+ mode: :per_attribute_iv,
+ key: Settings.attr_encrypted_db_key_base_32,
+ algorithm: 'aes-256-gcm',
+ encode: false,
+ encode_iv: false
+
+ validates :token, :expires_at, presence: true
+ end
+end