ldap_tools 0.9.2 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea0fa0ebe1c98580e3e623f810c1b036c5002ff9
4
- data.tar.gz: 6e56df2eb8f7caed546bfec945cb070c162d2b99
3
+ metadata.gz: a013f47e3c9fccb1ff3aafeee6ed84d8c0677c86
4
+ data.tar.gz: 1db37492ec187835d08b88462140ac9d930c590f
5
5
  SHA512:
6
- metadata.gz: 98bb0f41e0ec6df27863a2d4917a28e6d24cd7d4bc7c7966e9375decf4c1b4e7c9760c9d6431127b10238593f96581a454727129329530c26f402da980fca62d
7
- data.tar.gz: 3108815f8a5ec38c43917a7b0111f255aeb83c068d42e30dace52d59a40126586fd81edcd9a36716520f3515e1360b2acaf784db7581d9eb2921c59846444343
6
+ metadata.gz: db759742e4443fbec435dc701377ad505746ce92426255583f7e393079dd9d37ec7084087daabecb969bf2bf64c3c1c3d276c8271bca7a5651a9fa9bc93e4e0a
7
+ data.tar.gz: 016170fd1a601da4e120be647c9051377a052ebd24c7b38ae6b691864f07412ea608dd8ec84a76cd8c014be36c00669fe3d88db3f9ef6690adfa749eeb43589b
@@ -7,7 +7,7 @@ module Tapjoy
7
7
  SUB_COMMANDS = %w(by_user by_group raw)
8
8
 
9
9
  def commands
10
- Trollop.options do
10
+ Optimist.options do
11
11
  usage 'user [SUB_COMMAND] [options]'
12
12
  synopsis "\nThis object is used for auditing LDAP permissions\nAvailable subcommands are: #{SUB_COMMANDS}"
13
13
 
@@ -12,7 +12,7 @@ module Tapjoy
12
12
  private
13
13
 
14
14
  def opts
15
- @opts ||= Trollop.options do
15
+ @opts ||= Optimist.options do
16
16
  # Set help message
17
17
  usage 'group add_user [options]'
18
18
  synopsis "\nThis command is for adding existing users to existing groups"
@@ -6,13 +6,13 @@ module Tapjoy
6
6
  class Create
7
7
  def create
8
8
  # Check for errors
9
- Trollop.die :type, "argument must be 'user' or 'service'" unless ['user', 'service'].include?(opts[:type])
9
+ Optimist.die :type, "argument must be 'user' or 'service'" unless ['user', 'service'].include?(opts[:type])
10
10
 
11
11
  puts Tapjoy::LDAP::API::Group.create(opts[:name], opts[:type])
12
12
  end
13
13
 
14
14
  private def opts
15
- @opts ||= Trollop.options do
15
+ @opts ||= Optimist.options do
16
16
  # Set help message
17
17
  usage 'group create [options]'
18
18
  synopsis "\nThis command is for creating new LDAP groups"
@@ -12,7 +12,7 @@ module Tapjoy
12
12
  private
13
13
 
14
14
  def opts
15
- @opts ||= Trollop.options do
15
+ @opts ||= Optimist.options do
16
16
  # Set help message
17
17
  usage 'group delete [options]'
18
18
  synopsis "\nThis command is for deleting LDAP groups"
@@ -13,7 +13,7 @@ module Tapjoy
13
13
  private
14
14
 
15
15
  def opts
16
- @opts ||= Trollop.options do
16
+ @opts ||= Optimist.options do
17
17
  # Set help message
18
18
  usage 'group remove_user [options]'
19
19
  synopsis "\nThis command is for removing existing users from existing groups"
@@ -15,7 +15,7 @@ module Tapjoy
15
15
  SUB_COMMANDS = %w(create delete add_user remove_user)
16
16
 
17
17
  def commands
18
- Trollop.options do
18
+ Optimist.options do
19
19
  usage 'group [SUB_COMMAND] [options]'
20
20
  synopsis "\nThis object is used for group management\nAvailable subcommands are: #{SUB_COMMANDS}"
21
21
 
@@ -8,22 +8,22 @@ module Tapjoy
8
8
  # Make the API call to create an LDAP user
9
9
  def create
10
10
  verify_arguments
11
- fname, lname = opts[:user]
11
+ fname, lname = opts[:name]
12
12
  puts Tapjoy::LDAP::API::User.create(fname, lname,
13
13
  opts[:type], opts[:group])
14
14
  end
