json_voorhees 1.4.2 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85db652f4df886f9e564573f69313155cc208c09
4
- data.tar.gz: 5c34d2f12abcff0f7619146d7b3f49b75de9d5db
3
+ metadata.gz: c6f2eab0df10d6e1e8ad40dc83e8102b3fe18675
4
+ data.tar.gz: f7f6418c6be9c0bc139c57af5c8c61c056f10a78
5
5
  SHA512:
6
- metadata.gz: d53425a719f8ee49b347cd07f9ab52bd99febbec580557986f64b33110c4056ff92c6763240801fe0a201b57b758dff9a6f0fe070587aa4ed7fe0e5b6de2a9e7
7
- data.tar.gz: 709fa8e55311d4f7d4f09252f0348072ee8a902cb706824d7a932cf5251bd7c711c3790fa7c0551764e232b72a4d91fe8453d12dfc1258db10ffa7fb91a3528e
6
+ metadata.gz: 27c697b7b514b85030cb972a84bc1aec83112e9c46b9dc60b64de4b35147db7abaea155ec24e3508d73203e76ca87c6267ca83bb08bde8b715064fa629243b01
7
+ data.tar.gz: 89e6cbe41f549e99f9104fb984f7dcfe2edbd4e26d7e460caf18c9e3e3f5ddc712d0d244210edc02604e7c35dbaabce12e3985b4005b4a7be13a2a102c5552dd
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # JsonVoorhees 1.4.2
1
+ # JsonVoorhees 1.4.5
2
2
 
3
3
  ## Introduction
4
4
 
@@ -56,6 +56,15 @@ I usually set the app up, and then design the database. I make a list of all the
56
56
 
57
57
  ## Gotchas and Reminders
58
58
 
59
+ After authenticating the user, routes will by default require the users token
60
+ to be sent with every request. This can be disabled by skipping the filter in
61
+ the controller. If you want to set the user optionally, call set_hash. It wont
62
+ return an error if the user can't be authenticated. In addition, every request
63
+ to the api will need the api token sent with it. It can exist in either the
64
+ headers or params hash. Look at the settings file in config to see what the
65
+ default header and keys are. In production, make sure this key is set to
66
+ something different and remove it from version control.
67
+
59
68
  1. Make sure the version of Rails is the same in both engine and app.
60
69
  2. The mailer doesn't need to be set up. For test and development it is set so this doesn't have to be the case but change the environment config file to make it work.
61
70
  3. To use the mailer, make sure to export GMAIL_USERNAME and GMAIL_PASSWORD to your environment. Or you can just overwrite the values in the environment config file.
@@ -76,4 +85,4 @@ Does not work with Rails 4.2 yet. Byebug is added by default and this generator
76
85
  4. App tokens
77
86
 
78
87
  Emails are sent synchronously for now. I'm waiting for ActiveJob in Rails 4.2 so I can
79
- implement that interface and user the sidekiq adapter.
88
+ implement that interface and use the sidekiq adapter.
@@ -15,7 +15,20 @@ module JsonVoorhees
15
15
  def createSettings
16
16
  run "rails g rails_config:install"
17
17
  prepend_to_file 'config/settings.yml' do
18
- "token_header: \"Auth_Token\"\napi_header: \"Api_Token\"\n"
18
+ "token_header: \"Auth_Token\"\nmain_api_header: \"Main_Api_Header\"\n"
19
+ end
20
+ createEnvSettings
21
+ end
22
+
23
+ def createEnvSettings
24
+ prepend_to_file 'config/settings/development.yml' do
25
+ "main_api_key: \"123456789\"\n"
26
+ end
27
+ prepend_to_file 'config/settings/test.yml' do
28
+ "main_api_key: \"123456789\"\n"
29
+ end
30
+ prepend_to_file 'config/settings/production.yml' do
31
+ "main_api_key: \"123456789\"\n"
19
32
  end
20
33
  end
21
34
 
@@ -6,7 +6,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
6
6
  before(:example) do
