Sha256: 42ef9d250af8bd0e1dc6de72b7d384304efb8c84d5a08cf5f5c30a5265afc5c2

Contents?: true

Size: 1.19 KB

Versions: 26

Compression:

Stored size: 1.19 KB

Contents

class Maestrano::Auth::SamlController < Maestrano::Rails::SamlBaseController
  #== POST '/maestrano/auth/saml/consume'
  # Final phase of the Single Sign-On handshake. Find or create
  # the required resources (user and group) and sign the user
  # in
  #
  # This action is left to you to customize based on your application
  # requirements. Below is presented a potential way of writing 
  # the action.
  #
  # Assuming you have enabled maestrano on a user model
  # called 'User' and a group model called 'Organization'
  # the action could be written the following way
  def consume
    params[:tenant] ||= 'default'
    user = Maestrano::Connector::Rails::User.find_or_create_for_maestrano(user_auth_hash, params[:tenant])
    organization = Maestrano::Connector::Rails::Organization.find_or_create_for_maestrano(group_auth_hash, params[:tenant])
    if user && organization
      unless organization.member?(user)
        organization.add_member(user)
      end

      session[:tenant] = params[:tenant]
      session[:uid] = user.uid
      session[:org_uid] = organization.uid
      session[:"role_#{organization.uid}"] = user_group_rel_hash[:role]
    end
    
    redirect_to main_app.root_path
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
maestrano-connector-rails-0.3.5 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.3.4 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.3.3 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.3.2 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.3.1 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.3.0 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.20 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.19 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.18 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.17 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.16 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.15 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.14 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.13 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.12 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.11 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.10 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.9 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.8 app/controllers/maestrano/auth/saml_controller.rb
maestrano-connector-rails-0.2.7 app/controllers/maestrano/auth/saml_controller.rb