Class: GitHub::Ldap::MembershipValidators::Classic

Inherits:
Base
  • Object
show all
Defined in:
lib/github/ldap/membership_validators/classic.rb

Overview

Validates membership using ‘GitHub::Ldap::Domain#membership`.

This is a simple wrapper for existing functionality in order to expose it consistently with the new approach.

Instance Attribute Summary

Attributes inherited from Base

#groups, #ldap

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GitHub::Ldap::MembershipValidators::Base

Instance Method Details

#group_namesObject

Internal: the group names to look up membership for.

Returns an Array of String group names (CNs).



28
29
30
# File 'lib/github/ldap/membership_validators/classic.rb', line 28

def group_names
  @group_names ||= groups.map { |g| g[:cn].first }
end

#perform(entry) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/github/ldap/membership_validators/classic.rb', line 9

def perform(entry)
  # short circuit validation if there are no groups to check against
  return true if groups.empty?

  domains.each do |domain|
    membership = domain.membership(entry, group_names)

    if !membership.empty?
      entry[:groups] = membership
      return true
    end
  end

  false
end