7
7
  @user = FactoryGirl.create(:fbuser_user_1)
8
8
  token = @user.tokens[0].auth_token
9
- @header = {::Settings.token_header => token}
9
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
10
10
  end
11
11
  # get /api/<%= api_version %>/<%= resource_plural %>
12
12
  it "Gets all of the <%= resource_singular %>s" do
@@ -23,7 +23,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
23
23
  before(:example) do
24
24
  @user = FactoryGirl.create(:fbuser_user_1)
25
25
  token = @user.tokens[0].auth_token
26
- @header = {::Settings.token_header => token}
26
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
27
27
  end
28
28
  # get /api/<%= api_version %>/<%= resource_plural %>/1
29
29
  it "Gets a <%= resource_singular %> by id" do
@@ -38,7 +38,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
38
38
  before(:example) do
39
39
  @user = FactoryGirl.create(:fbuser_user_1)
40
40
  token = @user.tokens[0].auth_token
41
- @header = {::Settings.token_header => token}
41
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
42
42
  end
43
43
  # post /api/<%= api_version %>/<%= resource_plural %>
44
44
  it "Creates <%= resource_singular %>" do
@@ -55,7 +55,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
55
55
  before(:example) do
56
56
  @user = FactoryGirl.create(:fbuser_user_1)
57
57
  token = @user.tokens[0].auth_token
58
- @header = {::Settings.token_header => token}
58
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
59
59
  end
60
60
  # patch/put /api/<%= api_version %>/<%= resource_plural %>/1
61
61
  it "Updates <%= resource_singular %>" do
@@ -74,7 +74,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
74
74
  before(:example) do
75
75
  @user = FactoryGirl.create(:fbuser_user_1)
76
76
  token = @user.tokens[0].auth_token
77
- @header = {::Settings.token_header => token}
77
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
78
78
  end
79
79
  # delete /api/<%= api_version %>/<%= resource_plural %>/1
80
80
  it "Deletes <%= resource_singular %>" do
@@ -97,7 +97,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
97
97
  before(:example) do
98
98
  @user = FactoryGirl.create(:fbuser_user_1)
99
99
  token = @user.tokens[0].auth_token
100
- @header = {::Settings.token_header => token}
100
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
101
101
  end
102
102
  # get /api/1/collection
103
103
  it "checks response of a collection route" do
@@ -111,7 +111,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
111
111
  before(:example) do
112
112
  @user = FactoryGirl.create(:fbuser_user_1)
113
113
  token = @user.tokens[0].auth_token
114
- @header = {::Settings.token_header => token}
114
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
115
115
  end
116
116
  it "checks the index json sent back" do
117
117
 
@@ -124,7 +124,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
124
124
  before(:example) do
125
125
  @user = FactoryGirl.create(:fbuser_user_1)
126
126
  token = @user.tokens[0].auth_token
127
- @header = {::Settings.token_header => token}
127
+ @header = {::Settings.token_header => token, ::Settings.main_api_header => ::Settings.main_api_key}
128
128
  end
129
129
  # get /api/<%= api_version %>/<%= resource_plural %>/1
130
130
  it "checks for a 404" do
@@ -6,7 +6,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
6
6
  before(:example) do
7
7
  @user = FactoryGirl.create(:people_user_1)
8
8
  token = @user.tokens[0].auth_token
9
- @header = {::Settings.token_header => token, "Email" => @user.email}
9
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
10
10
  end
11
11
  # get /api/<%= api_version %>/<%= resource_plural %>
12
12
  it "Gets all of the <%= resource_singular %>s" do
@@ -23,7 +23,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
23
23
  before(:example) do
24
24
  @user = FactoryGirl.create(:people_user_1)
25
25
  token = @user.tokens[0].auth_token
26
- @header = {::Settings.token_header => token, "Email" => @user.email}
26
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
27
27
  end
28
28
  # get /api/<%= api_version %>/<%= resource_plural %>/1
29
29
  it "Gets a <%= resource_singular %> by id" do
