ldap_tools 0.10.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tapjoy/ldap.rb +2 -2
- data/lib/tapjoy/ldap/audit.rb +1 -1
- data/lib/tapjoy/ldap/cli.rb +1 -1
- data/lib/tapjoy/ldap/cli/group.rb +1 -1
- data/lib/tapjoy/ldap/cli/group/add_user.rb +1 -1
- data/lib/tapjoy/ldap/cli/group/create.rb +2 -2
- data/lib/tapjoy/ldap/cli/group/delete.rb +1 -1
- data/lib/tapjoy/ldap/cli/group/remove_user.rb +1 -1
- data/lib/tapjoy/ldap/cli/user.rb +1 -1
- data/lib/tapjoy/ldap/cli/user/create.rb +4 -4
- data/lib/tapjoy/ldap/cli/user/delete.rb +4 -4
- data/lib/tapjoy/ldap/cli/user/show.rb +2 -2
- data/lib/tapjoy/ldap/key.rb +4 -4
- data/lib/tapjoy/ldap/key/add.rb +3 -3
- data/lib/tapjoy/ldap/key/install.rb +1 -1
- data/lib/tapjoy/ldap/key/remove.rb +3 -3
- data/lib/tapjoy/ldap/key/show.rb +3 -3
- data/lib/tapjoy/ldap/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71483cb21ed88bf9e02be272cb67da88957243b4
|
4
|
+
data.tar.gz: 36825f063aecf9a42b54f0e8b328ed0fa5a19058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8367696a0f370406e8a8573cb4bf18d50eaf8abfbd67ec0640e7f35df750c031cde4d14bd1763b81b77702086f236d2e9c930a9b045d7de60011f6bad555e787
|
7
|
+
data.tar.gz: 5b5c01ed11bd20c675707209a5032510cb64417e24f68479ff12d1acd50e3674a6419fb630cff5c0ec46aec7567289e577ffe02e5699bc5250b5cb5db1ddf9df
|
data/lib/tapjoy/ldap.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'net/ldap'
|
2
2
|
require 'yaml'
|
3
|
-
require '
|
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
|
-
|
28
|
+
Optimist.educate
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/tapjoy/ldap/audit.rb
CHANGED
@@ -7,7 +7,7 @@ module Tapjoy
|
|
7
7
|
SUB_COMMANDS = %w(by_user by_group raw)
|
8
8
|
|
9
9
|
def commands
|
10
|
-
|
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
|
|
data/lib/tapjoy/ldap/cli.rb
CHANGED
@@ -7,7 +7,7 @@ module Tapjoy
|
|
7
7
|
class << self
|
8
8
|
def commands
|
9
9
|
subcommand = %w(user group key audit)
|
10
|
-
|
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
|
-
|
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
|
|
@@ -6,13 +6,13 @@ module Tapjoy
|
|
6
6
|
class Create
|
7
7
|
def create
|
8
8
|
# Check for errors
|
9
|
-
|
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 ||=
|
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"
|
data/lib/tapjoy/ldap/cli/user.rb
CHANGED
@@ -11,7 +11,7 @@ module Tapjoy
|
|
11
11
|
SUB_COMMANDS = %w(create delete index show)
|
12
12
|
|
13
13
|
def commands
|
14
|
-
|
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 ||=
|
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
|
-
#
|
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
|
-
|
36
|
-
|
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 ||=
|
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[:
|
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[:
|
31
|
+
abort("Deletion of #{opts[:username]} aborted") unless confirm.start_with?('y')
|
32
32
|
end
|
33
33
|
|
34
34
|
def verify_arguments
|
35
|
-
|
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[:
|
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 ||=
|
23
|
+
@opts ||= Optimist.options do
|
24
24
|
# Set help message
|
25
25
|
usage "user show [options]"
|
26
26
|
|
data/lib/tapjoy/ldap/key.rb
CHANGED
@@ -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
|
-
|
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.
|
61
|
+
results.each {|result| key_results[result.uid[0]] = result.sshpublickey}
|
62
62
|
key_results
|
63
63
|
end
|
64
64
|
|
data/lib/tapjoy/ldap/key/add.rb
CHANGED
@@ -15,7 +15,7 @@ module Tapjoy
|
|
15
15
|
|
16
16
|
private
|
17
17
|
def opts
|
18
|
-
@opts ||=
|
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[:
|
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[:
|
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 ||=
|
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[:
|
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[:
|
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
|
data/lib/tapjoy/ldap/key/show.rb
CHANGED
@@ -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[:
|
7
|
+
username = opts[:username]
|
8
8
|
keys = Tapjoy::LDAP::Key.get_keys_from_ldap[username]
|
9
|
-
puts "No keys found for #{opts[:
|
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 ||=
|
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"
|
data/lib/tapjoy/ldap/version.rb
CHANGED
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.
|
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:
|
12
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
+
name: optimist
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
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: '
|
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:
|
211
|
+
email: dev@tapjoy.com
|
211
212
|
executables:
|
212
213
|
- ldaptools
|
213
214
|
extensions: []
|