jive_add_ons 0.0.3 → 0.0.4

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: cbc43da36079246f39d21c6ec77638006aff71a2
4
- data.tar.gz: 69e6e13c6ee25d0c182da724e4df3f8b4923469f
3
+ metadata.gz: db5c3009d178a5f4bd98f1ffb3f96cceda58d97c
4
+ data.tar.gz: d3535453a8cfd4b4ad9305e416cc03f536ca962f
5
5
  SHA512:
6
- metadata.gz: cda670200ca20a2aa1a91c91993e25d6f906e9a0e136dfe561025633f86021295f81c268ade39cf954ec6676a79f3f377963a16476660dd1b7960d14c32ff612
7
- data.tar.gz: b162d46838951280132d7196bea4ea369044dbbc0fe307f0b6b3b2328cd88620eb19158a44c66efaff48c1d273fed99b449a8dedd68979346553e79a7a8fe00c
6
+ metadata.gz: b9506516eef2d91dbcf74720c22038331aa545853b8984e6374fa118c0b6c579afe25cff6881950e933edeed202bff6cfc79f3c6e824ae78b6e8ef69fcbdbe23
7
+ data.tar.gz: fc51562a5336a430c9af5022854e38ceefc2940fdeac766e786ee53b0fa72dd4d37a2dea73cf21d74a22e7b6ee6424423128f7f9f5aa43c085a49ef74b8417a3
@@ -11,8 +11,10 @@ end
11
11
  module JiveAddOns
12
12
  class AddOnsController < ApplicationController
13
13
  include Concerns::Controllers::AddOns
14
- rescue_from ActionController::BadRequest, :with => :failure
14
+ rescue_from ActionController::BadRequest, :with => :failure_403
15
+ rescue_from ActionController::UnknownController, :with => :failure_404
15
16
 
16
17
  before_filter :validate_authenticity
18
+ before_filter :validate_add_on_name
17
19
  end
18
20
  end
@@ -1,4 +1,4 @@
1
1
  module JiveAddOns
2
- class ApplicationController < ActionController::Base
3
- end
2
+ class ApplicationController < ActionController::Base
3
+ end
4
4
  end
data/config/routes.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  JiveAddOns::Engine.routes.draw do
2
- post ':add_on_name/register' => "add_ons#create", :as => :register_add_on
3
- post ':add_on_name/unregister' => "add_ons#destroy", :as => :unregister_add_on
4
-
5
- mount JiveOsApps::Engine => "/osapps"
6
- end
2
+ post ':name/register' => "add_ons#create", :as => :register_add_on
3
+ post ':name/unregister' => "add_ons#destroy", :as => :unregister_add_on
4
+ end
@@ -1,6 +1,7 @@
1
1
  class CreateJiveAddOns < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :jive_add_ons do |t|
4
+ t.string :name
4
5
  t.string :tenant_id
5
6
  t.string :client_id
6
7
  t.string :client_secret
@@ -6,6 +6,7 @@ module JiveAddOns
6
6
 
7
7
  def create
8
8
  @add_on = JiveAddOns::AddOn.new(register_params)
9
+ @add_on.name = params[:name]
9
10
  @add_on.uninstalled = false
10
11
  @add_on.save
11
12
 
@@ -20,13 +21,28 @@ module JiveAddOns
20
21
  end
21
22
 
22
23
  protected
24
+ def validate_add_on_name
25
+ # Add on name is whitelisted
26
+ if JiveAddOns.config.whitelist.length > 0 && !JiveAddOns.config.whitelist.include?(params[:name])
27
+ raise ActionController::UnknownController
28
+ end
29
+ # Add on name is blacklisted
30
+ if JiveAddOns.config.blacklist.length > 0 && JiveAddOns.config.blacklist.include?(params[:name])
31
+ raise ActionController::UnknownController
32
+ end
33
+ end
34
+
23
35
  def validate_authenticity
24
36
  if !::Jive::SignedRequest.validate_registration(json_params)
25
37
  raise ActionController::BadRequest
26
38
  end
27
39
  end
28
40
 
29
- def failure
41
+ def failure_404
42
+ render :nothing => true, :status => 404
43
+ end
44
+
45
+ def failure_403
30
46
  render :nothing => true, :status => 403
31
47
  end
32
48
 
@@ -10,4 +10,21 @@ module JiveAddOns
10
10
  end
11
11
  end
12
12
  end
13
+
14
+ def self.setup(&block)
15
+ @@config ||= JiveAddOns::Engine::Configuration.new
16
+
17
+ # Whitelist specific add-on names
18
+ @@config.whitelist = []
19
+ # Blacklist specific add-on names
20
+ @@config.blacklist = []
21
+
22
+ yield @@config if block
23
+
24
+ return @@config
25
+ end
26
+
27
+ def self.config
28
+ Rails.application.config
29
+ end
13
30
  end
@@ -1,3 +1,3 @@
1
1
  module JiveAddOns
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jive_add_ons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Butch Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-21 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 4.2.5
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 4.2.5
27
- - !ruby/object:Gem::Dependency
28
- name: jive_os_apps
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 0.0.1
19
+ version: 4.2.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: 0.0.1
26
+ version: 4.2.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: jive-signed_request
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,34 +108,6 @@ dependencies:
122
108
  - - ">="
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rack-cors
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: angular-ui-bootstrap-rails
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
111
  description: Api endpoints for making your platform Jive ready.
154
112
  email:
155
113
  - butch.a.marshall@gmail.com