meroku 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -5
  3. data/bin/meroku +1 -1
  4. data/circle.yml +23 -0
  5. data/frontend/Gemfile +5 -2
  6. data/frontend/Gemfile.lock +5 -2
  7. data/frontend/app/controllers/application_controller.rb +1 -0
  8. data/frontend/app/controllers/apps_controller.rb +46 -48
  9. data/frontend/app/controllers/publickeys_controller.rb +45 -46
  10. data/frontend/app/controllers/users/registrations_controller.rb +0 -15
  11. data/frontend/app/controllers/users/sessions_controller.rb +12 -3
  12. data/frontend/app/lib/cmd.rb +11 -0
  13. data/frontend/app/models/app.rb +18 -11
  14. data/frontend/app/models/publickey.rb +1 -1
  15. data/frontend/app/models/user.rb +5 -4
  16. data/frontend/app/policies/application_policy.rb +53 -0
  17. data/frontend/app/policies/publickey_policy.rb +7 -0
  18. data/frontend/app/serializable/serializable_user.rb +2 -1
  19. data/frontend/app/views/layouts/application.html.erb +1 -1
  20. data/frontend/config/database.yml +72 -10
  21. data/frontend/config/routes.rb +6 -14
  22. data/frontend/db/migrate/20171028150506_add_apisecret_to_users.rb +6 -0
  23. data/frontend/etc_nginx_sites-enabled_default +1 -1
  24. data/frontend/public/Meroku.html +140 -0
  25. data/frontend/public/Meroku/Api.html +129 -0
  26. data/frontend/public/Meroku/Api/Request.html +221 -0
  27. data/frontend/public/Meroku/Aws.html +212 -0
  28. data/frontend/public/Meroku/Aws/Ec2.html +477 -0
  29. data/frontend/public/Meroku/CLI.html +784 -0
  30. data/frontend/public/Meroku/CLI/AdminUser.html +192 -0
  31. data/frontend/public/Meroku/CLI/Help.html +224 -0
  32. data/frontend/public/Meroku/CLI/Secrets.html +191 -0
  33. data/frontend/public/Meroku/CLI/Session.html +460 -0
  34. data/frontend/public/Meroku/CLI/User.html +182 -0
  35. data/frontend/public/Meroku/Extensions.html +405 -0
  36. data/frontend/public/Meroku/Infrastructure.html +279 -0
  37. data/frontend/public/Meroku/Infrastructure/Node.html +785 -0
  38. data/frontend/public/Meroku/Infrastructure/Server.html +373 -0
  39. data/frontend/public/Meroku/Node.html +845 -0
  40. data/frontend/public/Meroku/Tunnel.html +701 -0
  41. data/frontend/public/Meroku/Tunnelable.html +243 -0
  42. data/frontend/public/_index.html +273 -0
  43. data/frontend/public/class_list.html +51 -0
  44. data/frontend/public/css/common.css +1 -0
  45. data/frontend/public/css/full_list.css +58 -0
  46. data/frontend/public/css/style.css +492 -0
  47. data/frontend/public/file.README.html +181 -0
  48. data/frontend/public/file_list.html +56 -0
  49. data/frontend/public/frames.html +17 -0
  50. data/frontend/public/index.html +181 -0
  51. data/frontend/public/js/app.js +248 -0
  52. data/frontend/public/js/full_list.js +216 -0
  53. data/frontend/public/js/jquery.js +4 -0
  54. data/frontend/public/method_list.html +395 -0
  55. data/frontend/public/robots.txt +2 -1
  56. data/frontend/public/top-level-namespace.html +110 -0
  57. data/frontend/test/policies/publickey_policy_test.rb +19 -0
  58. data/lib/meroku.rb +9 -7
  59. data/lib/meroku/api.rb +8 -0
  60. data/lib/meroku/api/request.rb +17 -0
  61. data/lib/meroku/aws.rb +14 -0
  62. data/lib/meroku/aws/ec2.rb +59 -0
  63. data/lib/meroku/cli.rb +80 -81
  64. data/lib/meroku/cli/help.rb +27 -0
  65. data/lib/meroku/cli/secrets.rb +13 -0
  66. data/lib/meroku/cli/session.rb +32 -51
  67. data/lib/meroku/extensions.rb +32 -0
  68. data/lib/meroku/infrastructure.rb +14 -17
  69. data/lib/meroku/infrastructure/server.rb +20 -0
  70. data/lib/meroku/node.rb +113 -0
  71. data/lib/meroku/tunnelable.rb +31 -0
  72. data/lib/meroku/version.rb +1 -1
  73. data/modified-cedar-14.sh +0 -4
  74. metadata +50 -9
  75. data/frontend/app/controllers/pages_controller.rb +0 -4
  76. data/frontend/app/views/pages/landing.html.erb +0 -2
  77. data/frontend/db/migrate/20171025193627_add_token_to_users.rb +0 -5
  78. data/lib/meroku/cli/admin_user.rb +0 -20
  79. data/lib/meroku/cli/user.rb +0 -14
  80. data/lib/meroku/infrastructure/node.rb +0 -102
  81. data/lib/meroku/tunnel.rb +0 -56
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe2ff13db62d348c38f0c5e092867906f34b4ea2
4
- data.tar.gz: 86bdb03ea56d8c3f2e870dd26606eb7477829535
3
+ metadata.gz: ad5f5ca79ce1ebc9536a34a7914167cbe0b09838
4
+ data.tar.gz: 2aa86958df6a7fb04e8664fdb6c3235b6cd4dff6
5
5
  SHA512:
