ldap_tools 0.10.1 → 0.11.1

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: 316184981588868fdbabf770dfebe61562858684
4
- data.tar.gz: 9eba4741430891ae3917322e49d99d082913748c
3
+ metadata.gz: 71483cb21ed88bf9e02be272cb67da88957243b4
4
+ data.tar.gz: 36825f063aecf9a42b54f0e8b328ed0fa5a19058
5
5
  SHA512:
6
- metadata.gz: be22665161482b466bf0c883a1d206ccb39ac08d710b357f3de469ba83aa30cc4435a38c9b3c56d50b3a55c52fe81e03507222ffb69e6ca2a1e75e9e16b472b5
7
- data.tar.gz: 5b20555a39fcd8b451e8a39f6baecf87a3845498367571d9e7a3b0b3d42e2393e003fb67c3f175000189d90443fed141fff56311cd0a2aa115c0be9266d8626d
6
+ metadata.gz: 8367696a0f370406e8a8573cb4bf18d50eaf8abfbd67ec0640e7f35df750c031cde4d14bd1763b81b77702086f236d2e9c930a9b045d7de60011f6bad555e787
7
+ data.tar.gz: 5b5c01ed11bd20c675707209a5032510cb64417e24f68479ff12d1acd50e3674a6419fb630cff5c0ec46aec7567289e577ffe02e5699bc5250b5cb5db1ddf9df
@@ -1,6 +1,6 @@
1
1
  require 'net/ldap'
2
2
  require 'yaml'
3
- require 'trollop'
3
+ require 'optimist'
4
4
  require 'memoist'
5
5
  require 'pry'
6
6
  require_relative 'ldap/cli'
@@ -25,7 +25,7 @@ module Tapjoy
25
25
 
26
26
  class InvalidArgument < ArgumentError
27
27
  def initialize
28
- Trollop.educate
28
+ Optimist.educate
29
29
  end
30
30
  end
31
31
  end
@@ -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
 
@@ -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,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
 
@@ -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"
@@ -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
 
@@ -15,13 +15,13 @@ 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 'user create [options]'
21
21
  synopsis "\nThis command is for creating new LDAP users"
22
22
 
23
23
  # Name is two arguments
24
- # Trollop will accept more, but we will only parse two later
24
+ # Optimist will accept more, but we will only parse two later
25
25
  # TODO: support given names that include a space
26
26
  opt :name, "Specify user's first and last name", type: :strings, required: true
27
27
 
@@ -32,8 +32,8 @@ module Tapjoy
32
32
  end
33
33
 
34
34
  def verify_arguments
35
- Trollop.die :name, 'argument count must be two' if opts[:name].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
@@ -14,7 +14,7 @@ module Tapjoy
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
 
@@ -25,14 +25,14 @@ module Tapjoy
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,7 +20,7 @@ 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
 
@@ -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
 
@@ -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 add [options]'
21
21
  synopsis "\nThis command is for adding user keys to a given user's profile"
@@ -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"
@@ -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 remove [options]'
21
21
  synopsis "\nThis command is for removing a user's SSH key(s)"
@@ -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,15 +4,15 @@ 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"
@@ -2,7 +2,7 @@ module Tapjoy
2
2
  module LDAP
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 10
5
+ MINOR = 11
6
6
  PATCH = 1
7
7
  end
8
8
 
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.10.1
4
+ version: 0.11.1
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-12-22 00:00:00.000000000 Z
12
+ date: 2019-11-06 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
@@ -207,7 +208,7 @@ dependencies:
207
208
  - !ruby/object:Gem::Version
208
209
  version: '0'
209
210
  description: A set of tools to make managing LDAP users, groups, and keys easier
210
- email: ali.tayarani@tapjoy.com
211
+ email: dev@tapjoy.com
211
212
  executables:
212
213
  - ldaptools
213
214
  extensions: []