fenton_shell 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE +201 -0
- data/README.md +93 -0
- data/Rakefile +84 -0
- data/bin/fenton +267 -0
- data/lib/Icon/r +0 -0
- data/lib/fenton_shell.rb +15 -0
- data/lib/fenton_shell/Icon/r +0 -0
- data/lib/fenton_shell/certificate.rb +83 -0
- data/lib/fenton_shell/client.rb +92 -0
- data/lib/fenton_shell/config_file.rb +122 -0
- data/lib/fenton_shell/key.rb +71 -0
- data/lib/fenton_shell/organization.rb +70 -0
- data/lib/fenton_shell/project.rb +91 -0
- data/lib/fenton_shell/version.rb +5 -0
- metadata +280 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
module FentonShell
|
2
|
+
# Interfaces with the project api on fenton server
|
3
|
+
class Project
|
4
|
+
# @!attribute [r] message
|
5
|
+
# @return [String] success or failure message and why
|
6
|
+
attr_accessor :message
|
7
|
+
|
8
|
+
# Creates a new project on fenton server by sending a post
|
9
|
+
# request with json from the command line to create the project
|
10
|
+
#
|
11
|
+
# @param global_options [Hash] global command line options
|
12
|
+
# @param options [Hash] json fields to send to fenton server
|
13
|
+
# @return [String] success or failure message
|
14
|
+
|
15
|
+
def create(global_options, options)
|
16
|
+
status, body = project_create(global_options, options)
|
17
|
+
|
18
|
+
if status == 201
|
19
|
+
save_message(create_success_message(body))
|
20
|
+
true
|
21
|
+
else
|
22
|
+
parse_message(body)
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def create_success_message(body)
|
30
|
+
msg = "Project Created! Below is the public key to add to the server.\n\n"
|
31
|
+
msg << "#{body['data']['attributes']['ca-public-key']}\n\n"
|
32
|
+
msg << "Add the public key above to /etc/ssh/trusted_user_ca_key\n\n"
|
33
|
+
msg << "Add this line to /etc/ssh/sshd_config\n"
|
34
|
+
msg << " TrustedUserCAKeys /etc/ssh/trusted_user_ca_key\n\n"
|
35
|
+
msg << "Run these commands:\n"
|
36
|
+
msg << ' chmod 644 /etc/ssh/trusted_user_ca_key && ' \
|
37
|
+
"service ssh restart\n\n"
|
38
|
+
msg << 'Now have Fenton Server sign your public key to ' \
|
39
|
+
"login to the server\n"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Sends a post request with json from the command line client
|
43
|
+
#
|
44
|
+
# @param global_options [Hash] global command line options
|
45
|
+
# @param options [Hash] json fields to send to fenton server
|
46
|
+
# @return [Fixnum] http status code
|
47
|
+
# @return [String] message back from fenton server
|
48
|
+
def project_create(global_options, options)
|
49
|
+
result = Excon.post(
|
50
|
+
"#{global_options[:fenton_server_url]}/projects.json",
|
51
|
+
body: project_json(options),
|
52
|
+
headers: { 'Content-Type' => 'application/json' }
|
53
|
+
)
|
54
|
+
|
55
|
+
[result.status, JSON.parse(result.body)]
|
56
|
+
end
|
57
|
+
|
58
|
+
# Formulates the project json for the post request
|
59
|
+
#
|
60
|
+
# @param options [Hash] fields from fenton command line
|
61
|
+
# @return [String] json created from the options hash
|
62
|
+
def project_json(options)
|
63
|
+
{
|
64
|
+
project: {
|
65
|
+
name: options[:name],
|
66
|
+
description: options[:description],
|
67
|
+
passphrase: options[:passphrase],
|
68
|
+
key: options[:key],
|
69
|
+
organization: options[:organization]
|
70
|
+
}
|
71
|
+
}.to_json
|
72
|
+
end
|
73
|
+
|
74
|
+
# Helps output the error message from fenton server
|
75
|
+
#
|
76
|
+
# @param msg [Hash] fields from fenton public classes
|
77
|
+
# @return [String] changed hash fields to string for command line output
|
78
|
+
def parse_message(msg = {})
|
79
|
+
self.message ||= ''
|
80
|
+
|
81
|
+
msg.each do |key, value|
|
82
|
+
self.message << "#{key.capitalize} #{value.first}\n"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def save_message(msg)
|
87
|
+
self.message ||= ''
|
88
|
+
self.message << msg.to_s
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
metadata
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fenton_shell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Willever
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRUwEwYDVQQDDAxuaWNr
|
14
|
+
d2lsbGV2ZXIxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
|
15
|
+
A2NvbTAeFw0xNjAxMjYwMjQ5MDRaFw0xNzAxMjUwMjQ5MDRaMEMxFTATBgNVBAMM
|
16
|
+
DG5pY2t3aWxsZXZlcjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
|
17
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAynzXUa0I
|
18
|
+
pZLVBoUR8uz8MojY/0ghnrCBnHJxht8f//uwUhRkgGQVGZXcOB9m8GTGz6Ei8od2
|
19
|
+
5OCzv6GUE4fqX65v3YNRHqtiLYUu8KDxWfWey8091lx8T9S10jQ4h6iAcodeLIEt
|
20
|
+
a/U6BLTb+3+Zys5lm/Epcs4ClhLP0JjF+8vJaCDEZtPOrl7T80kNkdY39D4G7rWX
|
21
|
+
jx9RZ8XlMR/tstJLes8GFi/SeCe5oBJjKoUc4NeXWe1qUQs3IWS31A/SHub6hIt7
|
22
|
+
4dBOYxEZfkOHhiKHJQu8gzB0Cvk/YDdddhVTQ2Gj3Yeg4OfLrQ53jg6kJ+iIoypP
|
23
|
+
nXb4eF4FwrRAQQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
+
HQ4EFgQUX4HwVDhB7ubeeSAm4aPJusRnsuQwIQYDVR0RBBowGIEWbmlja3dpbGxl
|
25
|
+
dmVyQGdtYWlsLmNvbTAhBgNVHRIEGjAYgRZuaWNrd2lsbGV2ZXJAZ21haWwuY29t
|
26
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBxOiYkWNexvtJ8KXKuTlmFa+hYC8L6myPGxtW9
|
27
|
+
Npj5L6VtAEZ/uKG9L9YUEGsYKqH2DQOH+LKmaIeDFKbcD/aCPBs3XuJ49xJ4pCF1
|
28
|
+
vwbYQdIO1soU8SVuigK2jMm6171m0lvytC4U6Yxd2dXo/SWAUpRLXiYfEg9udhEM
|
29
|
+
hxdFNaWPYzY6jgIx9Jqe2ELfzfxXNxYsCwjSZ5zUsmldLkrIVA3Ur6QpMSFK6ByP
|
30
|
+
sv70kP++8jtwDXzjWuNrZm5jg0CB+8WhtTCFTvHauMs94gbP6bK+cbYGfRx+4Ezs
|
31
|
+
NtVr/SVaHNU0xIf8bkxswQ4zTyZKgO4MBkQHQ2dd84fcxCTn
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2016-11-25 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: excon
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.45.4
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.45.4
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: gli
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.13.4
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.13.4
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: json
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.3
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.8.3
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: sshkey
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.8.0
|
84
|
+
type: :runtime
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.8.0
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: highline
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.7.8
|
98
|
+
type: :runtime
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.7.8
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rake
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: aruba
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: minitest
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: test-unit
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: yard
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: rubocop
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
- !ruby/object:Gem::Dependency
|
190
|
+
name: bundler-audit
|
191
|
+
requirement: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
type: :development
|
197
|
+
prerelease: false
|
198
|
+
version_requirements: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
- !ruby/object:Gem::Dependency
|
204
|
+
name: rubycritic
|
205
|
+
requirement: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
type: :development
|
211
|
+
prerelease: false
|
212
|
+
version_requirements: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
- !ruby/object:Gem::Dependency
|
218
|
+
name: mixlib-shellout
|
219
|
+
requirement: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
type: :development
|
225
|
+
prerelease: false
|
226
|
+
version_requirements: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
description: A command line client to manage and sign SSH keys via Fenton Server
|
232
|
+
email:
|
233
|
+
- nickwillever@gmail.com
|
234
|
+
executables:
|
235
|
+
- fenton
|
236
|
+
extensions: []
|
237
|
+
extra_rdoc_files:
|
238
|
+
- README.md
|
239
|
+
- LICENSE
|
240
|
+
files:
|
241
|
+
- LICENSE
|
242
|
+
- README.md
|
243
|
+
- Rakefile
|
244
|
+
- bin/fenton
|
245
|
+
- "lib/Icon\r"
|
246
|
+
- lib/fenton_shell.rb
|
247
|
+
- "lib/fenton_shell/Icon\r"
|
248
|
+
- lib/fenton_shell/certificate.rb
|
249
|
+
- lib/fenton_shell/client.rb
|
250
|
+
- lib/fenton_shell/config_file.rb
|
251
|
+
- lib/fenton_shell/key.rb
|
252
|
+
- lib/fenton_shell/organization.rb
|
253
|
+
- lib/fenton_shell/project.rb
|
254
|
+
- lib/fenton_shell/version.rb
|
255
|
+
homepage: https://github.com/fenton-project/fenton_shell
|
256
|
+
licenses:
|
257
|
+
- Apache License, Version 2.0
|
258
|
+
metadata: {}
|
259
|
+
post_install_message:
|
260
|
+
rdoc_options:
|
261
|
+
- "--charset=UTF-8"
|
262
|
+
require_paths:
|
263
|
+
- lib
|
264
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
265
|
+
requirements:
|
266
|
+
- - ">="
|
267
|
+
- !ruby/object:Gem::Version
|
268
|
+
version: '0'
|
269
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
|
+
requirements:
|
271
|
+
- - ">="
|
272
|
+
- !ruby/object:Gem::Version
|
273
|
+
version: '0'
|
274
|
+
requirements: []
|
275
|
+
rubyforge_project:
|
276
|
+
rubygems_version: 2.6.6
|
277
|
+
signing_key:
|
278
|
+
specification_version: 4
|
279
|
+
summary: A command line client to manage and sign SSH keys via Fenton Server
|
280
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|