module Decidim::Msad

Constants

DECIDIM_VERSION
VERSION

Public Class Methods

application_host() click to toggle source

Used to determine the default service provider entity ID in case not specifically set by the `sp_entity_id` configuration option.

# File lib/decidim/msad.rb, line 175
def self.application_host
  conf = Rails.application.config
  url_options = conf.action_controller.default_url_options
  url_options = conf.action_mailer.default_url_options if !url_options || !url_options[:host]
  url_options ||= {}

  # Note that at least Azure AD requires all callback URLs to be HTTPS, so
  # we'll default to that.
  host = url_options[:host]
  port = url_options[:port]
  protocol = url_options[:protocol]
  protocol = port.to_i == 80 ? "http" : "https" if protocol.blank?
  if host.blank?
    # Default to local development environment.
    host = "localhost"
    port ||= 3000
  end

  return "#{protocol}://#{host}:#{port}" if port && ![80, 443].include?(port.to_i)

  "#{protocol}://#{host}"
end
authenticator_for(organization, oauth_hash) click to toggle source
# File lib/decidim/msad.rb, line 136
def self.authenticator_for(organization, oauth_hash)
  authenticator_class.new(organization, oauth_hash)
end
certificate() click to toggle source
# File lib/decidim/msad.rb, line 146
def self.certificate
  return File.read(certificate_file) if certificate_file

  config.certificate
end
configure() click to toggle source
Calls superclass method
# File lib/decidim/msad.rb, line 131
def self.configure
  @configured = true
  super
end
configured?() click to toggle source
# File lib/decidim/msad.rb, line 127
def self.configured?
  @configured
end
omniauth_settings() click to toggle source
# File lib/decidim/msad.rb, line 158
def self.omniauth_settings
  {
    idp_metadata_url: idp_metadata_url,
    sp_entity_id: sp_entity_id,
    sp_name_qualifier: sp_entity_id,
    idp_slo_session_destroy: idp_slo_session_destroy,
    sp_metadata: sp_metadata,
    certificate: certificate,
    private_key: private_key,
    # Define the assertion and SLO URLs for the metadata.
    assertion_consumer_service_url: "#{application_host}/users/auth/msad/callback",
    single_logout_service_url: "#{application_host}/users/auth/msad/slo"
  }.merge(extra)
end
private_key() click to toggle source
# File lib/decidim/msad.rb, line 152
def self.private_key
  return File.read(private_key_file) if private_key_file

  config.private_key
end
sp_entity_id() click to toggle source
# File lib/decidim/msad.rb, line 140
def self.sp_entity_id
  return config.sp_entity_id if config.sp_entity_id

  "#{application_host}/users/auth/msad/metadata"
end