Sha256: fd2f43c813b5b197f6b7231f7fa4938a1b0a64f58bc5436575bdd519490ff976

Contents?: true

Size: 845 Bytes

Versions: 4

Compression:

Stored size: 845 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

4 entries across 4 versions & 1 rubygems

Version Path
olelo-0.9.3 plugins/authentication/portal.rb
olelo-0.9.2 plugins/authentication/portal.rb
olelo-0.9.1 plugins/security/portal.rb
olelo-0.9.0 plugins/security/portal.rb