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

service_access_token.rb « ai « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 46dfbe9078ca7709420fa8c75ddcf6b691037714 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module Ai
  class ServiceAccessToken < ApplicationRecord
    include IgnorableColumns
    self.table_name = 'service_access_tokens'

    ignore_column :category, remove_with: '16.8', remove_after: '2024-01-22'

    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