motor-admin 0.1.58 → 0.1.60

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
  SHA256:
3
- metadata.gz: 98eed032de058a25fc5951c40afac9faeedd33ad66299ab381f15527e122aeeb
4
- data.tar.gz: 4797ba6520bf3614ced8ea7aa800145f2ee7c35934820c5ae623dfe19c007a45
3
+ metadata.gz: 5d709fb5b88f56a20cb9c2f906f3540b53278e04becc96598556dba70a0dcb4f
4
+ data.tar.gz: 5ffca9ae9451e2aa373957116c1b9b6607f5aba3bc1fa1cee555682c1a2987be
5
5
  SHA512:
6
- metadata.gz: 7d966ae337a44f486a56f0dcb741d06787af84e67e4a4f5c5f750796b6a8b7979e9685ec9485854e34d994477ddcfdbc55882d9efc0dd26b356f8bbfe66bb0dd
7
- data.tar.gz: 82e3f0b57ef8aa4902a36da9a8d94814f3d42f5b18cd73d70a95e59d69b5737d8652505bf3b6468629b51fef06c55e55b3ab03840838db8b1222edbc9ef9a3df
6
+ metadata.gz: 944babec34990e1889a52e76f652ca725dda31f4bcbb75aefc47cb715beca9a1a6127d6c5aa1e70437beafdf6a0c9cfaaaf3cf29a901524980812e23134cefaa
7
+ data.tar.gz: c79c99d0491e3c02c05296f0ace0ace54bbeeef1cd11f927b49f5edd814503f3e5f0f5a017c184e97bbce9a4b02b7279db36333a8b3fb796fb6125f283e8604a
data/README.md CHANGED
@@ -93,7 +93,7 @@ Intelligence search can be opened via the top right corner button or using <kbd>
93
93
 
94
94
  ### Authorization
95
95
 
