Sha256: c091083afdf30bb49c00e461a0534d0f57084175fe0e8110a8dc43da8d927bf6
Contents?: true
Size: 1.64 KB
Versions: 4
Compression:
Stored size: 1.64 KB
Contents
module ZuoraConnect class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authenticate_connect_app_request, except: [:ldap_login] after_action :persist_connect_app_session, except: [:ldap_login] skip_before_action :verify_authenticity_token, :only => [:ldap_login] def ldap_login if !ZuoraConnect::AppInstance::INTERNAL_HOSTS.include?(request.headers.fetch("HOST", nil)) render 'zuora_connect/application/ldap_login', locals: { title: 'Internal Auth Failure', message: 'Internal Auth Failure' }, :layout => false end require 'net-ldap' username = request.parameters['ldap_username'] password = request.parameters['ldap_password'] begin if ZuoraConnect::LDAP::Adapter.valid_credentials?(username, password) id = ZuoraConnect::AppInstance.first.id session["appInstance"] = ZuoraConnect::AppInstance.first.id session["#{id}::admin"] = true respond_to do |format| format.html { redirect_to '/admin/app_instances' } end else render 'zuora_connect/application/ldap_login', locals: { title: 'LDAP Authentication Failed', message: 'Invalid username or password' }, :layout => false end rescue Net::LDAP::Error render 'zuora_connect/application/ldap_login', locals: { title: 'LDAP Authentication Net Error', message: 'Failed to connect to server while authenticating the LDAP credentials. Please retry later.' }, :layout => false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems