yus 1.0.2 → 1.0.4
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 +5 -13
- data/.gitignore +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +22 -0
- data/0001-Added-support-for-running-yus-via-docker.patch +172 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +84 -0
- data/History.txt +11 -0
- data/Manifest.txt +25 -0
- data/Rakefile +26 -0
- data/bin/yus_add_user +5 -41
- data/bin/yus_delete_user +3 -37
- data/bin/yus_dump +19 -0
- data/bin/yus_grant +8 -32
- data/bin/yus_passwd +5 -41
- data/bin/yus_show +8 -34
- data/bin/yusd +2 -2
- data/data/yus_dump.yml +42 -0
- data/lib/data/yus_dump.yml +42 -0
- data/lib/yus/helpers.rb +74 -0
- data/lib/yus/server.rb +1 -2
- data/lib/yus/session.rb +2 -1
- data/lib/yus/version.rb +3 -0
- data/readme.md +27 -0
- data/second.env +1 -0
- data/yus.gemspec +45 -0
- data/yus_migrate_to_utf_8 +214 -0
- metadata +239 -44
- data/.gemtest +0 -0
- data/README.txt +0 -35
- data/test/suite.rb +0 -15
- data/test/test_entity.rb +0 -238
- data/test/test_privilege.rb +0 -57
- data/test/test_server.rb +0 -127
- data/test/test_session.rb +0 -909
data/bin/yus_delete_user
CHANGED
@@ -8,18 +8,10 @@ require 'drb/ssl'
|
|
8
8
|
require 'password'
|
9
9
|
require 'rclconf'
|
10
10
|
require 'yus/session'
|
11
|
+
require 'yus/helpers'
|
11
12
|
require 'getoptlong'
|
12
13
|
|
13
|
-
opts =
|
14
|
-
GetoptLong.new(
|
15
|
-
['--config', '-c', GetoptLong::OPTIONAL_ARGUMENT],
|
16
|
-
['--root_name', '-r', GetoptLong::OPTIONAL_ARGUMENT],
|
17
|
-
['--server_url', '-u', GetoptLong::OPTIONAL_ARGUMENT],
|
18
|
-
['--yus_dir', '-d', GetoptLong::OPTIONAL_ARGUMENT]
|
19
|
-
).each { |pair|
|
20
|
-
opts.push(pair.join('=')[2..-1])
|
21
|
-
}
|
22
|
-
|
14
|
+
opts = Yus.default_opts
|
23
15
|
name, action, item = ARGV
|
24
16
|
|
25
17
|
unless(name)
|
@@ -29,31 +21,5 @@ Usage: yus_delete_user <username>
|
|
29
21
|
exit
|
30
22
|
end
|
31
23
|
|
32
|
-
|
33
|
-
default_config_files = [
|
34
|
-
File.join(default_dir, 'yus.yml'),
|
35
|
-
'/etc/yus/yus.yml',
|
36
|
-
]
|
37
|
-
defaults = {
|
38
|
-
'config' => default_config_files,
|
39
|
-
'root_name' => 'admin',
|
40
|
-
'server_url' => 'drbssl://localhost:9997',
|
41
|
-
'yus_dir' => default_dir,
|
42
|
-
}
|
43
|
-
|
44
|
-
config = RCLConf::RCLConf.new(opts, defaults)
|
45
|
-
config.load(config.config)
|
46
|
-
|
47
|
-
server = DRb::DRbObject.new(nil, config.server_url)
|
48
|
-
server.ping
|
49
|
-
|
50
|
-
session = nil
|
51
|
-
begin
|
52
|
-
pass = Password.get("Password for #{config.root_name}: ")
|
53
|
-
session = server.login(config.root_name, pass.to_s, 'commandline')
|
54
|
-
rescue Yus::YusError => e
|
55
|
-
puts e.message
|
56
|
-
retry
|
57
|
-
end
|
58
|
-
|
24
|
+
session = Yus.session(opts)
|
59
25
|
session.delete_entity(name)
|
data/bin/yus_dump
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$: << File.expand_path('../lib', File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require 'rubygems' if RUBY_VERSION.match('1.8.6')
|
6
|
+
require 'drb'
|
7
|
+
require 'drb/ssl'
|
8
|
+
require 'password'
|
9
|
+
require 'rclconf'
|
10
|
+
require 'yus/session'
|
11
|
+
require 'yus/helpers'
|
12
|
+
require 'getoptlong'
|
13
|
+
|
14
|
+
opts = Yus.default_opts
|
15
|
+
filename = ARGV.first
|
16
|
+
|
17
|
+
session = Yus.session(opts)
|
18
|
+
session.dump_to_yaml(filename)
|
19
|
+
|
data/bin/yus_grant
CHANGED
@@ -8,6 +8,7 @@ require 'drb/ssl'
|
|
8
8
|
require 'password'
|
9
9
|
require 'rclconf'
|
10
10
|
require 'yus/session'
|
11
|
+
require 'yus/helpers'
|
11
12
|
require 'getoptlong'
|
12
13
|
|
13
14
|
opts = []
|
@@ -20,13 +21,13 @@ GetoptLong.new(
|
|
20
21
|
['--yus_dir', '-d', GetoptLong::REQUIRED_ARGUMENT],
|
21
22
|
['--revoke', '-R', GetoptLong::NO_ARGUMENT]
|
22
23
|
).each { |key, value|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
case key
|
25
|
+
when '--revoke'
|
26
|
+
command = :revoke
|
26
27
|
date = 'from'
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
else
|
29
|
+
opts.push("#{key}=#{value}")
|
30
|
+
end
|
30
31
|
}
|
31
32
|
|
32
33
|
name, action, item, expires = ARGV
|
@@ -38,18 +39,6 @@ Usage: yus_grant <username> <action> [<item> [<expiry_time>]]
|
|
38
39
|
exit
|
39
40
|
end
|
40
41
|
|
41
|
-
default_dir = File.join(ENV['HOME'], '.yus')
|
42
|
-
default_config_files = [
|
43
|
-
File.join(default_dir, 'yus.yml'),
|
44
|
-
'/etc/yus/yus.yml',
|
45
|
-
]
|
46
|
-
defaults = {
|
47
|
-
'config' => default_config_files,
|
48
|
-
'root_name' => 'admin',
|
49
|
-
'server_url' => 'drbssl://localhost:9997',
|
50
|
-
'yus_dir' => default_dir,
|
51
|
-
}
|
52
|
-
|
53
42
|
time = nil
|
54
43
|
if expires
|
55
44
|
if match = /(\d{1,2})\.(\d{1,2})\.(\d{4})/.match(expires.to_s)
|
@@ -61,20 +50,7 @@ expiry_date must be in the Format: mm.dd.YYYY
|
|
61
50
|
end
|
62
51
|
end
|
63
52
|
|
64
|
-
|
65
|
-
config.load(config.config)
|
66
|
-
|
67
|
-
server = DRb::DRbObject.new(nil, config.server_url)
|
68
|
-
server.ping
|
69
|
-
|
70
|
-
session = nil
|
71
|
-
begin
|
72
|
-
pass = Password.get("Password for #{config.root_name}: ")
|
73
|
-
session = server.login(config.root_name, pass.to_s, 'commandline')
|
74
|
-
rescue Yus::YusError => e
|
75
|
-
puts e.message
|
76
|
-
retry
|
77
|
-
end
|
53
|
+
session = Yus.session(opts)
|
78
54
|
|
79
55
|
session.send(command, name, action, item, time)
|
80
56
|
puts sprintf("%sed permission to %s %s for %s %s %s",
|
data/bin/yus_passwd
CHANGED
@@ -5,21 +5,12 @@ $: << File.expand_path('../lib', File.dirname(__FILE__))
|
|
5
5
|
require 'rubygems' if RUBY_VERSION.match('1.8.6')
|
6
6
|
require 'drb'
|
7
7
|
require 'drb/ssl'
|
8
|
-
require 'password'
|
9
8
|
require 'rclconf'
|
10
9
|
require 'yus/session'
|
10
|
+
require 'yus/helpers'
|
11
11
|
require 'getoptlong'
|
12
12
|
|
13
|
-
opts =
|
14
|
-
GetoptLong.new(
|
15
|
-
['--config', '-c', GetoptLong::OPTIONAL_ARGUMENT],
|
16
|
-
['--root_name', '-r', GetoptLong::OPTIONAL_ARGUMENT],
|
17
|
-
['--server_url', '-u', GetoptLong::OPTIONAL_ARGUMENT],
|
18
|
-
['--yus_dir', '-d', GetoptLong::OPTIONAL_ARGUMENT]
|
19
|
-
).each { |pair|
|
20
|
-
opts.push(pair.join('=')[2..-1])
|
21
|
-
}
|
22
|
-
|
13
|
+
opts = Yus.default_opts
|
23
14
|
name = ARGV.first
|
24
15
|
|
25
16
|
unless(name)
|
@@ -29,37 +20,10 @@ Usage: yus_passwd <username>
|
|
29
20
|
exit
|
30
21
|
end
|
31
22
|
|
32
|
-
|
33
|
-
default_config_files = [
|
34
|
-
File.join(default_dir, 'yus.yml'),
|
35
|
-
'/etc/yus/yus.yml',
|
36
|
-
]
|
37
|
-
defaults = {
|
38
|
-
'config' => default_config_files,
|
39
|
-
'root_name' => 'admin',
|
40
|
-
'server_url' => 'drbssl://localhost:9997',
|
41
|
-
'yus_dir' => default_dir,
|
42
|
-
}
|
43
|
-
|
44
|
-
config = RCLConf::RCLConf.new(opts, defaults)
|
45
|
-
config.load(config.config)
|
46
|
-
|
47
|
-
server = DRb::DRbObject.new(nil, config.server_url)
|
48
|
-
server.ping
|
49
|
-
|
50
|
-
session = nil
|
51
|
-
begin
|
52
|
-
pass = Password.get("Password for #{config.root_name}: ")
|
53
|
-
session = server.login(config.root_name, pass.to_s, 'commandline')
|
54
|
-
rescue Yus::YusError => e
|
55
|
-
puts e.message
|
56
|
-
retry
|
57
|
-
end
|
23
|
+
session = Yus.session(opts)
|
58
24
|
|
59
|
-
|
60
|
-
|
61
|
-
pass1 = Password.get("New Password for #{name}: ")
|
62
|
-
pass2 = Password.get("Repeat Password for #{name}: ")
|
25
|
+
pass1 = Yus.get_password("New Password for #{name}: ")
|
26
|
+
pass2 = Yus.get_password("Repeat Password for #{name}: ")
|
63
27
|
|
64
28
|
if(pass1 != pass2)
|
65
29
|
puts "Passwords did not match"
|
data/bin/yus_show
CHANGED
@@ -8,6 +8,7 @@ require 'drb/ssl'
|
|
8
8
|
require 'password'
|
9
9
|
require 'rclconf'
|
10
10
|
require 'yus/session'
|
11
|
+
require 'yus/helpers'
|
11
12
|
require 'getoptlong'
|
12
13
|
|
13
14
|
opts = []
|
@@ -19,14 +20,13 @@ GetoptLong.new(
|
|
19
20
|
['--yus_dir', '-d', GetoptLong::REQUIRED_ARGUMENT],
|
20
21
|
['--recursive', '-R', GetoptLong::NO_ARGUMENT]
|
21
22
|
).each { |key, value|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
case key
|
24
|
+
when '--recursive'
|
25
|
+
recursive = true
|
26
|
+
else
|
27
|
+
opts.push("#{key}=#{value}")
|
28
|
+
end
|
28
29
|
}
|
29
|
-
|
30
30
|
name = ARGV.first
|
31
31
|
|
32
32
|
unless(name)
|
@@ -36,31 +36,5 @@ Usage: yus_show <username>
|
|
36
36
|
exit
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
default_config_files = [
|
41
|
-
File.join(default_dir, 'yus.yml'),
|
42
|
-
'/etc/yus/yus.yml',
|
43
|
-
]
|
44
|
-
defaults = {
|
45
|
-
'config' => default_config_files,
|
46
|
-
'root_name' => 'admin',
|
47
|
-
'server_url' => 'drbssl://localhost:9997',
|
48
|
-
'yus_dir' => default_dir,
|
49
|
-
}
|
50
|
-
|
51
|
-
config = RCLConf::RCLConf.new(opts, defaults)
|
52
|
-
config.load(config.config)
|
53
|
-
|
54
|
-
server = DRb::DRbObject.new(nil, config.server_url)
|
55
|
-
server.ping
|
56
|
-
|
57
|
-
session = nil
|
58
|
-
begin
|
59
|
-
pass = Password.get("Password for #{config.root_name}: ")
|
60
|
-
session = server.login(config.root_name, pass.to_s, 'commandline')
|
61
|
-
rescue Yus::YusError => e
|
62
|
-
puts e.message
|
63
|
-
retry
|
64
|
-
end
|
65
|
-
|
39
|
+
session = Yus.session(opts)
|
66
40
|
puts session.show(name, recursive)
|
data/bin/yusd
CHANGED
@@ -9,6 +9,7 @@ require 'drb'
|
|
9
9
|
require 'drb/ssl'
|
10
10
|
require 'drb/timeridconv'
|
11
11
|
require 'digest/sha2'
|
12
|
+
require 'odba/18_19_loading_compatibility'
|
12
13
|
|
13
14
|
default_dir = File.join(ENV['HOME'], '.yus')
|
14
15
|
default_config_files = [
|
@@ -91,8 +92,7 @@ begin
|
|
91
92
|
url.untaint
|
92
93
|
DRb.start_service(url, server, drbconf)
|
93
94
|
$SAFE = 1
|
94
|
-
logger.info('start') {
|
95
|
-
sprintf("starting yus-server on %s", url) }
|
95
|
+
logger.info('start') { sprintf("starting yus-server on %s", url) }
|
96
96
|
DRb.thread.join
|
97
97
|
rescue Exception => error
|
98
98
|
logger.error('fatal') { error }
|
data/data/yus_dump.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
--- !ruby/object:MockPersistence
|
2
|
+
entities:
|
3
|
+
entity_name: !ruby/object:Yus::Entity
|
4
|
+
name: entity_name
|
5
|
+
valid_until: entity_pass
|
6
|
+
valid_from: 2016-05-23 17:41:00.786953476 +02:00
|
7
|
+
affiliations:
|
8
|
+
- &1 !ruby/object:Yus::Entity
|
9
|
+
name: a_yus_group
|
10
|
+
valid_until: entity_pass
|
11
|
+
valid_from: 2016-05-23 17:41:00.787118766 +02:00
|
12
|
+
affiliations: []
|
13
|
+
privileges:
|
14
|
+
set_password: !ruby/object:Yus::Privilege
|
15
|
+
items:
|
16
|
+
a_yus_group: :never
|
17
|
+
preferences: {}
|
18
|
+
last_logins: {}
|
19
|
+
tokens: {}
|
20
|
+
privileges:
|
21
|
+
set_password: !ruby/object:Yus::Privilege
|
22
|
+
items:
|
23
|
+
entity_name: :never
|
24
|
+
action: !ruby/object:Yus::Privilege
|
25
|
+
items:
|
26
|
+
key: :never
|
27
|
+
preferences: {}
|
28
|
+
last_logins: {}
|
29
|
+
tokens: {}
|
30
|
+
second_name: !ruby/object:Yus::Entity
|
31
|
+
name: second_name
|
32
|
+
valid_until: entity_pass
|
33
|
+
valid_from: 2016-05-23 17:41:00.787038968 +02:00
|
34
|
+
affiliations: []
|
35
|
+
privileges:
|
36
|
+
set_password: !ruby/object:Yus::Privilege
|
37
|
+
items:
|
38
|
+
second_name: :never
|
39
|
+
preferences: {}
|
40
|
+
last_logins: {}
|
41
|
+
tokens: {}
|
42
|
+
a_yus_group: *1
|
@@ -0,0 +1,42 @@
|
|
1
|
+
--- !ruby/object:MockPersistence
|
2
|
+
entities:
|
3
|
+
entity_name: !ruby/object:Yus::Entity
|
4
|
+
name: entity_name
|
5
|
+
valid_until: entity_pass
|
6
|
+
valid_from: 2014-10-01 13:16:27.677438587 +02:00
|
7
|
+
affiliations:
|
8
|
+
- &1 !ruby/object:Yus::Entity
|
9
|
+
name: a_yus_group
|
10
|
+
valid_until: entity_pass
|
11
|
+
valid_from: 2014-10-01 13:16:27.677673350 +02:00
|
12
|
+
affiliations: []
|
13
|
+
privileges:
|
14
|
+
set_password: !ruby/object:Yus::Privilege
|
15
|
+
items:
|
16
|
+
a_yus_group: :never
|
17
|
+
preferences: {}
|
18
|
+
last_logins: {}
|
19
|
+
tokens: {}
|
20
|
+
privileges:
|
21
|
+
set_password: !ruby/object:Yus::Privilege
|
22
|
+
items:
|
23
|
+
entity_name: :never
|
24
|
+
action: !ruby/object:Yus::Privilege
|
25
|
+
items:
|
26
|
+
key: :never
|
27
|
+
preferences: {}
|
28
|
+
last_logins: {}
|
29
|
+
tokens: {}
|
30
|
+
second_name: !ruby/object:Yus::Entity
|
31
|
+
name: second_name
|
32
|
+
valid_until: entity_pass
|
33
|
+
valid_from: 2014-10-01 13:16:27.677558840 +02:00
|
34
|
+
affiliations: []
|
35
|
+
privileges:
|
36
|
+
set_password: !ruby/object:Yus::Privilege
|
37
|
+
items:
|
38
|
+
second_name: :never
|
39
|
+
preferences: {}
|
40
|
+
last_logins: {}
|
41
|
+
tokens: {}
|
42
|
+
a_yus_group: *1
|
data/lib/yus/helpers.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# AutoInvoicer -- ydim -- 13.01.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'rclconf'
|
5
|
+
require 'getoptlong'
|
6
|
+
require 'highline/import'
|
7
|
+
|
8
|
+
module Yus
|
9
|
+
def self.default_opts
|
10
|
+
opts = []
|
11
|
+
GetoptLong.new(
|
12
|
+
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
13
|
+
['--config', '-c', GetoptLong::OPTIONAL_ARGUMENT],
|
14
|
+
['--root_name', '-r', GetoptLong::OPTIONAL_ARGUMENT],
|
15
|
+
['--server_url', '-u', GetoptLong::OPTIONAL_ARGUMENT],
|
16
|
+
['--yus_dir', '-d', GetoptLong::OPTIONAL_ARGUMENT]
|
17
|
+
).each { |key, pair|
|
18
|
+
opts.push("#{key}=#{pair}")
|
19
|
+
}
|
20
|
+
opts
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.session(opts = self.default_opts)
|
24
|
+
if /--help=/.match(opts[0])
|
25
|
+
puts <<-EOF
|
26
|
+
#{File.basename(__FILE__)} ...
|
27
|
+
|
28
|
+
-h, --help:
|
29
|
+
show help
|
30
|
+
|
31
|
+
-c -config
|
32
|
+
config directory of yus.yml
|
33
|
+
|
34
|
+
-r --root_name
|
35
|
+
Root name to use for reading yus
|
36
|
+
|
37
|
+
-s --config
|
38
|
+
path to YAML-config of Yus
|
39
|
+
EOF
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
default_dir = File.join(ENV['HOME'], '.yus')
|
43
|
+
default_config_files = [
|
44
|
+
File.join(default_dir, 'yus.yml'),
|
45
|
+
'/etc/yus/yus.yml',
|
46
|
+
]
|
47
|
+
defaults = {
|
48
|
+
'config' => default_config_files,
|
49
|
+
'root_name' => 'admin',
|
50
|
+
'server_url' => 'drbssl://localhost:9997',
|
51
|
+
'yus_dir' => default_config_files,
|
52
|
+
}
|
53
|
+
|
54
|
+
opts.each{|opt|opt.sub!(/^--/, '') } # Remove leading '--' from the GetOptLong
|
55
|
+
config = RCLConf::RCLConf.new(opts, defaults)
|
56
|
+
config.load(config.config)
|
57
|
+
|
58
|
+
server = DRb::DRbObject.new(nil, config.server_url)
|
59
|
+
server.ping
|
60
|
+
|
61
|
+
session = nil
|
62
|
+
begin
|
63
|
+
pass = Yus.get_password("Password for #{config.root_name}: ")
|
64
|
+
session = server.login(config.root_name, pass.to_s, 'commandline')
|
65
|
+
rescue Yus::YusError => e
|
66
|
+
puts e.message
|
67
|
+
retry
|
68
|
+
end
|
69
|
+
return session
|
70
|
+
end
|
71
|
+
def self.get_password(prompt='Password: ')
|
72
|
+
ask(prompt) { |q| q.echo = false}
|
73
|
+
end
|
74
|
+
end
|