titech-pubnet-auth 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/titech-pubnet-auth +7 -12
- data/lib/titech_pubnet_auth.rb +5 -4
- data/lib/titech_pubnet_auth/config.rb +50 -0
- data/lib/titech_pubnet_auth/version.rb +1 -1
- data/titech_pubnet_auth.gemspec +2 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05593e5dec9d131a04ac5be42ca7de6e5a7994c2
|
4
|
+
data.tar.gz: bbd03b2b41e239b5d0a246929617396bc0d490c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1461fb93108722600e466de33e403d829c02d88d55d93fc7101d8f1cf3f6026bf58f20a8979daed2f49259d9e5b9fa7554474c9fd5fe2b7ce1d5dd8398a0a22a
|
7
|
+
data.tar.gz: fed6471199fc471dd692906a2b68bbb86c425fb1e1c2990bedb8d2ee6fa8c762ea330088af3dcc1db20ee83dc73780763302f7a5260752a8faa2d414e2cc89b9
|
data/bin/titech-pubnet-auth
CHANGED
@@ -22,9 +22,9 @@ opt.on('-s','--single','No loop. Use as single command.'){
|
|
22
22
|
single = true
|
23
23
|
}
|
24
24
|
|
25
|
-
|
25
|
+
reconfig = false
|
26
26
|
opt.on('-c','--config','Set your username and password.'){
|
27
|
-
|
27
|
+
reconfig = true
|
28
28
|
}
|
29
29
|
|
30
30
|
debug = false
|
@@ -35,19 +35,14 @@ opt.on('--debug','Debug-mode.'){
|
|
35
35
|
opt.parse!(ARGV)
|
36
36
|
|
37
37
|
|
38
|
-
if
|
38
|
+
if !TitechPubnetAuth::Config.get || reconfig
|
39
|
+
config = TitechPubnetAuth::Config.new
|
39
40
|
puts 'Please type your username:'
|
40
|
-
username = gets.strip
|
41
|
+
config.username = gets.strip
|
41
42
|
system "stty -echo"
|
42
43
|
puts 'Please type your password (typing will be hidden):'
|
43
|
-
password = gets.strip
|
44
|
-
|
45
|
-
'username' => username,
|
46
|
-
'password' => password
|
47
|
-
}
|
48
|
-
File::open(File.expand_path('../config/private.yml', File.dirname(__FILE__)),'w'){|f|
|
49
|
-
f << conf.to_yaml
|
50
|
-
}
|
44
|
+
config.password = gets.strip
|
45
|
+
config.save!
|
51
46
|
puts 'configured!'
|
52
47
|
exit!
|
53
48
|
end
|
data/lib/titech_pubnet_auth.rb
CHANGED
@@ -7,7 +7,7 @@ require 'yaml'
|
|
7
7
|
$:.unshift(File.dirname(__FILE__))
|
8
8
|
require 'titech_pubnet_auth/bin_routines'
|
9
9
|
require 'titech_pubnet_auth/extensions'
|
10
|
-
|
10
|
+
require 'titech_pubnet_auth/config'
|
11
11
|
|
12
12
|
class TitechPubnetAuth
|
13
13
|
SAMPLE_URI = URI "http://example.org"
|
@@ -22,7 +22,8 @@ class TitechPubnetAuth
|
|
22
22
|
}
|
23
23
|
@agent_with_proxy.set_proxy(HTTP_PROXY[:ip], HTTP_PROXY[:port])
|
24
24
|
|
25
|
-
@
|
25
|
+
@config = opt[:config] || TitechPubnetAuth::Config.get
|
26
|
+
fail "config not found" unless @config
|
26
27
|
end
|
27
28
|
|
28
29
|
#
|
@@ -35,8 +36,8 @@ class TitechPubnetAuth
|
|
35
36
|
auth_page.form do |form|
|
36
37
|
form.buttonClicked = 4
|
37
38
|
form.redirect_url = sample_uri
|
38
|
-
form.username = @
|
39
|
-
form.password = @
|
39
|
+
form.username = @config.username
|
40
|
+
form.password = @config.password
|
40
41
|
end.submit
|
41
42
|
|
42
43
|
return is_connected?
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'virtus'
|
3
|
+
|
4
|
+
class TitechPubnetAuth
|
5
|
+
class Config
|
6
|
+
include Virtus::Model
|
7
|
+
attribute :username, String
|
8
|
+
attribute :password, String
|
9
|
+
|
10
|
+
if RbConfig::CONFIG["target_os"].downcase =~ /^darwin/
|
11
|
+
require 'keychain'
|
12
|
+
SERVICE_NAME = 'titech-pubnet-auth'
|
13
|
+
|
14
|
+
def self.get
|
15
|
+
key = keychain_item
|
16
|
+
key && new(username: key.account, password: key.password)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.keychain_item
|
20
|
+
Keychain.generic_passwords.where(service: SERVICE_NAME).first
|
21
|
+
end
|
22
|
+
|
23
|
+
def save!
|
24
|
+
key = self.class.keychain_item
|
25
|
+
if key
|
26
|
+
key.account = username
|
27
|
+
key.password = password
|
28
|
+
key.save!
|
29
|
+
else
|
30
|
+
Keychain.generic_passwords.create(service: SERVICE_NAME, account: username, password: password)
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
34
|
+
else
|
35
|
+
require 'yaml'
|
36
|
+
CONFIG_PATH = Pathname(__FILE__) + '../../../config/private.yml'
|
37
|
+
|
38
|
+
def self.get
|
39
|
+
new(YAML.load_file(CONFIG_PATH)) rescue nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def save!
|
43
|
+
CONFIG_PATH.open('w') do |f|
|
44
|
+
f << attributes.to_yaml
|
45
|
+
end
|
46
|
+
self
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/titech_pubnet_auth.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency 'colorize'
|
21
21
|
gem.add_dependency 'mechanize', '~> 2.7'
|
22
22
|
gem.add_dependency 'terminal-notifier', '~> 1.4'
|
23
|
+
gem.add_dependency 'ruby-keychain'
|
24
|
+
gem.add_dependency 'virtus', '~> 1.0'
|
23
25
|
|
24
26
|
gem.add_development_dependency 'rake'
|
25
27
|
gem.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: titech-pubnet-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sohei Takeno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-keychain
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: virtus
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rake
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,6 +153,7 @@ files:
|
|
125
153
|
- config/private.yml.example
|
126
154
|
- lib/titech_pubnet_auth.rb
|
127
155
|
- lib/titech_pubnet_auth/bin_routines.rb
|
156
|
+
- lib/titech_pubnet_auth/config.rb
|
128
157
|
- lib/titech_pubnet_auth/extensions.rb
|
129
158
|
- lib/titech_pubnet_auth/version.rb
|
130
159
|
- titech_pubnet_auth.gemspec
|