15
15
 
16
16
  private
17
17
  def opts
18
- @opts ||= Trollop.options do
18
+ @opts ||= Optimist.options do
19
19
  # Set help message
20
20
  usage 'user create [options]'
21
21
  synopsis "\nThis command is for creating new LDAP users"
22
22
 
23
- # Username is two arguments
24
- # Trollop will accept more, but we will only parse two later
23
+ # Name is two arguments
24
+ # Optimist will accept more, but we will only parse two later
25
25
  # TODO: support given names that include a space
26
- opt :user, "Specify user's first and last name", type: :strings, required: true
26
+ opt :name, "Specify user's first and last name", type: :strings, required: true
27
27
 
28
28
  # Groupname is a single string, for primary group setting
29
29
  opt :group, 'Specify name of primary group', type: :string, required: true
@@ -32,8 +32,8 @@ module Tapjoy
32
32
  end
33
33
 
34
34
  def verify_arguments
35
- Trollop.die :user, 'argument count must be two' if opts[:user].size != 2
36
- Trollop.die :type, "argument must be 'user' or 'service'" unless %w(user service).include?(opts[:type])
35
+ Optimist.die :name, 'argument count must be two' if opts[:name].size != 2
36
+ Optimist.die :type, "argument must be 'user' or 'service'" unless %w(user service).include?(opts[:type])
37
37
  end
38
38
  end
39
39
  end
@@ -9,30 +9,30 @@ module Tapjoy
9
9
  def delete
10
10
  verify_arguments
11
11
  confirm unless opts[:force]
12
- puts Tapjoy::LDAP::API::User.destroy(opts[:user], opts[:type])
12
+ puts Tapjoy::LDAP::API::User.destroy(opts[:username], opts[:type])
13
13
  end
14
14
 
15
15
  private
16
16
  def opts
17
- @opts ||= Trollop.options do
17
+ @opts ||= Optimist.options do
18
18
  # Set help message
19
19
  usage "user delete [options]"
20
20
 
21
- opt :user, 'Specify username', type: :string, required: true
21
+ opt :username, 'Specify username', type: :string, required: true
22
22
  opt :force, 'Force delete'
23
23
  opt :type, 'Specfy if this is a user or service account', type: :string, default: 'user'
24
24
  end
25
25
  end
26
26
 
27
27
  def confirm
28
- puts "Confirm that you want to delete user: #{opts[:user]} (yes/no)"
28
+ puts "Confirm that you want to delete user: #{opts[:username]} (yes/no)"
29
29
  print '>'
30
30
  confirm = STDIN.gets.chomp.downcase
31
- abort("Deletion of #{opts[:user]} aborted") unless confirm.start_with?('y')
31
+ abort("Deletion of #{opts[:username]} aborted") unless confirm.start_with?('y')
32
32
  end
33
33
 
34
34
  def verify_arguments
35
- Trollop.die :type, "argument must be 'user' or 'service'" unless %w(user service).include?(opts[:type])
35
+ Optimist.die :type, "argument must be 'user' or 'service'" unless %w(user service).include?(opts[:type])
36
36
  end
37
37
  end
38
38
  end
@@ -7,7 +7,7 @@ module Tapjoy
7
7
  class Show
8
8
  # Make the API call to show an LDAP user
9
9
  def show
10
- Tapjoy::LDAP::API::User.show(opts[:user]).each do |entry|
10
+ Tapjoy::LDAP::API::User.show(opts[:username]).each do |entry|
11
11
  puts "DN: #{entry.dn}"
12
12
  entry.each do |attribute, values|
13
13
  puts " #{attribute}:"
@@ -20,11 +20,11 @@ module Tapjoy
20
20
 
21
21
  private
22
22
  def opts
23
- @opts ||= Trollop.options do
23
+ @opts ||= Optimist.options do
24
24
  # Set help message
25
25
  usage "user show [options]"
26
26
 
27
- opt :user, 'Specify username', type: :string, required: true
27
+ opt :username, 'Specify username', type: :string, required: true
28
28
  end
29
29
  end
30
30
  end
@@ -11,7 +11,7 @@ module Tapjoy
11
11
  SUB_COMMANDS = %w(create delete index show)
12
12
 
13
13
  def commands
14
- Trollop.options do
14
+ Optimist.options do
15
15
  usage 'user [SUB_COMMAND] [options]'
16
16
  synopsis "\nThis object is used for user management\nAvailable subcommands are: #{SUB_COMMANDS}"
