Initial commit

This commit is contained in:
zhongjin
2020-06-15 10:58:47 +08:00
commit 4f1dfe7564
8590 changed files with 1516878 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
require_dependency 'carto/controller_helper'
module Carto
class SamlController < ApplicationController
include Carto::ControllerHelper
ssl_required :metadata
before_filter :load_organization, :ensure_saml_enabled
rescue_from LoadError, UnauthorizedError, with: :rescue_from_carto_error
def metadata
render(xml: Carto::SamlService.new(@organization).saml_metadata)
end
private
def load_organization
@organization = Carto::Organization.where(name: CartoDB.extract_subdomain(request)).first
raise LoadError.new('Organization does not exist') unless @organization
end
def ensure_saml_enabled
raise UnauthorizedError.new('SAML not enabled') unless @organization.auth_saml_enabled?
end
end
end