Sha256: f8ae02f97534bdba0d15fa57249ed798212d544a692ca88471f86c1e6a39fee8

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Osso
  module Models
    # Base class for SAML Providers
    class IdentityProvider < ActiveRecord::Base
      NAME_FORMAT = 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
      belongs_to :enterprise_account
      belongs_to :oauth_client
      has_many :users

      before_create :create_enterprise_account

      # def name
      #   raise(
      #     NoMethodError,
      #     '#name must be defined on each provider specific subclass',
      #   )
      # end

      # def saml_options
      #   raise(
      #     NoMethodError,
      #     '#saml_options must be defined on each provider specific subclass',
      #   )
      # end

      def assertion_consumer_service_url
        [
          ENV.fetch('BASE_URL'),
          'auth',
          'saml',
          id,
          'callback',
        ].join('/')
      end

      alias acs_url assertion_consumer_service_url

      def create_enterprise_account
        return if enterprise_account_id

        self.enterprise_account = Models::EnterpriseAccount.create(
          domain: domain,
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
osso-0.0.3.8 lib/osso/models/saml_provider.rb
osso-0.0.3.7 lib/osso/models/saml_provider.rb
osso-0.0.3.6 lib/osso/models/saml_provider.rb