17
17
 
@@ -7,7 +7,7 @@ module Tapjoy
7
7
  class << self
8
8
  def commands
9
9
  subcommand = %w(user group key audit)
10
- Trollop.options do
10
+ Optimist.options do
11
11
  usage '[SUB_COMMAND] [options]'
12
12
  synopsis "\nTool to manage LDAP resources.\nAvailable subcommands are: #{subcommand}"
13
13
  version "#{File.basename($PROGRAM_NAME)} #{Tapjoy::LDAP::VERSION} \u00A9 2015 Tapjoy, Inc."
@@ -15,12 +15,12 @@ module Tapjoy
15
15
 
16
16
  private
17
17
  def opts
18
- @opts ||= Trollop.options do
18
+ @opts ||= Optimist.options do
19
19
  # Set help message
20
20
  usage 'key add [options]'
21
21
  synopsis "\nThis command is for adding user keys to a given user's profile"
22
22
 
23
- opt :user, 'Specify username to add key to', type: :string,
23
+ opt :username, 'Specify username to add key to', type: :string,
24
24
  required: true
25
25
  opt :filename, 'File to load keys from', type: :string
26
26
  end
@@ -31,10 +31,10 @@ module Tapjoy
31
31
  end
32
32
 
33
33
  def filter_users
34
- filter = Net::LDAP::Filter.eq('uid', opts[:user])
34
+ filter = Net::LDAP::Filter.eq('uid', opts[:username])
35
35
  results = Tapjoy::LDAP.client.search(attributes = ['*'], filter = filter)
36
36
 
37
- Tapjoy::LDAP::Key.verify_user(opts[:user], results)
37
+ Tapjoy::LDAP::Key.verify_user(opts[:username], results)
38
38
 
39
39
  results
40
40
  end
@@ -15,7 +15,7 @@ module Tapjoy
15
15
 
16
16
  private
17
17
  def opts
18
- @opts ||= Trollop.options do
18
+ @opts ||= Optimist.options do
19
19
  # Set help message
20
20
  usage 'key install'
21
21
  synopsis "\nThis command is for adding keys to the appropriate authorized_keys file"
@@ -6,7 +6,7 @@ module Tapjoy
6
6
  # Remove key from LDAP
7
7
  def remove
8
8
  keys # Get keys first
9
- Tapjoy::LDAP::Key.verify_user(opts[:user], results)
9
+ Tapjoy::LDAP::Key.verify_user(opts[:username], results)
10
10
 
11
11
  confirm unless opts[:force]
