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 +4 -4
- data/lib/tapjoy/ldap/audit.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/group.rb +1 -1
- data/lib/tapjoy/ldap/cli/user/create.rb +7 -7
- data/lib/tapjoy/ldap/cli/user/delete.rb +6 -6
- data/lib/tapjoy/ldap/cli/user/show.rb +3 -3
- data/lib/tapjoy/ldap/cli/user.rb +1 -1
- data/lib/tapjoy/ldap/cli.rb +1 -1
- data/lib/tapjoy/ldap/key/add.rb +4 -4
- data/lib/tapjoy/ldap/key/install.rb +1 -1
- data/lib/tapjoy/ldap/key/remove.rb +5 -5
- data/lib/tapjoy/ldap/key/show.rb +4 -4
- data/lib/tapjoy/ldap/key.rb +4 -4
- data/lib/tapjoy/ldap/version.rb +1 -1
- data/lib/tapjoy/ldap.rb +2 -3
- metadata +8 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a013f47e3c9fccb1ff3aafeee6ed84d8c0677c86
|
4
|
+
data.tar.gz: 1db37492ec187835d08b88462140ac9d930c590f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db759742e4443fbec435dc701377ad505746ce92426255583f7e393079dd9d37ec7084087daabecb969bf2bf64c3c1c3d276c8271bca7a5651a9fa9bc93e4e0a
|
7
|
+
data.tar.gz: 016170fd1a601da4e120be647c9051377a052ebd24c7b38ae6b691864f07412ea608dd8ec84a76cd8c014be36c00669fe3d88db3f9ef6690adfa749eeb43589b
|
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
|
|
@@ -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"
|
@@ -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
|
|
@@ -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[:
|
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 ||=
|
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
|
-
#
|
24
|
-
#
|
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 :
|
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
|
-
|
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
|
@@ -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[:
|
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 ||=
|
17
|
+
@opts ||= Optimist.options do
|
18
18
|
# Set help message
|
19
19
|
usage "user delete [options]"
|
20
20
|
|
21
|
-
opt :
|
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[:
|
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,11 +20,11 @@ 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
|
|
27
|
-
opt :
|
27
|
+
opt :username, 'Specify username', type: :string, required: true
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
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
|
|
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."
|
data/lib/tapjoy/ldap/key/add.rb
CHANGED
@@ -15,12 +15,12 @@ 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"
|
22
22
|
|
23
|
-
opt :
|
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[:
|
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
|
@@ -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[:
|
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 ||=
|
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 :
|
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[:
|
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,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[:
|
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"
|
19
19
|
|
20
|
-
opt :
|
20
|
+
opt :username, 'Specify username', type: :string, required: true
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
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/version.rb
CHANGED
data/lib/tapjoy/ldap.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'net/ldap'
|
2
2
|
require 'yaml'
|
3
|
-
require '
|
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
|
-
|
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.
|
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:
|
12
|
+
date: 2021-10-28 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
|
@@ -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:
|
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.
|
263
|
+
rubygems_version: 2.6.14
|
277
264
|
signing_key:
|
278
265
|
specification_version: 4
|
279
266
|
summary: Tapjoy LDAP Tools
|