cloudcover 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/bin/cloudcover +4 -3
- data/lib/cloudcover/commands/simple_auth.rb +1 -2
- data/lib/cloudcover/config.rb +69 -23
- data/lib/cloudcover/okta/client.rb +2 -3
- data/lib/cloudcover/version.rb +1 -1
- metadata +2 -4
- data/Gemfile.lock +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc7a52c9efd426f2b7fd2438f68d3d9a588dde98
|
4
|
+
data.tar.gz: bede9c874d547cd617abf404c9662111137f541c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe281b19166021c9ff8bb52c4ea45d3f17d797341001775646d37da3fb28429829a8179e4dc8ec2b8f979feb19203a982519310537fc4ea84cc902396b45edeb
|
7
|
+
data.tar.gz: c49f80a026335d4517bea20921f2bddb1ed61d48e8a6fe3cc22e87551030d8410d67ad930eaaba09e2d55179658509980c388fb1ed2adae81dca739d10e2e1d5
|
data/.gitignore
CHANGED
data/bin/cloudcover
CHANGED
@@ -21,11 +21,11 @@ desc 'Simply verify that a set of credentials are valid to login to Okta. Return
|
|
21
21
|
arg_name '[credential file path]'
|
22
22
|
command 'simple-auth' do |c|
|
23
23
|
c.switch [:f], :desc => 'Get credentials from file path specified as first argument (Useful for OpenVPN authentication)'
|
24
|
-
c.switch [:radius], :desc => 'Return RADIUS style Accept/Reject Messages', :
|
24
|
+
c.switch [:radius], :desc => 'Return RADIUS style Accept/Reject Messages', :negatable => false
|
25
25
|
c.flag [:g, :group], :desc => 'Verify membership to the specified group during authentication', :default_value => false
|
26
26
|
c.flag [:c, :context], :desc => 'Extra context for success/fail message', :default_value => false
|
27
27
|
|
28
|
-
c.action do |
|
28
|
+
c.action do |global,options,args|
|
29
29
|
if options[:f]
|
30
30
|
raise CredentialFileError, "No readable credential file specified" unless File.readable?(args.first)
|
31
31
|
end
|
@@ -38,8 +38,9 @@ end
|
|
38
38
|
pre do |global,command,options,args|
|
39
39
|
$verbose = global[:verbose] || global[:debug]
|
40
40
|
$debug = global[:debug]
|
41
|
-
$config_path = global[:config]
|
42
41
|
$color = global[:color]
|
42
|
+
Cloudcover::Config.load(global[:config])
|
43
|
+
Cloudcover::Config.set_config_options(global)
|
43
44
|
true
|
44
45
|
end
|
45
46
|
|
@@ -5,7 +5,6 @@ module Cloudcover
|
|
5
5
|
|
6
6
|
def initialize(opts,path)
|
7
7
|
Output.say_debug("SimpleAuth class: #{self}")
|
8
|
-
@config = Cloudcover::Config.config
|
9
8
|
@okta = Cloudcover::Okta::Client.new
|
10
9
|
@credentials = {}
|
11
10
|
@opts = opts
|
@@ -82,7 +81,7 @@ module Cloudcover
|
|
82
81
|
end
|
83
82
|
|
84
83
|
def date_format
|
85
|
-
|
84
|
+
Cloudcover::Config.date_format ? Cloudcover::Config.date_format : "%a %b %e %H:%M:%S %Y"
|
86
85
|
end
|
87
86
|
|
88
87
|
def group_id
|
data/lib/cloudcover/config.rb
CHANGED
@@ -1,36 +1,82 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
module Cloudcover
|
4
|
-
class Config
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
module PrivateAttrAccessor
|
6
|
+
def private_attr_accessor(*names)
|
7
|
+
private
|
8
|
+
attr_accessor *names
|
8
9
|
end
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
class Config
|
13
|
+
|
14
|
+
CONFIG_DEFAULTS = {
|
15
|
+
location: File.join(ENV['HOME'],'.cloudcover'),
|
16
|
+
cookie_location: File.join(ENV['HOME'],'.cloudcover_cookie'),
|
17
|
+
}
|
18
|
+
|
19
|
+
class << self
|
20
|
+
extend PrivateAttrAccessor
|
21
|
+
private_attr_accessor :config_data
|
22
|
+
|
23
|
+
def config
|
24
|
+
CONFIG_DEFAULTS.merge data
|
25
|
+
end
|
26
|
+
|
27
|
+
def load(path)
|
28
|
+
load_config(path)
|
29
|
+
config
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_config_options(opts = {})
|
33
|
+
data.merge! opts
|
34
|
+
config
|
35
|
+
end
|
36
|
+
|
37
|
+
def data
|
38
|
+
self.config_data ||= load_config(CONFIG_DEFAULTS[:location])
|
39
|
+
end
|
40
|
+
private :data
|
41
|
+
|
42
|
+
def default_value(key)
|
43
|
+
CONFIG_DEFAULTS[key.to_sym]
|
44
|
+
end
|
45
|
+
private :default_value
|
46
|
+
|
47
|
+
def method_missing(method, args=false)
|
48
|
+
return data[method] if data[method]
|
49
|
+
return default_value(method) if default_value(method)
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
private :method_missing
|
53
|
+
|
54
|
+
def load_config(file)
|
55
|
+
Output.say_debug("Loading the config file from #{file}")
|
56
|
+
raise MissingConfig, "Missing configuration file: #{file} Run 'cloudcover help'" unless File.exist?(file)
|
57
|
+
config_data = symbolize_keys(YAML.load_file(file)) rescue {}
|
58
|
+
end
|
59
|
+
private :load_config
|
15
60
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
new_value = case value
|
25
|
-
when Hash then symbolize_keys(value)
|
26
|
-
else value
|
61
|
+
# We want all ouf our YAML loaded keys to be symbols
|
62
|
+
# taken from http://devblog.avdi.org/2009/07/14/recursively-symbolize-keys/
|
63
|
+
def symbolize_keys(hash)
|
64
|
+
hash.inject({}){|result, (key, value)|
|
65
|
+
new_key = case key
|
66
|
+
when String then key.to_sym
|
67
|
+
else key
|
27
68
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
69
|
+
new_value = case value
|
70
|
+
when Hash then symbolize_keys(value)
|
71
|
+
else value
|
72
|
+
end
|
73
|
+
result[new_key] = new_value
|
74
|
+
result
|
75
|
+
}
|
76
|
+
end
|
77
|
+
private :symbolize_keys
|
31
78
|
end
|
32
79
|
|
33
80
|
MissingConfig = Class.new(StandardError)
|
34
|
-
MissingEnvironment = Class.new(StandardError)
|
35
81
|
end
|
36
82
|
end
|
@@ -5,13 +5,12 @@ module Cloudcover
|
|
5
5
|
module Okta
|
6
6
|
class Client
|
7
7
|
include HTTParty
|
8
|
-
debug_output if
|
8
|
+
debug_output if Cloudcover::Config.debug
|
9
9
|
|
10
10
|
attr_reader :headers
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
|
14
|
-
self.class.base_uri "https://#{@config[:okta_domain]}.okta.com"
|
13
|
+
self.class.base_uri "https://#{Cloudcover::Config.okta_domain}.okta.com"
|
15
14
|
@headers = {
|
16
15
|
'Content-Type' => "application/json",
|
17
16
|
'Accept' => "application/json",
|
data/lib/cloudcover/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudcover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Krieger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -146,7 +146,6 @@ files:
|
|
146
146
|
- ".gitignore"
|
147
147
|
- ".ruby-version"
|
148
148
|
- Gemfile
|
149
|
-
- Gemfile.lock
|
150
149
|
- README.md
|
151
150
|
- Rakefile
|
152
151
|
- bin/cloudcover
|
@@ -185,4 +184,3 @@ specification_version: 4
|
|
185
184
|
summary: Provides a simple interface for using Okta authentication in command line
|
186
185
|
applications
|
187
186
|
test_files: []
|
188
|
-
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
cloudcover (0.0.1)
|
5
|
-
gli (~> 2.13.4)
|
6
|
-
hashdiff
|
7
|
-
highline
|
8
|
-
http-cookie
|
9
|
-
httparty
|
10
|
-
minitar
|
11
|
-
terminal-table
|
12
|
-
|
13
|
-
GEM
|
14
|
-
remote: https://rubygems.org/
|
15
|
-
specs:
|
16
|
-
domain_name (0.5.25)
|
17
|
-
unf (>= 0.0.5, < 1.0.0)
|
18
|
-
gli (2.13.4)
|
19
|
-
hashdiff (0.2.3)
|
20
|
-
highline (1.7.8)
|
21
|
-
http-cookie (1.0.2)
|
22
|
-
domain_name (~> 0.5)
|
23
|
-
httparty (0.13.7)
|
24
|
-
json (~> 1.8)
|
25
|
-
multi_xml (>= 0.5.2)
|
26
|
-
json (1.8.3)
|
27
|
-
minitar (0.5.4)
|
28
|
-
multi_xml (0.5.5)
|
29
|
-
rake (10.4.2)
|
30
|
-
rdoc (4.2.0)
|
31
|
-
json (~> 1.4)
|
32
|
-
terminal-table (1.5.2)
|
33
|
-
unf (0.1.4)
|
34
|
-
unf_ext
|
35
|
-
unf_ext (0.0.7.1)
|
36
|
-
|
37
|
-
PLATFORMS
|
38
|
-
ruby
|
39
|
-
|
40
|
-
DEPENDENCIES
|
41
|
-
cloudcover!
|
42
|
-
rake
|
43
|
-
rdoc
|
44
|
-
|
45
|
-
BUNDLED WITH
|
46
|
-
1.12.3
|