12
12
  Tapjoy::LDAP.client.replace_attribute(
@@ -15,12 +15,12 @@ module Tapjoy
15
15
 
16
16
  private
17
17
  def opts
18
- @opts ||= Trollop.options do
18
+ @opts ||= Optimist.options do
19
19
  # Set help message
20
20
  usage 'key remove [options]'
21
21
  synopsis "\nThis command is for removing a user's SSH key(s)"
22
22
 
23
- opt :user, 'Specify username to delete key from', type: :string,
23
+ opt :username, 'Specify username to delete key from', type: :string,
24
24
  required: true
25
25
  opt :filename, 'File to load key deletion list from', type: :string
26
26
  opt :force, 'Force delete', short: '-F'
@@ -32,7 +32,7 @@ module Tapjoy
32
32
  end
33
33
 
34
34
  def filter
35
- @filter ||= Net::LDAP::Filter.eq('uid', opts[:user])
35
+ @filter ||= Net::LDAP::Filter.eq('uid', opts[:username])
36
36
  end
37
37
 
38
38
  def results
@@ -69,7 +69,7 @@ module Tapjoy
69
69
  print "\t #{ keep_keys }\n\n"
70
70
  puts "Delete these keys:\n\n"
71
71
  print "\t #{ delete_keys }\n\n"
72
- puts "Ignore these keys (not found in LDAP for #{ opts[:user]}):\n\n"
72
+ puts "Ignore these keys (not found in LDAP for #{ opts[:username]}):\n\n"
73
73
  print "\t #{ keys_not_found }\n\n"
74
74
  get_confirmation
75
75
  end
@@ -4,20 +4,20 @@ module Tapjoy
4
4
  # Show all of a user's keys
5
5
  class Show
6
6
  def show
7
- username = opts[:user]
7
+ username = opts[:username]
8
8
  keys = Tapjoy::LDAP::Key.get_keys_from_ldap[username]
9
- puts "No keys found for #{opts[:user]}" if keys.nil?
9
+ puts "No keys found for #{opts[:username]}" if keys.nil?
10
10
  puts keys
11
11
  end
12
12
 
13
13
  private
14
14
  def opts
15
- @opts ||= Trollop.options do
15
+ @opts ||= Optimist.options do
16
16
  # Set help message
17
17
  usage 'key show [options]'
18
18
  synopsis "\nThis command is for showing a specific user's SSH keys"
19
19
 
20
- opt :user, 'Specify username', type: :string, required: true
20
+ opt :username, 'Specify username', type: :string, required: true
21
21
  end
22
22
  end
23
23
 
@@ -1,3 +1,4 @@
1
+ require 'json'
1
2
  require_relative 'key/add'
2
3
  require_relative 'key/remove'
3
4
  require_relative 'key/show'
@@ -11,7 +12,7 @@ module Tapjoy
11
12
  SUB_COMMANDS = %w(add remove install list show)
12
13
 
13
14
  def commands
14
- Trollop.options do
15
+ Optimist.options do
15
16
  usage 'key [SUB_COMMAND] [options]'
16
17
  synopsis "\nThis object is used for user key management\nAvailable subcommands are: #{SUB_COMMANDS}"
17
18
 
@@ -44,7 +45,7 @@ module Tapjoy
44
45
  end
45
46
 
46
47
  def list
47
- Tapjoy::LDAP::Key.get_keys_from_ldap
48
+ puts JSON.pretty_generate(Tapjoy::LDAP::Key.get_keys_from_ldap)
48
49
  end
49
50
 
50
51
  def show
@@ -53,12 +54,11 @@ module Tapjoy
53
54
  end
54
55
 
55
56
  def get_keys_from_ldap
56
-
57
57
  key_results = {}
58
58
  filter = Net::LDAP::Filter.eq('sshPublicKey', '*')
59
59
  attributes = %w(uid sshPublicKey)
60
60
  results = Tapjoy::LDAP.client.search(attributes, filter)
61
- results.each {|result| key_results[result.uid[0]] = result.sshPublicKey}
61
+ results.each {|result| key_results[result.uid[0]] = result.sshpublickey}
62
62
  key_results
63
63
  end
64
64
 
@@ -2,7 +2,7 @@ module Tapjoy
2
2
  module LDAP
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 9
5
+ MINOR = 11
6
6
  PATCH = 2
7
7
  end
8
8
 
data/lib/tapjoy/ldap.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  require 'net/ldap'
2
2
  require 'yaml'
3
- require 'trollop'
3
+ require 'optimist'
4
4
  require 'memoist'
5
- require 'pry'
6
5
  require_relative 'ldap/cli'
7
6
  require_relative 'ldap/base'
8
7
  require_relative 'ldap/key'
@@ -25,7 +24,7 @@ module Tapjoy
25
24
 
26
25
  class InvalidArgument < ArgumentError
27
26
  def initialize
28
- Trollop.educate
27
+ Optimist.educate
29
28
  end
30
29
  end
31
30
  end
metadata CHANGED
@@ -1,29 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldap_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
+ - Tapjoy
7
8
  - Ali Tayarani
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
12
+ date: 2021-10-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: trollop
15
+ name: optimist
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '2.1'
20
+ version: '3.0'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
25
  - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: '2.1'
27
+ version: '3.0'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: net-ldap
29
30
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +67,6 @@ dependencies:
66
67
  - - ">="
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0.14'
69
- - !ruby/object:Gem::Dependency
70
- name: activesupport
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '4.2'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '4.2'
83
70
  - !ruby/object:Gem::Dependency
84
71
  name: rspec
85
72
  requirement: !ruby/object:Gem::Requirement
@@ -221,7 +208,7 @@ dependencies:
221
208
  - !ruby/object:Gem::Version
222
209
  version: '0'
223
210
  description: A set of tools to make managing LDAP users, groups, and keys easier
224
- email: ali.tayarani@tapjoy.com
211
+ email: dev@tapjoy.com
225
212
  executables:
226
213
  - ldaptools
227
214
  extensions: []
@@ -273,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
260
  version: '0'
274
261
  requirements: []
275
262
  rubyforge_project:
276
- rubygems_version: 2.5.1
263
+ rubygems_version: 2.6.14
277
264
  signing_key:
278
265
  specification_version: 4
279
266
  summary: Tapjoy LDAP Tools