96
- Motor Admin allows to set row-level and column-level permissions via [cancan](https://github.com/CanCanCommunity/cancancan) gem. Admin UI permissions should be defined in `app/models/motor/ability.rb` file in `Motor::Ability` class. See [Motor Admin guide](https://github.com/omohokcoj/motor-admin/blob/master/guides/defining_prmissions.md) and [CanCan documentation](https://github.com/CanCanCommunity/cancancan/blob/develop/docs/Defining-Abilities.md) to learn how to define user permissions.
96
+ Motor Admin allows to set row-level and column-level permissions via [cancan](https://github.com/CanCanCommunity/cancancan) gem. Admin UI permissions should be defined in `app/models/motor/ability.rb` file in `Motor::Ability` class. See [Motor Admin guide](https://github.com/omohokcoj/motor-admin/blob/master/guides/defining_permissions.md) and [CanCan documentation](https://github.com/CanCanCommunity/cancancan/blob/develop/docs/Defining-Abilities.md) to learn how to define user permissions.
97
97
 
98
98
  ### Optimized for Mobile
99
99
 
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Motor
4
+ class AuthTokensController < ApiBaseController
5
+ GENERIC_TOKEN_TTL = 2.hours
6
+
7
+ skip_authorization_check
8
+
9
+ def create
10
+ return render json: {} unless current_user
11
+
12
+ if defined?(Devise::JWT)
13
+ respond_with_devise_jwt
14
+ elsif defined?(JWT)
15
+ respond_with_generic_jwt
16
+ else
17
+ render json: {}
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def respond_with_devise_jwt
24
+ warden.set_user(current_user)
25
+
26
+ render json: { token: request.env['warden-jwt_auth.token'] }
27
+ end
28
+
29
+ def respond_with_generic_jwt
30
+ payload = { uid: current_user.id, exp: GENERIC_TOKEN_TTL.from_now.to_i }
31
+ token = JWT.encode(payload, Rails.application.secrets.secret_key_base)
32
+
33
+ render json: { token: token }
34
+ end
35
+ end
36
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Motor
4
4
  class IconsController < ApiBaseController
5
+ skip_authorization_check
6
+
5
7
  CACHE_STORE = ActiveSupport::Cache::MemoryStore.new
6
8
 
7
9
  def index
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Motor
4
4
  class ResourceMethodsController < ApiBaseController
5
+ skip_authorization_check
6
+
5
7
  before_action :authorize_resource
6
8
 
7
9
  def show
data/config/routes.rb CHANGED
@@ -5,6 +5,7 @@ Motor::Admin.routes.draw do
5
5
  scope 'api', as: :api do
6
6
  resources :run_queries, only: %i[show create]
7
7
  resources :send_alerts, only: %i[create]
8
+ resources :auth_tokens, only: %i[create]
8
9
  resources :queries, only: %i[index show create update destroy]
9
10
  resources :tags, only: %i[index]
10
11
  resources :configs, only: %i[index create]
data/lib/motor/admin.rb CHANGED
@@ -65,6 +65,18 @@ module Motor
65
65
  end
66
66
  end
67
67
 
68
+ initializer 'warden.configure.dispatch_requests' do
69
+ next unless defined?(Warden::JWTAuth)
70
+
71
+ config.after_initialize do
72
+ Warden::JWTAuth.configure do |config|
73
+ config.dispatch_requests += [
74
+ ['POST', /\A#{Regexp.escape(Motor::Admin.routes.url_helpers.motor_api_auth_tokens_path)}\z/]
75
+ ]
76
+ end
77
+ end
78
+ end
79
+
68
80
  initializer 'motor.active_storage.extensions' do
69
81
  config.after_initialize do
70
82
  next unless defined?(ActiveStorage::Engine)
@@ -99,7 +99,6 @@ module Motor
99
99
  'customer' => 'users',
100
100
  'client' => 'users',
101
101
  'ticket' => 'ticket',
102
- 'event' => 'event',
103
102
  'contact' => 'users',
104
103
  'member' => 'users',
105
104
  'admin' => 'user-check',
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.1.58'
4
+ VERSION = '0.1.60'
5
5
  end
@@ -2068,11 +2068,11 @@
2068
2068
  "mail-opened.svg": "icons/mail-opened.svg",
2069
2069
  "mail.svg": "icons/mail.svg",
2070
2070
  "mailbox.svg": "icons/mailbox.svg",
2071
- "main-ba741735a93c9314bbfa.css.gz": "main-ba741735a93c9314bbfa.css.gz",
2072
- "main-ba741735a93c9314bbfa.js.LICENSE.txt": "main-ba741735a93c9314bbfa.js.LICENSE.txt",
2073
- "main-ba741735a93c9314bbfa.js.gz": "main-ba741735a93c9314bbfa.js.gz",
2074
- "main.css": "main-ba741735a93c9314bbfa.css",
2075
- "main.js": "main-ba741735a93c9314bbfa.js",
2071
+ "main-96c4a62d2fb789ab1080.css.gz": "main-96c4a62d2fb789ab1080.css.gz",
2072
+ "main-96c4a62d2fb789ab1080.js.LICENSE.txt": "main-96c4a62d2fb789ab1080.js.LICENSE.txt",
2073
+ "main-96c4a62d2fb789ab1080.js.gz": "main-96c4a62d2fb789ab1080.js.gz",
2074
+ "main.css": "main-96c4a62d2fb789ab1080.css",
2075
+ "main.js": "main-96c4a62d2fb789ab1080.js",
2076
2076
  "man.svg": "icons/man.svg",
2077
2077
  "manual-gearbox.svg": "icons/manual-gearbox.svg",
2078
2078
  "map-2.svg": "icons/map-2.svg",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.58
4
+ version: 0.1.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-13 00:00:00.000000000 Z
11
+ date: 2021-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -131,6 +131,7 @@ files:
131
131
  - app/controllers/motor/application_controller.rb
132
132
  - app/controllers/motor/assets_controller.rb
133
133
  - app/controllers/motor/audits_controller.rb
134
+ - app/controllers/motor/auth_tokens_controller.rb
134
135
  - app/controllers/motor/configs_controller.rb
135
136
  - app/controllers/motor/dashboards_controller.rb
136
137
  - app/controllers/motor/data_controller.rb
@@ -140,7 +141,6 @@ files:
140
141
  - app/controllers/motor/resource_methods_controller.rb
141
142
  - app/controllers/motor/resources_controller.rb
142
143
  - app/controllers/motor/run_queries_controller.rb
143
- - app/controllers/motor/schemas_controller.rb
144
144
  - app/controllers/motor/send_alerts_controller.rb
145
145
  - app/controllers/motor/tags_controller.rb
146
146
  - app/controllers/motor/ui_controller.rb
@@ -1490,8 +1490,8 @@ files:
1490
1490
  - ui/dist/icons/zoom-money.svg.gz
1491
1491
  - ui/dist/icons/zoom-out.svg.gz
1492
1492
  - ui/dist/icons/zoom-question.svg.gz
1493
- - ui/dist/main-ba741735a93c9314bbfa.css.gz
1494
- - ui/dist/main-ba741735a93c9314bbfa.js.gz
1493
+ - ui/dist/main-96c4a62d2fb789ab1080.css.gz
1494
+ - ui/dist/main-96c4a62d2fb789ab1080.js.gz
1495
1495
  - ui/dist/manifest.json
1496
1496
  homepage:
1497
1497
  licenses:
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Motor
4
- class SchemasController < ApiBaseController
5
- def show
6
- render json: Motor::BuildSchema.call
7
- end
8
-
9
- def update; end
10
- end
11
- end