@@ -38,7 +38,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
38
38
  before(:example) do
39
39
  @user = FactoryGirl.create(:people_user_1)
40
40
  token = @user.tokens[0].auth_token
41
- @header = {::Settings.token_header => token, "Email" => @user.email}
41
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
42
42
  end
43
43
  # post /api/<%= api_version %>/<%= resource_plural %>
44
44
  it "Creates <%= resource_singular %>" do
@@ -55,7 +55,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
55
55
  before(:example) do
56
56
  @user = FactoryGirl.create(:people_user_1)
57
57
  token = @user.tokens[0].auth_token
58
- @header = {::Settings.token_header => token, "Email" => @user.email}
58
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
59
59
  end
60
60
  # patch/put /api/<%= api_version %>/<%= resource_plural %>/1
61
61
  it "Updates <%= resource_singular %>" do
@@ -74,7 +74,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
74
74
  before(:example) do
75
75
  @user = FactoryGirl.create(:people_user_1)
76
76
  token = @user.tokens[0].auth_token
77
- @header = {::Settings.token_header => token, "Email" => @user.email}
77
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
78
78
  end
79
79
  # delete /api/<%= api_version %>/<%= resource_plural %>/1
80
80
  it "Deletes <%= resource_singular %>" do
@@ -97,7 +97,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
97
97
  before(:example) do
98
98
  @user = FactoryGirl.create(:people_user_1)
99
99
  token = @user.tokens[0].auth_token
100
- @header = {::Settings.token_header => token, "Email" => @user.email}
100
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
101
101
  end
102
102
  # get /api/1/collection
103
103
  it "checks response of a collection route" do
@@ -111,7 +111,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
111
111
  before(:example) do
112
112
  @user = FactoryGirl.create(:people_user_1)
113
113
  token = @user.tokens[0].auth_token
114
- @header = {::Settings.token_header => token, "Email" => @user.email}
114
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
115
115
  end
116
116
  it "checks the index json sent back" do
117
117
 
@@ -124,7 +124,7 @@ RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>
124
124
  before(:example) do
125
125
  @user = FactoryGirl.create(:people_user_1)
126
126
  token = @user.tokens[0].auth_token
127
- @header = {::Settings.token_header => token, "Email" => @user.email}
127
+ @header = {::Settings.token_header => token, "Email" => @user.email, ::Settings.main_api_header => ::Settings.main_api_key}
128
128
  end
129
129
  # get /api/<%= api_version %>/<%= resource_plural %>/1
130
130
  it "checks for a 404" do
@@ -9,7 +9,7 @@ module JsonVoorhees
9
9
  def sprint
10
10
  run "rails g json_voorhees:app_make_authorizations #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
11
11
  if Kernel.const_defined?("Fbuser")
12
- run "rails g json_voorhees:app_make_tests --fbonly #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
12
+ run "rails g json_voorhees:app_make_tests #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")} --fbonly"
13
13
  else
14
14
  run "rails g json_voorhees:app_make_tests #{module_name} #{resource_name} #{api_version} #{attributes.join(" ")}"
15
15
  end
@@ -1,12 +1,16 @@
1
1
  class Api::V1::ApiController < ::ActionController::API
2
2
 
3
- #before_action :authenticate_app
3
+ before_action :authenticate_app
4
4
  before_action :authenticate_user
5
5
 
6
6
  private
7
7
 
8
- #def authenticate_app
9
- #end
8
+ def authenticate_app
9
+ api_key = ::Arcadex::Header.grab_param_header(params,request,::Settings.main_api_header,false)
10
+ if api_key.nil? || api_key != ::Settings.main_api_key
11
+ render :json => {errors: "App is not authorized"} , status: :forbidden
12
+ end
13
+ end
10
14
 
11
15
  def authenticate_user
12
16
  set_hash
@@ -1,3 +1,3 @@
1
1
  module JsonVoorhees
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_voorhees
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cleophus Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-14 00:00:00.000000000 Z
11
+ date: 2014-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails