hotify 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -1
- data/hotify.gemspec +1 -0
- data/lib/hotify.rb +7 -4
- data/lib/hotify/cli.rb +56 -27
- data/lib/hotify/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87530c74880b1befe5ee22346c52ea9832dfa0784b1fbd6457f27b9f76428821
|
4
|
+
data.tar.gz: d72bc7a24db4601fdbf932b72f11417fb129a184cf59804c54c59696572f011c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a61070bacaa148c9770257df5745a9fd56fa3ddfe12417a56eebcbe813ccd510ce68d5d80b9dfc8095417180d8ab402b0e69a8219aa9ea57e1f912a33fcbc7
|
7
|
+
data.tar.gz: '095275f5c1e02b7fbff2753c1aae5548e4f60b1d898d952dec90640f7f8f3efc68c7d7adcbb3553a435680a7e66a2f9ee8f8d0d61c7d2dc8d34b036895ab1c4e'
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hotify (0.1.
|
4
|
+
hotify (0.1.3)
|
5
5
|
onelogin (~> 1.5.0)
|
6
|
+
parallel (~> 1.19.1)
|
6
7
|
thor (~> 1.0.1)
|
7
8
|
|
8
9
|
GEM
|
@@ -26,6 +27,7 @@ GEM
|
|
26
27
|
onelogin (1.5.0)
|
27
28
|
httparty (>= 0.13.7)
|
28
29
|
nokogiri (>= 1.6.3.1)
|
30
|
+
parallel (1.19.1)
|
29
31
|
pry (0.13.1)
|
30
32
|
coderay (~> 1.1)
|
31
33
|
method_source (~> 1.0)
|
@@ -53,6 +55,7 @@ DEPENDENCIES
|
|
53
55
|
dotenv
|
54
56
|
hotify!
|
55
57
|
onelogin
|
58
|
+
parallel
|
56
59
|
pry
|
57
60
|
rake (~> 12.0)
|
58
61
|
rspec (~> 3.0)
|
data/hotify.gemspec
CHANGED
data/lib/hotify.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "onelogin"
|
2
2
|
require "thor"
|
3
|
+
require "parallel"
|
3
4
|
require "hotify/version"
|
4
5
|
require "hotify/cli"
|
5
6
|
require "hotify/auth"
|
@@ -68,12 +69,14 @@ module Hotify
|
|
68
69
|
role_user
|
69
70
|
end
|
70
71
|
|
71
|
-
def add_role(
|
72
|
-
|
72
|
+
def add_role(user_email, role_ids)
|
73
|
+
user = Hotify::Users.find_by(email: user_email)
|
74
|
+
client.assign_role_to_user(user.id, role_ids)
|
73
75
|
end
|
74
76
|
|
75
|
-
def leave_role(
|
76
|
-
|
77
|
+
def leave_role(user_email, role_ids)
|
78
|
+
user = Hotify::Users.find_by(email: user_email)
|
79
|
+
client.remove_role_from_user(user.id, role_ids)
|
77
80
|
end
|
78
81
|
|
79
82
|
def find_by_name(name)
|
data/lib/hotify/cli.rb
CHANGED
@@ -28,48 +28,77 @@ module Hotify
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def hotify_role
|
32
|
+
@_hotify_role ||= Hotify::Role.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def role_id_names
|
36
|
+
@_role_id_names ||= hotify_role.all_roles.map{ | role | { id: role.id, name: role.name} }
|
37
|
+
end
|
38
|
+
|
39
|
+
def role_id_by(name)
|
40
|
+
role_id_names.each do | role_id_name |
|
41
|
+
return role_id_name[:id] if role_id_name[:name] == name
|
42
|
+
end
|
43
|
+
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def onelogin_role_in_user
|
48
|
+
@_onelogin_role_in_user ||= role_in_user_dump(hotify_role.role_in_user)
|
49
|
+
end
|
50
|
+
|
31
51
|
def add_role_by_yaml(hotify_role_users_hash)
|
32
|
-
|
33
|
-
hotify_role_users_hash.each do |
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
unless onelogin_user_role_names.include?(role_name)
|
38
|
-
add!(user, role_name)
|
52
|
+
users_and_roles_will_add = Hash.new { |h,k| h[k] = [] }
|
53
|
+
hotify_role_users_hash.each do | hotify_role_name, hotify_user_emails |
|
54
|
+
hotify_user_emails.each do | hotify_user_email |
|
55
|
+
unless onelogin_role_in_user[hotify_role_name].include?(hotify_user_email)
|
56
|
+
users_and_roles_will_add[hotify_user_email].push(hotify_role_name)
|
39
57
|
end
|
40
58
|
end
|
41
59
|
end
|
60
|
+
|
61
|
+
add!(users_and_roles_will_add)
|
42
62
|
end
|
43
63
|
|
44
64
|
def remove_role_by_yaml(hotify_role_users_hash)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
remove!(user, onelogin_role_name)
|
65
|
+
users_and_roles_will_remove = Hash.new { |h,k| h[k] = [] }
|
66
|
+
hotify_role_users_hash.each do | hotify_role_name, hotify_user_emails |
|
67
|
+
onelogin_role_in_user[hotify_role_name].each do | onelogin_user_email |
|
68
|
+
unless hotify_user_emails.include?(onelogin_user_email)
|
69
|
+
users_and_roles_will_remove[onelogin_user_email].push(hotify_role_name)
|
51
70
|
end
|
52
71
|
end
|
53
72
|
end
|
73
|
+
|
74
|
+
remove!(users_and_roles_will_remove)
|
54
75
|
end
|
55
76
|
|
56
|
-
def add!(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
77
|
+
def add!(users_and_roles_will_add)
|
78
|
+
users_and_roles_will_add.each do |user_email, role_names|
|
79
|
+
if options[:dry_run]
|
80
|
+
puts "#{user_email} will add to:"
|
81
|
+
role_names.each { | role_name | puts role_name }
|
82
|
+
else
|
83
|
+
role_ids = role_names.map{ |role_name| role_id_by(role_name) }
|
84
|
+
hotify_role.add_role(user_email, role_ids)
|
85
|
+
puts "#{user_email} added to:"
|
86
|
+
role_names.each { | role_name | puts role_name }
|
87
|
+
end
|
63
88
|
end
|
64
89
|
end
|
65
90
|
|
66
|
-
def remove!(
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
91
|
+
def remove!(users_and_roles_will_remove)
|
92
|
+
users_and_roles_will_remove.each do |user_email, role_names|
|
93
|
+
if options[:dry_run]
|
94
|
+
puts "#{user_email} will remove by:"
|
95
|
+
role_names.each { | role_name | puts role_name }
|
96
|
+
else
|
97
|
+
role_ids = role_names.map{ |role_name| role_id_by(role_name) }
|
98
|
+
hotify_role.leave_role(user_email, role_ids)
|
99
|
+
puts "#{user_email} removed by:"
|
100
|
+
role_names.each { | role_name | puts role_name }
|
101
|
+
end
|
73
102
|
end
|
74
103
|
end
|
75
104
|
|
data/lib/hotify/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- j-o-lantern0422
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.0.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: parallel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.19.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.19.1
|
83
97
|
description: Onelogin role manage, example user add, or remove from role command
|
84
98
|
email:
|
85
99
|
- j.o.lantern0422@gmail.com
|