6
- metadata.gz: 73baef2c048146816a658c9a6dbac5bf9e28f3827a685ac246f41bef2f4ac7e75f902cad6e08a0be96b977d436d8bc4acec403f989ee8715712cc1a719016243
7
- data.tar.gz: 01156426d89e2cff0ef734707b17bf92982dc98644f88cb0990061394390c7b0a1c591b78f7177e672aa67ebf342c49dd02ca82920a1d5b317615b261fd9d2a8
6
+ metadata.gz: 9dcbd1a4a80ff721be16c9aa265067fe6167e7f08213df4bde6171e02074a7d1a9ef40e7b3751abbc7541e938ad2b9225a43dae2bd42024901648be44770c7cf
7
+ data.tar.gz: 00cffa6fe619cc4e0530690ad2043cb1f44c9673eed29ce7be03802fa21987d702072b45b2db20f5f6ee989cf9dc4d2656d3ee73d3ba786a5ed693cc0cc927c3
data/README.md CHANGED
@@ -79,7 +79,14 @@ You will need a copy of the file `.secret`. Place it at `~/.meroku/.secret`
79
79
  ### Commands
80
80
 
81
81
  $ meroku infrastructure spawn
82
+ $ meroku infrastructure despawn
82
83
 
84
+ $ rubocop -D -F --except FrozenStringLiteralComment,StringLiterals,MutableConstant lib/
85
+ Inspecting 15 files
86
+ ...............
87
+
88
+ 15 files inspected, no offenses detected
89
+ $
83
90
 
84
91
  ### TODO
85
92
 
@@ -88,11 +95,8 @@ You will need a copy of the file `.secret`. Place it at `~/.meroku/.secret`
88
95
  - Only RAILS_ENV=procution is supported at the moment
89
96
  - Only puma is supported at the moment
90
97
 
91
- - Database
92
- - User security / Lxc
93
- - Nightly spawn
94
-
95
- - respons time sanity check
98
+ - Nightly spawn
99
+ - respons time sanity check and full-lifecycle topics
96
100
  - piper visual check
97
101
  - some commodity apps
98
102
 
data/bin/meroku CHANGED
@@ -3,4 +3,4 @@
3
3
  $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
4
4
  require 'meroku'
5
5
 
6
- Meroku::CLI::Session.new(*ARGV)
6
+ Meroku::CLI::Session.new ARGV
data/circle.yml ADDED
@@ -0,0 +1,23 @@
1
+ general:
2
+ branches:
3
+ only:
4
+ - notmaster
5
+
6
+ machine:
7
+
8
+ timezone:
9
+ America/Los_Angeles # Set the timezone
10
+
11
+ dependencies:
12
+ override:
13
+ - echo
14
+
15
+ database:
16
+ override:
17
+ - echo
18
+
19
+ test:
20
+ override:
21
+ - ruby --version
22
+ - gem install meroku
23
+
data/frontend/Gemfile CHANGED
@@ -9,7 +9,7 @@ end
9
9
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
10
10
  gem 'rails', '~> 5.1.4'
11
11
  # Use sqlite3 as the database for Active Record
12
- gem 'sqlite3'
12
+ #gem 'sqlite3'
13
13
  # Use Puma as the app server
14
14
  gem 'puma', '~> 3.7'
