bsm_oa 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +180 -0
- data/Rakefile +21 -0
- data/app/controllers/bsm_oa/accounts_controller.rb +12 -0
- data/app/controllers/bsm_oa/applications_controller.rb +35 -0
- data/app/controllers/bsm_oa/authorizations_controller.rb +80 -0
- data/app/controllers/bsm_oa/roles_controller.rb +58 -0
- data/app/views/bsm_oa/accounts/show.json.jbuilder +7 -0
- data/app/views/bsm_oa/applications/_application.html.erb +15 -0
- data/app/views/bsm_oa/applications/_application.json.jbuilder +1 -0
- data/app/views/bsm_oa/applications/_inputs.html.erb +11 -0
- data/app/views/bsm_oa/applications/create.json.jbuilder +1 -0
- data/app/views/bsm_oa/applications/edit.html.erb +10 -0
- data/app/views/bsm_oa/applications/index.html.erb +24 -0
- data/app/views/bsm_oa/applications/index.json.jbuilder +1 -0
- data/app/views/bsm_oa/applications/new.html.erb +10 -0
- data/app/views/bsm_oa/applications/show.json.jbuilder +1 -0
- data/app/views/bsm_oa/applications/update.json.jbuilder +1 -0
- data/app/views/bsm_oa/authorizations/_authorization.json.jbuilder +1 -0
- data/app/views/bsm_oa/authorizations/_inputs.html.erb +2 -0
- data/app/views/bsm_oa/authorizations/edit.html.erb +10 -0
- data/app/views/bsm_oa/authorizations/index.html.erb +0 -0
- data/app/views/bsm_oa/authorizations/index.json.jbuilder +1 -0
- data/app/views/bsm_oa/authorizations/new.html.erb +11 -0
- data/app/views/bsm_oa/authorizations/toggle.js.erb +9 -0
- data/app/views/bsm_oa/authorizations/toggle.json.jbuilder +1 -0
- data/app/views/bsm_oa/roles/_authorization.html.erb +17 -0
- data/app/views/bsm_oa/roles/_inputs.html.erb +5 -0
- data/app/views/bsm_oa/roles/_role.html.erb +16 -0
- data/app/views/bsm_oa/roles/_role.json.jbuilder +2 -0
- data/app/views/bsm_oa/roles/create.json.jbuilder +1 -0
- data/app/views/bsm_oa/roles/edit.html.erb +10 -0
- data/app/views/bsm_oa/roles/index.html.erb +19 -0
- data/app/views/bsm_oa/roles/index.json.jbuilder +2 -0
- data/app/views/bsm_oa/roles/new.html.erb +10 -0
- data/app/views/bsm_oa/roles/show.html.erb +41 -0
- data/app/views/bsm_oa/roles/show.json.jbuilder +1 -0
- data/app/views/bsm_oa/roles/update.json.jbuilder +1 -0
- data/bsm_oa.gemspec +37 -0
- data/config.ru +7 -0
- data/db/migrate/20150507113313_bsm_oa_create_doorkeeper_tables.rb +43 -0
- data/db/migrate/20150513155732_bsm_oa_create_tables.rb +16 -0
- data/lib/bsm_oa/application_mixin.rb +37 -0
- data/lib/bsm_oa/authorization.rb +49 -0
- data/lib/bsm_oa/config.rb +19 -0
- data/lib/bsm_oa/engine.rb +27 -0
- data/lib/bsm_oa/role.rb +28 -0
- data/lib/bsm_oa/routes.rb +24 -0
- data/lib/bsm_oa/version.rb +3 -0
- data/lib/bsm_oa.rb +25 -0
- data/spec/controllers/bsm_oa/accounts_controller_spec.rb +35 -0
- data/spec/controllers/bsm_oa/applications_controller_spec.rb +114 -0
- data/spec/controllers/bsm_oa/authorizations_controller_spec.rb +164 -0
- data/spec/controllers/bsm_oa/roles_controller_spec.rb +140 -0
- data/spec/factories.rb +23 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +13 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/lib/bsm_oa/application_mixin_spec.rb +48 -0
- data/spec/lib/bsm_oa/authorization_spec.rb +53 -0
- data/spec/lib/bsm_oa/config_spec.rb +20 -0
- data/spec/lib/bsm_oa/role_spec.rb +22 -0
- data/spec/spec_helper.rb +64 -0
- metadata +372 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5025b6ecca24e19622010e73f34aeb51ab6c41c
|
4
|
+
data.tar.gz: 509fddabc2da4dc37aac6fe107af71dd43dd9885
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2813cf35613dca6b1693216d3ca2f3f304eb28003e92f162d567657e7f6afc1033fa9dc8a33459b1e5bb377168e277ff91e6dfb779ed5e903866fc51e017df34
|
7
|
+
data.tar.gz: d497df0bc2375359c9cbcb49edda1034447350370c2bd626d0228d23232071cb20958de605b765776903f2159c6ed8a406ae4c701609722a9b2b6c0c4ade62e4
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bsm_oa (0.3.1)
|
5
|
+
bsm-models
|
6
|
+
doorkeeper (~> 3.0.0.rc)
|
7
|
+
has_scope (~> 0.6)
|
8
|
+
jbuilder (~> 2.2)
|
9
|
+
jquery-rails
|
10
|
+
railties (>= 4.1, < 5.0)
|
11
|
+
responders (~> 2.0)
|
12
|
+
simple_form (~> 3.1)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
abstract (1.0.0)
|
18
|
+
actionmailer (4.2.2)
|
19
|
+
actionpack (= 4.2.2)
|
20
|
+
actionview (= 4.2.2)
|
21
|
+
activejob (= 4.2.2)
|
22
|
+
mail (~> 2.5, >= 2.5.4)
|
23
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
24
|
+
actionpack (4.2.2)
|
25
|
+
actionview (= 4.2.2)
|
26
|
+
activesupport (= 4.2.2)
|
27
|
+
rack (~> 1.6)
|
28
|
+
rack-test (~> 0.6.2)
|
29
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
30
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
31
|
+
actionview (4.2.2)
|
32
|
+
activesupport (= 4.2.2)
|
33
|
+
builder (~> 3.1)
|
34
|
+
erubis (~> 2.7.0)
|
35
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
37
|
+
activejob (4.2.2)
|
38
|
+
activesupport (= 4.2.2)
|
39
|
+
globalid (>= 0.3.0)
|
40
|
+
activemodel (4.2.2)
|
41
|
+
activesupport (= 4.2.2)
|
42
|
+
builder (~> 3.1)
|
43
|
+
activerecord (4.2.2)
|
44
|
+
activemodel (= 4.2.2)
|
45
|
+
activesupport (= 4.2.2)
|
46
|
+
arel (~> 6.0)
|
47
|
+
activesupport (4.2.2)
|
48
|
+
i18n (~> 0.7)
|
49
|
+
json (~> 1.7, >= 1.7.7)
|
50
|
+
minitest (~> 5.1)
|
51
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
52
|
+
tzinfo (~> 1.1)
|
53
|
+
arel (6.0.0)
|
54
|
+
bsm-models (0.8.2)
|
55
|
+
abstract
|
56
|
+
activerecord (>= 4.1.0, < 5.0.0)
|
57
|
+
railties (>= 4.1.0, < 5.0.0)
|
58
|
+
builder (3.2.2)
|
59
|
+
combustion (0.5.3)
|
60
|
+
activesupport (>= 3.0.0)
|
61
|
+
railties (>= 3.0.0)
|
62
|
+
thor (>= 0.14.6)
|
63
|
+
database_cleaner (1.4.1)
|
64
|
+
diff-lcs (1.2.5)
|
65
|
+
doorkeeper (3.0.0.rc1)
|
66
|
+
railties (>= 3.2)
|
67
|
+
erubis (2.7.0)
|
68
|
+
factory_girl (4.5.0)
|
69
|
+
activesupport (>= 3.0.0)
|
70
|
+
faker (1.4.3)
|
71
|
+
i18n (~> 0.5)
|
72
|
+
globalid (0.3.5)
|
73
|
+
activesupport (>= 4.1.0)
|
74
|
+
has_scope (0.6.0)
|
75
|
+
actionpack (>= 3.2, < 5)
|
76
|
+
activesupport (>= 3.2, < 5)
|
77
|
+
i18n (0.7.0)
|
78
|
+
jbuilder (2.3.0)
|
79
|
+
activesupport (>= 3.0.0, < 5)
|
80
|
+
multi_json (~> 1.2)
|
81
|
+
jquery-rails (4.0.4)
|
82
|
+
rails-dom-testing (~> 1.0)
|
83
|
+
railties (>= 4.2.0)
|
84
|
+
thor (>= 0.14, < 2.0)
|
85
|
+
json (1.8.3)
|
86
|
+
json_spec (1.1.4)
|
87
|
+
multi_json (~> 1.0)
|
88
|
+
rspec (>= 2.0, < 4.0)
|
89
|
+
loofah (2.0.2)
|
90
|
+
nokogiri (>= 1.5.9)
|
91
|
+
mail (2.6.3)
|
92
|
+
mime-types (>= 1.16, < 3)
|
93
|
+
mime-types (2.6.1)
|
94
|
+
mini_portile (0.6.2)
|
95
|
+
minitest (5.7.0)
|
96
|
+
multi_json (1.11.1)
|
97
|
+
nokogiri (1.6.6.2)
|
98
|
+
mini_portile (~> 0.6.0)
|
99
|
+
rack (1.6.2)
|
100
|
+
rack-test (0.6.3)
|
101
|
+
rack (>= 1.0)
|
102
|
+
rails (4.2.2)
|
103
|
+
actionmailer (= 4.2.2)
|
104
|
+
actionpack (= 4.2.2)
|
105
|
+
actionview (= 4.2.2)
|
106
|
+
activejob (= 4.2.2)
|
107
|
+
activemodel (= 4.2.2)
|
108
|
+
activerecord (= 4.2.2)
|
109
|
+
activesupport (= 4.2.2)
|
110
|
+
bundler (>= 1.3.0, < 2.0)
|
111
|
+
railties (= 4.2.2)
|
112
|
+
sprockets-rails
|
113
|
+
rails-deprecated_sanitizer (1.0.3)
|
114
|
+
activesupport (>= 4.2.0.alpha)
|
115
|
+
rails-dom-testing (1.0.6)
|
116
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
117
|
+
nokogiri (~> 1.6.0)
|
118
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
119
|
+
rails-html-sanitizer (1.0.2)
|
120
|
+
loofah (~> 2.0)
|
121
|
+
railties (4.2.2)
|
122
|
+
actionpack (= 4.2.2)
|
123
|
+
activesupport (= 4.2.2)
|
124
|
+
rake (>= 0.8.7)
|
125
|
+
thor (>= 0.18.1, < 2.0)
|
126
|
+
rake (10.4.2)
|
127
|
+
responders (2.1.0)
|
128
|
+
railties (>= 4.2.0, < 5)
|
129
|
+
rspec (3.3.0)
|
130
|
+
rspec-core (~> 3.3.0)
|
131
|
+
rspec-expectations (~> 3.3.0)
|
132
|
+
rspec-mocks (~> 3.3.0)
|
133
|
+
rspec-core (3.3.1)
|
134
|
+
rspec-support (~> 3.3.0)
|
135
|
+
rspec-expectations (3.3.0)
|
136
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
137
|
+
rspec-support (~> 3.3.0)
|
138
|
+
rspec-mocks (3.3.0)
|
139
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
140
|
+
rspec-support (~> 3.3.0)
|
141
|
+
rspec-rails (3.3.2)
|
142
|
+
actionpack (>= 3.0, < 4.3)
|
143
|
+
activesupport (>= 3.0, < 4.3)
|
144
|
+
railties (>= 3.0, < 4.3)
|
145
|
+
rspec-core (~> 3.3.0)
|
146
|
+
rspec-expectations (~> 3.3.0)
|
147
|
+
rspec-mocks (~> 3.3.0)
|
148
|
+
rspec-support (~> 3.3.0)
|
149
|
+
rspec-support (3.3.0)
|
150
|
+
shoulda-matchers (2.8.0)
|
151
|
+
activesupport (>= 3.0.0)
|
152
|
+
simple_form (3.1.0)
|
153
|
+
actionpack (~> 4.0)
|
154
|
+
activemodel (~> 4.0)
|
155
|
+
sprockets (3.2.0)
|
156
|
+
rack (~> 1.0)
|
157
|
+
sprockets-rails (2.3.1)
|
158
|
+
actionpack (>= 3.0)
|
159
|
+
activesupport (>= 3.0)
|
160
|
+
sprockets (>= 2.8, < 4.0)
|
161
|
+
sqlite3 (1.3.10)
|
162
|
+
thor (0.19.1)
|
163
|
+
thread_safe (0.3.5)
|
164
|
+
tzinfo (1.2.2)
|
165
|
+
thread_safe (~> 0.1)
|
166
|
+
|
167
|
+
PLATFORMS
|
168
|
+
ruby
|
169
|
+
|
170
|
+
DEPENDENCIES
|
171
|
+
bsm_oa!
|
172
|
+
combustion (~> 0.5.3)
|
173
|
+
database_cleaner
|
174
|
+
factory_girl
|
175
|
+
faker
|
176
|
+
json_spec
|
177
|
+
rails (>= 4.1)
|
178
|
+
rspec-rails
|
179
|
+
shoulda-matchers
|
180
|
+
sqlite3
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
desc 'Default: run specs.'
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
desc "Run all specs"
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |config|
|
10
|
+
config.verbose = false
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Show test app routes"
|
14
|
+
task :routes do
|
15
|
+
require File.expand_path('../spec/spec_helper', __FILE__)
|
16
|
+
require 'action_dispatch/routing/inspector'
|
17
|
+
|
18
|
+
all_routes = Rails.application.routes.routes
|
19
|
+
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
20
|
+
puts inspector.format(ActionDispatch::Routing::ConsoleFormatter.new, ENV['CONTROLLER'])
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module BsmOa
|
2
|
+
class AccountsController < Doorkeeper::ApplicationController
|
3
|
+
before_action :doorkeeper_authorize!
|
4
|
+
respond_to :json
|
5
|
+
|
6
|
+
# GET /me.json
|
7
|
+
def show
|
8
|
+
@account = BsmOa.config.user_class.find doorkeeper_token.try(:resource_owner_id)
|
9
|
+
respond_with @account
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module BsmOa
|
2
|
+
class ApplicationsController < Doorkeeper::ApplicationsController
|
3
|
+
respond_to :html, :json
|
4
|
+
before_filter :redirect_to_index_on_html, only: [:show]
|
5
|
+
|
6
|
+
def create
|
7
|
+
@application = Doorkeeper::Application.create(application_params)
|
8
|
+
location = oauth_application_path(@application) if @application.persisted?
|
9
|
+
respond_with @application, location: location
|
10
|
+
end
|
11
|
+
|
12
|
+
def update
|
13
|
+
@application.update(application_params)
|
14
|
+
respond_with @application, location: oauth_application_path(@application)
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy
|
18
|
+
respond_with @application, location: oauth_applications_path
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def application_params
|
24
|
+
params.require(:doorkeeper_application).permit(:name, :redirect_uri, :permissions, :permissions_string, :uid, :secret)
|
25
|
+
end
|
26
|
+
|
27
|
+
def redirect_to_index_on_html
|
28
|
+
return unless request.format.html?
|
29
|
+
|
30
|
+
flash.keep
|
31
|
+
redirect_to oauth_applications_path
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module BsmOa
|
2
|
+
class AuthorizationsController < Doorkeeper::ApplicationController
|
3
|
+
respond_to :html
|
4
|
+
respond_to :json, except: [:new, :edit]
|
5
|
+
respond_to :js, only: [:toggle]
|
6
|
+
before_filter :redirect_to_index_on_html, only: [:show]
|
7
|
+
|
8
|
+
def index
|
9
|
+
@authorizations = apply_scopes(resource_scope)
|
10
|
+
respond_with @authorizations
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
@authorization = resource_scope.find params[:id]
|
15
|
+
respond_with @authorization
|
16
|
+
end
|
17
|
+
|
18
|
+
def new
|
19
|
+
@authorization = resource_scope.new
|
20
|
+
respond_with @authorization
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
@authorization = resource_scope.find params[:id]
|
25
|
+
respond_with @authorization
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
@authorization = resource_scope.create permitted_params
|
30
|
+
respond_with @authorization
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
@authorization = resource_scope.find params[:id]
|
35
|
+
@authorization.update(permitted_params)
|
36
|
+
respond_with @authorization, location: bsm_oa_authorization_path(@authorization)
|
37
|
+
end
|
38
|
+
|
39
|
+
def toggle
|
40
|
+
@authorization = resource_scope.find params[:id]
|
41
|
+
@authorization.toggle(params[:permission])
|
42
|
+
respond_with @authorization
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
@authorization = resource_scope.find params[:id]
|
47
|
+
@authorization.destroy
|
48
|
+
respond_with @authorization, location: bsm_oa_authorization_path(@authorization)
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
# @return [User]
|
54
|
+
def parent
|
55
|
+
@parent ||= BsmOa::Role.find params[:bsm_oa_role_id]
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [ActiveRecord::Relation]
|
59
|
+
def resource_scope
|
60
|
+
if params[:bsm_oa_role_id]
|
61
|
+
parent.authorizations.all
|
62
|
+
else
|
63
|
+
BsmOa::Authorization.all
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def permitted_params
|
68
|
+
params.require(:authorization).permit :application_id, :permissions_string, :uid, :secret
|
69
|
+
end
|
70
|
+
|
71
|
+
def redirect_to_index_on_html
|
72
|
+
return unless request.format.html?
|
73
|
+
|
74
|
+
flash.keep
|
75
|
+
@authorization ||= resource_scope.find params[:id]
|
76
|
+
redirect_to bsm_oa_role_path(@authorization.role)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module BsmOa
|
2
|
+
class RolesController < Doorkeeper::ApplicationController
|
3
|
+
respond_to :html
|
4
|
+
respond_to :json, except: [:new, :edit]
|
5
|
+
|
6
|
+
has_scope :ordered, default: true, only: [:index]
|
7
|
+
|
8
|
+
def index
|
9
|
+
@roles = apply_scopes(resource_scope)
|
10
|
+
respond_with @roles
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
@role = resource_scope.find params[:id]
|
15
|
+
respond_with @role
|
16
|
+
end
|
17
|
+
|
18
|
+
def new
|
19
|
+
@role = resource_scope.new
|
20
|
+
respond_with @role
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@role = resource_scope.create permitted_params
|
25
|
+
location = bsm_oa_role_url(@role) if @role.persisted?
|
26
|
+
respond_with @role, location: location
|
27
|
+
end
|
28
|
+
|
29
|
+
def edit
|
30
|
+
@role = resource_scope.find params[:id]
|
31
|
+
respond_with @role
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@role = resource_scope.find params[:id]
|
36
|
+
@role.update permitted_params
|
37
|
+
respond_with @role, location: bsm_oa_role_url(@role)
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
@role = resource_scope.find params[:id]
|
42
|
+
@role.destroy
|
43
|
+
respond_with @role, location: bsm_oa_roles_url
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
# @return [ActiveRecord::Relation]
|
49
|
+
def resource_scope
|
50
|
+
BsmOa::Role.all
|
51
|
+
end
|
52
|
+
|
53
|
+
def permitted_params
|
54
|
+
params.require(:role).permit :name, :description
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<tr>
|
2
|
+
<td><%= application.name %></td>
|
3
|
+
<td><%= truncate(application.uid, length: 15) %></td>
|
4
|
+
<td><%= truncate(application.secret, length: 15) %></td>
|
5
|
+
<td><%= application.redirect_uri %></td>
|
6
|
+
<td>
|
7
|
+
<%= '–'.html_safe if application.permissions.empty? %>
|
8
|
+
<% application.permissions.each do |pm| %>
|
9
|
+
<span class="label label-info"><%= "#{pm}" %></span>
|
10
|
+
<% end %>
|
11
|
+
<td>
|
12
|
+
<%= link_to t('doorkeeper.applications.buttons.edit'), edit_oauth_application_path(application), class: 'btn btn-default btn-xs' %>
|
13
|
+
<%= link_to 'Delete', oauth_application_path(application), data: { confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-default btn-xs'%>
|
14
|
+
</td>
|
15
|
+
</tr>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.(application, :id, :name, :uid, :secret, :redirect_uri, :scopes)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= f.input :name, placeholder: "Enter name"%>
|
2
|
+
|
3
|
+
<%= f.input :uid, placeholder: "Enter application UID"%>
|
4
|
+
|
5
|
+
<%= f.input :secret, placeholder: "Enter application secret"%>
|
6
|
+
|
7
|
+
<%= f.input :redirect_uri, placeholder: "Enter redirect url"%>
|
8
|
+
|
9
|
+
<%= f.input :permissions_string, placeholder: "Enter comma separated permissions"%>
|
10
|
+
|
11
|
+
<%= f.button :submit %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! 'application', application: @application
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to "← Back".html_safe, oauth_applications_path, class: 'btn btn-lg btn-default'%>
|
4
|
+
</div>
|
5
|
+
<h1>Edit Application</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<%= simple_form_for @application, url: oauth_application_url(@application) do |f| %>
|
9
|
+
<%= render 'inputs', f: f %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to 'New Application', new_oauth_application_path, class: 'btn btn-lg btn-primary' %>
|
4
|
+
</div>
|
5
|
+
<h1>Applications</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<table class="table table-hover">
|
9
|
+
<thead>
|
10
|
+
<tr>
|
11
|
+
<th><%= t('.name') %></th>
|
12
|
+
<th><%= t('.uid') %></th>
|
13
|
+
<th><%= t('.secret') %></th>
|
14
|
+
<th><%= t('.callback_url') %></th>
|
15
|
+
<th><%= t('.permissions') %></th>
|
16
|
+
<th></th>
|
17
|
+
</tr>
|
18
|
+
</thead>
|
19
|
+
<tbody>
|
20
|
+
<% @applications.each do |application| %>
|
21
|
+
<%= render 'application', application: application %>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @applications, :id, :name
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to "← Back".html_safe, oauth_applications_path, class: 'btn btn-lg btn-default'%>
|
4
|
+
</div>
|
5
|
+
<h1>New Application</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<%= simple_form_for @application, url: oauth_applications_url do |f| %>
|
9
|
+
<%= render 'inputs', f: f %>
|
10
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! 'application', application: @application
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! 'application', application: @application
|
@@ -0,0 +1 @@
|
|
1
|
+
json.(authorization, :id, :role_id, :application_id, :permissions)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to "← Back".html_safe, bsm_oa_role_path(@authorization.role), class: 'btn btn-lg btn-default'%>
|
4
|
+
</div>
|
5
|
+
<h1>Edit Authorization</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<%= simple_form_for @authorization, url: bsm_oa_authorization_url do |f| %>
|
9
|
+
<%= render 'inputs', f: f %>
|
10
|
+
<% end %>
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @authorizations, :role_id, :application_id, :permissions
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to "← Back".html_safe, bsm_oa_role_path(@parent), class: 'btn btn-lg btn-default'%>
|
4
|
+
</div>
|
5
|
+
<h1>New Authorization</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<%= simple_form_for [@parent, @authorization], url: bsm_oa_role_bsm_oa_authorizations_url do |f| %>
|
9
|
+
<%= f.association :application, as: :select, collection: Doorkeeper::Application.ordered, prompt: true %>
|
10
|
+
<%= f.button :submit %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
var elem = $("bsm_oa_authorization_<%= @authorization.to_param %>_<%= params[:permission] %>"),
|
2
|
+
included = <%= @authorization.permissions.include?(params[:permission]) %>,
|
3
|
+
inClass = "label-info",
|
4
|
+
exClass = "label-default";
|
5
|
+
|
6
|
+
elem
|
7
|
+
.removeClass(inClass)
|
8
|
+
.removeClass(exClass)
|
9
|
+
.addClass(included ? inClass : exClass);
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! 'authorization', authorization: @authorization
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%- app = auth.application %>
|
2
|
+
<tr>
|
3
|
+
<td><%= app.name %></td>
|
4
|
+
<td>
|
5
|
+
<%= '–'.html_safe if app.permissions.empty? %>
|
6
|
+
<% app.permissions.each do |permission| %>
|
7
|
+
<%- klass = auth.permissions.include?(permission) ? 'info' : 'default' %>
|
8
|
+
<%- path = toggle_authorization_path auth, permission: permission, format: 'js' %>
|
9
|
+
<%- elem = "bsm_oa_authorization_#{auth.to_param}_#{permission}" %>
|
10
|
+
<%= link_to permission, path, class: "label label-#{klass}", remote: true, method: :put, id: elem %>
|
11
|
+
<% end %>
|
12
|
+
</td>
|
13
|
+
<td>
|
14
|
+
<%= link_to 'Edit', edit_authorization_path(auth), class: 'btn btn-default btn-xs' %>
|
15
|
+
<%= link_to 'Delete', authorization_path(auth), data: { confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-default btn-xs' %>
|
16
|
+
</td>
|
17
|
+
</tr>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<tr>
|
2
|
+
<td><%= link_to role.name, role %></td>
|
3
|
+
<td>
|
4
|
+
<%= '–'.html_safe unless role.description %>
|
5
|
+
<%= role.description %></td>
|
6
|
+
<td>
|
7
|
+
<%= '–'.html_safe if role.authorizations.empty? %>
|
8
|
+
<% role.authorizations.includes(:application).each do |auth| %>
|
9
|
+
<span class="label label-info"><%= "#{auth.application.name}" %></span>
|
10
|
+
<% end %>
|
11
|
+
</td>
|
12
|
+
<td>
|
13
|
+
<%= link_to 'Edit', edit_role_url(role), class: 'btn btn-default btn-xs' if current_user.admin? %>
|
14
|
+
<%= link_to 'Delete', role_path(role), data: { confirm: 'Are you sure?' }, :method => :delete, class: 'btn btn-default btn-xs' %>
|
15
|
+
</td>
|
16
|
+
</tr>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! 'role', role: @role
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to "← Back".html_safe, bsm_oa_roles_path, class: 'btn btn-lg btn-default'%>
|
4
|
+
</div>
|
5
|
+
<h1>Edit Role</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<%= simple_form_for @role, url: bsm_oa_role_url(@role) do |f| %>
|
9
|
+
<%= render 'inputs', f: f %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to 'New Role', new_bsm_oa_role_path, class: 'btn btn-lg btn-primary' %>
|
4
|
+
</div>
|
5
|
+
<h1>Roles</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="table-responsive">
|
9
|
+
<table class="table table-hover">
|
10
|
+
<thead>
|
11
|
+
<tr><th>Name</th><th>Description</th><th>Authorizations</th><th> </th></tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<% @roles.includes(:authorizations).each do |role| -%>
|
15
|
+
<%= render 'role', role: role %>
|
16
|
+
<% end -%>
|
17
|
+
</tbody>
|
18
|
+
</table>
|
19
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<div class="pull-right">
|
3
|
+
<%= link_to "← Back".html_safe, bsm_oa_roles_path, class: 'btn btn-lg btn-default'%>
|
4
|
+
</div>
|
5
|
+
<h1>New Role</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<%= simple_form_for @role, url: bsm_oa_roles_path do |f| %>
|
9
|
+
<%= render 'inputs', f: f %>
|
10
|
+
<% end %>
|