renamed MatchedMembership#member_of to #has_member - that's what it means
This commit is contained in:
parent
47d5b9862e
commit
2cc2b39863
@ -193,15 +193,15 @@ class Application
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
MatchedMembership = Struct.new :role_name, :member_of, :state
|
MatchedMembership = Struct.new :role_name, :has_member, :state
|
||||||
|
|
||||||
def match_memberships(ldap_roles, pg_roles)
|
def match_memberships(ldap_roles, pg_roles)
|
||||||
ldap_by_dn = ldap_roles.inject({}){|h,r| h[r.dn] = r; h }
|
ldap_by_dn = ldap_roles.inject({}){|h,r| h[r.dn] = r; h }
|
||||||
ldap_by_m2m = ldap_roles.inject([]){|a,r|
|
ldap_by_m2m = ldap_roles.inject([]){|a,r|
|
||||||
next a unless r.member_dns
|
next a unless r.member_dns
|
||||||
a + r.member_dns.map{|dn|
|
a + r.member_dns.map{|dn|
|
||||||
if member_of=ldap_by_dn[dn]
|
if has_member=ldap_by_dn[dn]
|
||||||
[r.name, member_of.name]
|
[r.name, has_member.name]
|
||||||
else
|
else
|
||||||
log.warn{"ldap member with dn #{dn} is unknown"}
|
log.warn{"ldap member with dn #{dn} is unknown"}
|
||||||
nil
|
nil
|
||||||
@ -213,11 +213,11 @@ class Application
|
|||||||
pg_by_m2m = pg_roles.inject([]){|a,r|
|
pg_by_m2m = pg_roles.inject([]){|a,r|
|
||||||
next a unless r.member_names
|
next a unless r.member_names
|
||||||
a + r.member_names.map{|name|
|
a + r.member_names.map{|name|
|
||||||
member_of = pg_by_name[name]
|
has_member = pg_by_name[name]
|
||||||
unless member_of
|
unless has_member
|
||||||
log.warn{"pg member with name #{name} is unknown"}
|
log.warn{"pg member with name #{name} is unknown"}
|
||||||
end
|
end
|
||||||
[r.name, member_of.name]
|
[r.name, has_member.name]
|
||||||
}.compact
|
}.compact
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ class Application
|
|||||||
|
|
||||||
log.info{
|
log.info{
|
||||||
memberships.each do |membership|
|
memberships.each do |membership|
|
||||||
log.debug{ "#{membership.state} #{membership.role_name} to #{membership.member_of}" }
|
log.debug{ "#{membership.state} #{membership.role_name} to #{membership.has_member}" }
|
||||||
end
|
end
|
||||||
"membership stat: grant: #{memberships.count{|u| u.state==:grant }} revoke: #{memberships.count{|u| u.state==:revoke }} keep: #{memberships.count{|u| u.state==:keep }}"
|
"membership stat: grant: #{memberships.count{|u| u.state==:grant }} revoke: #{memberships.count{|u| u.state==:revoke }} keep: #{memberships.count{|u| u.state==:keep }}"
|
||||||
}
|
}
|
||||||
@ -249,12 +249,12 @@ class Application
|
|||||||
grants = {}
|
grants = {}
|
||||||
memberships.select{|ms| ms.state==:grant }.each do |ms|
|
memberships.select{|ms| ms.state==:grant }.each do |ms|
|
||||||
grants[ms.role_name] ||= []
|
grants[ms.role_name] ||= []
|
||||||
grants[ms.role_name] << ms.member_of
|
grants[ms.role_name] << ms.has_member
|
||||||
end
|
end
|
||||||
revokes = {}
|
revokes = {}
|
||||||
memberships.select{|ms| ms.state==:revoke }.each do |ms|
|
memberships.select{|ms| ms.state==:revoke }.each do |ms|
|
||||||
revokes[ms.role_name] ||= []
|
revokes[ms.role_name] ||= []
|
||||||
revokes[ms.role_name] << ms.member_of
|
revokes[ms.role_name] << ms.has_member
|
||||||
end
|
end
|
||||||
|
|
||||||
grants.each{|role_name, members| grant_membership(role_name, members) }
|
grants.each{|role_name, members| grant_membership(role_name, members) }
|
||||||
|
Reference in New Issue
Block a user