Sha256: 26b9ae5c4c3476b389591c586e7ae6698472d922538e74e0dcf255639d1e5fd5

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

class Maestrano::Rails::SamlBaseController < ApplicationController
  attr_reader :saml_response, :user_auth_hash, :group_auth_hash, :user_group_rel_hash
  protect_from_forgery :except => [:consume]
  around_filter :saml_response_transaction, only: [:consume]
  
  # GET /maestrano/auth/saml/init/:tenant
  #
  # Initialize the SAML request and redirects the user to Maestrano
  def init
    redirect_to Maestrano::Saml::Request[params[:tenant]].new(params, session).redirect_url
  end
  
  #===================================
  # Helper methods
  #===================================
  def saml_response_transaction
    begin
      process_saml_response
      yield
      Maestrano::SSO.set_session(session,@user_auth_hash)
    rescue Exception => e
      if Rails.env.development?
        raise
      else
        logger.error e
        redirect_to "#{Maestrano::SSO.unauthorized_url}?err=internal"
      end
    end
  end
  
  def process_saml_response
    if params[:SAMLResponse]
      @saml_response = Maestrano::Saml::Response.new(params[:SAMLResponse])
      if @saml_response.validate!
        @user_auth_hash = Maestrano::SSO::BaseUser.new(@saml_response).to_hash
        @group_auth_hash = Maestrano::SSO::BaseGroup.new(@saml_response).to_hash
        @user_group_rel_hash = Maestrano::SSO::BaseMembership.new(@saml_response).to_hash
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
maestrano-rails-0.15.0 app/controllers/maestrano/rails/saml_base_controller.rb
maestrano-rails-0.14.0 app/controllers/maestrano/rails/saml_base_controller.rb
maestrano-rails-0.13.0 app/controllers/maestrano/rails/saml_base_controller.rb