Sha256: 17ff6ea3e97e50f340fca03fbbefb1a83378927b4b1456283681c303e8d252d9

Contents?: true

Size: 839 Bytes

Versions: 12

Compression:

Stored size: 839 Bytes

Contents

description 'Proprietary web portal based user storage'
require 'open-uri'
require 'openssl'

class PortalService < User::Service
  def initialize(config)
    @url = config[:url]
  end

  # @override
  def authenticate(name, password)
    xml = open(@url,
               ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE,
               http_basic_authentication: [name, password]).read
    # User data is exposed via REST/XML-API
    doc = Nokogiri::XML(xml)
    email = (doc/'person/email').text
    name = (doc/'person/user/name').text
    groups = (doc/'person/groups/group/name').to_a.map(&:text)
    raise AuthenticationError if name.blank?
    email = "#{name}@localhost" if email.blank?
    User.new(name, email, groups)
  rescue
    raise AuthenticationError, :wrong_user_or_pw.t
  end
end

User::Service.register :portal, PortalService

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
olelo-0.9.15 plugins/authentication/portal.rb
olelo-0.9.14 plugins/authentication/portal.rb
olelo-0.9.13 plugins/authentication/portal.rb
olelo-0.9.12 plugins/authentication/portal.rb
olelo-0.9.11 plugins/authentication/portal.rb
olelo-0.9.10 plugins/authentication/portal.rb
olelo-0.9.9 plugins/authentication/portal.rb
olelo-0.9.8 plugins/authentication/portal.rb
olelo-0.9.7 plugins/authentication/portal.rb
olelo-0.9.6 plugins/authentication/portal.rb
olelo-0.9.5 plugins/authentication/portal.rb
olelo-0.9.4 plugins/authentication/portal.rb