Sha256: 4c5c9e30b2081b929bcdd556de48978b8ed52d68977b7560c1f83d809b5d9186

Contents?: true

Size: 704 Bytes

Versions: 8

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

require 'securerandom'
module Osso
  module Models
    class OauthClient < ActiveRecord::Base
      has_many :access_tokens
      has_many :refresh_tokens
      has_many :saml_providers
      has_many :redirect_uris

      before_validation :setup, on: :create
      validates :name, :secret, presence: true
      validates :identifier, presence: true, uniqueness: true

      def default_redirect_uri
        redirect_uris.find(&:primary)
      end

      def redirect_uri_values
        redirect_uris.map(&:uri)
      end

      private

      def setup
        self.identifier = SecureRandom.hex(16)
        self.secret = SecureRandom.hex(64)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
osso-0.0.3.4 lib/osso/models/oauth_client.rb
osso-0.0.3.3 lib/osso/models/oauth_client.rb
osso-0.0.3.2 lib/osso/models/oauth_client.rb
osso-0.0.3.1 lib/osso/models/oauth_client.rb
osso-0.0.3 lib/osso/models/oauth_client.rb
osso-0.0.2.10 lib/osso/models/oauth_client.rb
osso-0.0.2.9 lib/osso/models/oauth_client.rb
osso-0.0.2.8 lib/osso/models/oauth_client.rb