15
15
  # Use SCSS for stylesheets
@@ -35,7 +35,7 @@ gem 'jbuilder', '~> 2.5'
35
35
 
36
36
  group :development, :test do
37
37
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
38
- gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
38
+ #gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
39
39
  # Adds support for Capybara system testing and selenium driver
40
40
  gem 'capybara', '~> 2.13'
41
41
  gem 'selenium-webdriver'
@@ -56,3 +56,6 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
56
56
  gem 'devise'
57
57
  gem 'jsonapi-rails'
58
58
  gem "active_model_serializers"
59
+ gem "pg"
60
+ gem "byebug"
61
+ gem "pundit"
@@ -118,8 +118,11 @@ GEM
118
118
  nokogiri (1.8.1)
119
119
  mini_portile2 (~> 2.3.0)
120
120
  orm_adapter (0.5.0)
121
+ pg (0.21.0)
121
122
  public_suffix (3.0.0)
122
123
  puma (3.10.0)
124
+ pundit (1.1.0)
125
+ activesupport (>= 3.0.0)
123
126
  rack (2.0.3)
124
127
  rack-test (0.7.0)
125
128
  rack (>= 1.0, < 3)
@@ -181,7 +184,6 @@ GEM
181
184
  actionpack (>= 4.0)
182
185
  activesupport (>= 4.0)
183
186
  sprockets (>= 3.0.0)
184
- sqlite3 (1.3.13)
185
187
  thor (0.20.0)
186
188
  thread_safe (0.3.6)
187
189
  tilt (2.0.8)
@@ -217,13 +219,14 @@ DEPENDENCIES
217
219
  jbuilder (~> 2.5)
218
220
  jsonapi-rails
219
221
  listen (>= 3.0.5, < 3.2)
222
+ pg
220
223
  puma (~> 3.7)
224
+ pundit
221
225
  rails (~> 5.1.4)
222
226
  sass-rails (~> 5.0)
223
227
  selenium-webdriver
224
228
  spring
225
229
  spring-watcher-listen (~> 2.0.0)
226
- sqlite3
227
230
  turbolinks (~> 5)
228
231
  tzinfo-data
229
232
  uglifier (>= 1.3.0)
@@ -1,3 +1,4 @@
1
1
  class ApplicationController < ActionController::Base
2
+ include Pundit
2
3
  protect_from_forgery with: :exception
3
4
  end
@@ -2,44 +2,42 @@ class AppsController < ApplicationController
2
2
  before_action :set_app, only: [:show, :edit, :update, :destroy]
3
3
  skip_before_action :verify_authenticity_token, only: [:create]
4
4
 
5
- # GET /apps
6
- # GET /apps.json
7
- def index
8
- @apps = App.all
9
- end
10
-
11
- # GET /apps/1
12
- # GET /apps/1.json
13
- def show
14
- end
15
-
16
- # GET /apps/new
17
- def new
18
- @app = App.new
19
- end
20
-
21
- # GET /apps/1/edit
22
- def edit
23
- end
5
+ ## GET /apps
6
+ ## GET /apps.json
7
+ #def index
8
+ # @apps = App.all
9
+ #end
10
+ #
11
+ ## GET /apps/1
12
+ ## GET /apps/1.json
13
+ #def show
14
+ #end
15
+ #
16
+ ## GET /apps/new
17
+ #def new
18
+ # @app = App.new
19
+ #end
20
+ #
21
+ ## GET /apps/1/edit
22
+ #def edit
23
+ #end
24
24
 
25
25
  # POST /apps
26
26
  # POST /apps.json
27
27
  def create
28
28
  @app = App.new(app_params)
29
- @app.name = SecureRandom.hex
30
- @app.user = User.find_by_token(params[:token])
29
+ @app.name = "app#{SecureRandom.hex[0..6]}"
30
+ @app.user = User.find_by_apisecret(params[:apisecret])
31
31
  if !@app.user
32
32
  (render :jsonapi_errors => [{
33
- title: 'Invalid Authorization Token',
34
- detail: 'Invalid token. Try logging in again.'
33
+ title: 'Authentication failed',
34
+ detail: 'Authentication failed'
35
35
  }]) and return
36
-
37
36
  end
38
37
 
39
38
  respond_to do |format|
40
39
  if @app.save
41
40
  format.html { redirect_to @app, notice: 'App was successfully created.' }
42
- #format.json { render :show, status: :created, location: @app }
43
41
  format.json { render jsonapi: @app }
