lib/osso/models/identity_provider.rb in osso-0.0.5.pre.gamma vs lib/osso/models/identity_provider.rb in osso-0.0.5.pre.iota
- old
+ new
@@ -4,14 +4,16 @@
module Models
# Base class for SAML Providers
class IdentityProvider < ActiveRecord::Base
belongs_to :enterprise_account
belongs_to :oauth_client
- has_many :users
+ has_many :users, dependent: :delete_all
before_save :set_status
validate :sso_cert_valid
+ enum status: { pending: "PENDING", configured: 'CONFIGURED', active: "ACTIVE", error: "ERROR"}
+
PEM_HEADER = "-----BEGIN CERTIFICATE-----\n"
PEM_FOOTER = "\n-----END CERTIFICATE-----"
def name
service.titlecase
@@ -36,21 +38,23 @@
].join('/')
end
alias acs_url assertion_consumer_service_url
- def set_status
- return if status != 'PENDING'
+ def acs_url_validator
+ Regexp.escape(acs_url)
+ end
- self.status = 'CONFIGURED' if sso_url && sso_cert
+ def set_status
+ self.status = 'configured' if sso_url && sso_cert && pending?
end
def active!
- update(status: 'ACTIVE')
+ update(status: 'active')
end
def error!
- update(status: 'ERROR')
+ update(status: 'error')
end
def root_url
return "https://#{ENV['HEROKU_APP_NAME']}.herokuapp.com" if ENV['HEROKU_APP_NAME']