model_driven_api 3.0.10 → 3.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ae75e607281baf108e6841f71d4dd5e9f55f8e1fc1658fb83020e28a61338da
4
- data.tar.gz: 9639e68bb94fb4a1562b5078c8832cf2c4fb8b5033b42b2dde1441e9863fc16e
3
+ metadata.gz: 77497a359b4d336baf533725376f1122b376d2a97b05bcf3e8f7e203d4963780
4
+ data.tar.gz: 8a799a1009588c764b5dbec7ea1b1cfd4c7f8c1d4ac4554bccb22b35877531a1
5
5
  SHA512:
6
- metadata.gz: 145cce106430f76bcae76084684c5926fbd5fbfb774a285778fadf78e5443b1c750a46e71e8775adde75582bfa36548e0b0353bcf7a36fb86bcd524c6acf21d0
7
- data.tar.gz: ad33e323b89e297f16899d99931321ed262dfb07b05b4bd938f19e1250108a0c769d6ca7690c604cfbb2a860f19bedd5d79cce535065c016f042ecb56f49b96a
6
+ metadata.gz: abd1210273d04c393f6a6b46e593f52da8dba14bce52dd3351b3cc3c5575c9c931826538035566a186c9d4af0596cea2f54aa1ce6d685dc7136feb933f82ce1a
7
+ data.tar.gz: 6b822a4b6da0f2718a7837124e654fc6c5ba7223798171621d669de2fd54aa4e9a933a99d5c5cf7c5b0b5641fc2eab6f5b729bef7d4d7ae8a4531fda20e3aa87
@@ -1,8 +1,8 @@
1
1
  class AuthorizeApiRequest
2
2
  prepend SimpleCommand
3
3
 
4
- def initialize(headers = {})
5
- @headers = headers
4
+ def initialize(request = {})
5
+ @headers = request.headers rescue {}
6
6
  end
7
7
 
8
8
  def call
@@ -129,11 +129,12 @@ class Api::V2::ApplicationController < ActionController::API
129
129
  unless params[:do].blank?
130
130
  # Poor man's solution to avoid the possibility to
131
131
  # call an unwanted method in the AR Model.
132
- resource = "custom_action_#{params[:do]}"
132
+ custom_action, token = params[:do].split("-")
133
+ resource = "custom_action_#{custom_action}"
133
134
  raise NoMethodError unless @model.respond_to?(resource)
134
135
  # puts json_attrs
135
136
  params[:request_url] = request.url
136
- params[:token] = bearer_token
137
+ params[:token] = token.presence || bearer_token
137
138
  body, status = @model.send(resource, params)
138
139
  return true, body.to_json(json_attrs), status
139
140
  end
@@ -158,10 +159,10 @@ class Api::V2::ApplicationController < ActionController::API
158
159
  @current_user = nil
159
160
  Settings.ns(:security).allowed_authorization_headers.split(",").each do |header|
160
161
  # puts "Found header #{header}: #{request.headers[header]}"
161
- check_authorization("Authorize#{header}".constantize.call(request.headers)) # if request.headers[header]
162
+ check_authorization("Authorize#{header}".constantize.call(request))
162
163
  end
163
164
 
164
- check_authorization AuthorizeApiRequest.call(request.headers) unless @current_user
165
+ check_authorization AuthorizeApiRequest.call(request) unless @current_user
165
166
  return unauthenticated!(OpenStruct.new({message: @auth_errors})) unless @current_user
166
167
 
167
168
  current_user = @current_user
@@ -1,3 +1,3 @@
1
1
  module ModelDrivenApi
2
- VERSION = "3.0.10".freeze
2
+ VERSION = "3.0.11".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_driven_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.10
4
+ version: 3.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_backend_commons