44
42
  else
45
43
  format.html { render :new }
@@ -48,29 +46,29 @@ class AppsController < ApplicationController
48
46
  end
49
47
  end
50
48
 
51
- # PATCH/PUT /apps/1
52
- # PATCH/PUT /apps/1.json
53
- def update
54
- respond_to do |format|
55
- if @app.update(app_params)
56
- format.html { redirect_to @app, notice: 'App was successfully updated.' }
57
- format.json { render :show, status: :ok, location: @app }
58
- else
59
- format.html { render :edit }
60
- format.json { render json: @app.errors, status: :unprocessable_entity }
61
- end
62
- end
63
- end
64
-
65
- # DELETE /apps/1
66
- # DELETE /apps/1.json
67
- def destroy
68
- @app.destroy
69
- respond_to do |format|
70
- format.html { redirect_to apps_url, notice: 'App was successfully destroyed.' }
71
- format.json { head :no_content }
72
- end
73
- end
49
+ ## PATCH/PUT /apps/1
50
+ ## PATCH/PUT /apps/1.json
51
+ #def update
52
+ # respond_to do |format|
53
+ # if @app.update(app_params)
54
+ # format.html { redirect_to @app, notice: 'App was successfully updated.' }
55
+ # format.json { render :show, status: :ok, location: @app }
56
+ # else
57
+ # format.html { render :edit }
58
+ # format.json { render json: @app.errors, status: :unprocessable_entity }
59
+ # end
60
+ # end
61
+ #end
62
+ #
63
+ ## DELETE /apps/1
64
+ ## DELETE /apps/1.json
65
+ #def destroy
66
+ # @app.destroy
67
+ # respond_to do |format|
68
+ # format.html { redirect_to apps_url, notice: 'App was successfully destroyed.' }
69
+ # format.json { head :no_content }
70
+ # end
71
+ #end
74
72
 
75
73
  private
76
74
  # Use callbacks to share common setup or constraints between actions.
@@ -2,42 +2,41 @@ class PublickeysController < ApplicationController
2
2
  before_action :set_publickey, only: [:show, :edit, :update, :destroy]
3
3
  skip_before_action :verify_authenticity_token, only: [:create]
4
4
 
5
- # GET /publickeys
6
- # GET /publickeys.json
7
- def index
8
- @publickeys = Publickey.all
9
- end
10
-
11
- # GET /publickeys/1
12
- # GET /publickeys/1.json
13
- def show
14
- end
15
-
16
- # GET /publickeys/new
17
- def new
18
- @publickey = Publickey.new
19
- end
20
-
21
- # GET /publickeys/1/edit
22
- def edit
23
- end
5
+ ## GET /publickeys
6
+ ## GET /publickeys.json
7
+ #def index
8
+ # @publickeys = Publickey.all
9
+ #end
10
+ #
11
+ ## GET /publickeys/1
12
+ ## GET /publickeys/1.json
13
+ #def show
14
+ #end
15
+ #
16
+ ## GET /publickeys/new
17
+ #def new
18
+ # @publickey = Publickey.new
19
+ #end
20
+ #
21
+ ## GET /publickeys/1/edit
22
+ #def edit
23
+ #end
24
24
 
25
25
  # POST /publickeys
26
26
  # POST /publickeys.json
27
27
  def create
28
28
  @publickey = Publickey.new(publickey_params)
29
- @publickey.user = User.find_by_token(params[:token])
29
+ @publickey.user = User.find_by_apisecret(params[:apisecret])
30
30
  if !@publickey.user
31
31
  (render :jsonapi_errors => [{
32
- title: 'Invalid Authorization Token',
33
- detail: 'Invalid token. Try logging in again.'
32
+ title: 'Authentiction failed',
33
+ detail: 'Invalid Authentication failed. Try logging in again.'
34
34
  }]) and return
35
35
  end
36
36
 
37
37
  respond_to do |format|
38
38
  if @publickey.save
39
39
  format.html { redirect_to @publickey, notice: 'Publickey was successfully created.' }
40
- #format.json { render :show, status: :created, location: @publickey }
41
40
  format.json { render jsonapi: @publickey }
42
41
  else
43
42
  format.html { render :new }
@@ -46,29 +45,29 @@ class PublickeysController < ApplicationController
46
45
  end
47
46
  end
48
47
 
49
- # PATCH/PUT /publickeys/1
50
- # PATCH/PUT /publickeys/1.json
51
- def update
52
- respond_to do |format|
53
- if @publickey.update(publickey_params)
54
- format.html { redirect_to @publickey, notice: 'Publickey was successfully updated.' }
55
- format.json { render :show, status: :ok, location: @publickey }
56
- else
57
- format.html { render :edit }
58
- format.json { render json: @publickey.errors, status: :unprocessable_entity }
59
- end
60
- end
61
- end
62
-
63
- # DELETE /publickeys/1
64
- # DELETE /publickeys/1.json
65
- def destroy
66
- @publickey.destroy
67
- respond_to do |format|
68
- format.html { redirect_to publickeys_url, notice: 'Publickey was successfully destroyed.' }
69
- format.json { head :no_content }
70
- end
71
- end
48
+ ## PATCH/PUT /publickeys/1
49
+ ## PATCH/PUT /publickeys/1.json
50
+ #def update
51
+ # respond_to do |format|
52
+ # if @publickey.update(publickey_params)
53
+ # format.html { redirect_to @publickey, notice: 'Publickey was successfully updated.' }
54
+ # format.json { render :show, status: :ok, location: @publickey }
55
+ # else
56
+ # format.html { render :edit }
57
+ # format.json { render json: @publickey.errors, status: :unprocessable_entity }
58
+ # end
59
+ # end
60
+ #end
61
+ #
62
+ ## DELETE /publickeys/1
63
+ ## DELETE /publickeys/1.json
64
+ #def destroy
65
+ # @publickey.destroy
66
+ # respond_to do |format|
67
+ # format.html { redirect_to publickeys_url, notice: 'Publickey was successfully destroyed.' }
68
+ # format.json { head :no_content }
69
+ # end
70
+ #end
72
71
 
73
72
  private
74
73
  # Use callbacks to share common setup or constraints between actions.
@@ -13,31 +13,16 @@ class Users::RegistrationsController < Devise::RegistrationsController
13
13
 
14
14
  # POST /resource
15
15
  def create
16
- #super
17
16
  build_resource(sign_up_params)
18
17
 
19
18
  resource.save
20
19
  yield resource if block_given?
21
20
  if resource.persisted?
22
- #render jsonapi: resource
23
21
  render jsonapi: resource
24
- #if resource.active_for_authentication?
25
- # set_flash_message! :notice, :signed_up
26
- # sign_up(resource_name, resource)
27
- # respond_with resource, location: after_sign_up_path_for(resource)
28
- #else
29
- # set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
30
- # expire_data_after_sign_in!
31
- # respond_with resource, location: after_inactive_sign_up_path_for(resource)
32
- #end
33
22
  else
34
23
  clean_up_passwords resource
35
24
  set_minimum_password_length
36
- ##respond_with resource
37
- #warden.custom_failure!
38
- #render :json=> resource.errors, :status=>422
39
25
  render jsonapi_errors: resource.errors
40
- #render json: {status: 'SUCCESS', message: resource.errors.full_messages}, status: 422
41
26
  end
42
27
  end
43
28
 
@@ -1,5 +1,7 @@
1
1
  class Users::SessionsController < Devise::SessionsController
2
2
  # before_action :configure_sign_in_params, only: [:create]
3
+ skip_before_action :verify_authenticity_token, only: [:create]
4
+ respond_to :json
3
5
 
4
6
  # GET /resource/sign_in
5
7
  # def new
@@ -7,9 +9,16 @@ class Users::SessionsController < Devise::SessionsController
7
9
  # end
8
10
 
9
11
  # POST /resource/sign_in
10
- # def create
11
- # super
12
- # end
12
+ def create
13
+ self.resource = warden.authenticate(auth_options)
14
+ if self.resource
15
+ render jsonapi: self.resource
16
+ else
17
+ render json: {
18
+ "errors": [ { "detail": "Authentication failed" } ]
19
+ }
20
+ end
21
+ end
13
22
 
14
23
  # DELETE /resource/sign_out
15
24
  # def destroy
@@ -0,0 +1,11 @@
1
+ module Cmd
2
+
3
+
4
+ def self.run(cmd)
5
+ require 'open3'
6
+ Rails.logger.debug "DB8 Running\n#{cmd[0..180]}"
7
+ stdout, stderr, status = Open3.capture3(cmd)
8
+ Rails.logger.debug "DB8\nstatus:#{status}\nstdout:#{stdout}\nstderr:#{stderr}"
9
+ end
10
+
11
+ end