raas-client-rails 0.1.14 → 0.1.16

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: 0bca6ac232a858b8f876e23b9061e02ddb0a29b08ef0fb97891928e7a5a41bbd
4
- data.tar.gz: ac59b74d7439972836b87abe6fae7c4b28c31ddde6d96202981fa1ce7c413c15
3
+ metadata.gz: ddd1fba858dc356f6b622b6e85d535b226d3f8305f01a412977b18d6351ac5d0
4
+ data.tar.gz: 67e3ac4df50a35d7105952e02a80a7409e64d96c07520477bc706dcec49378ca
5
5
  SHA512:
6
- metadata.gz: 02622a4c02f015f98ef9fcaa676bc8a8945d00b012b2d51dfd5cf0664ecb6155e71a7864c9e8926a1f47cccc1db05b66b8b341870d940c5286fc5d559cbb0554
7
- data.tar.gz: 1343474a1b7b19ad092297ec3676bfcdf24df2a489bd52e16bae43d6c4a09fb279eb2b463298d39c5ba5d1b0d3a0e4987749b499b3b63cfa1ee5ea68ca4d9802
6
+ metadata.gz: 6b03712796e5afd4f1fca7feeda0a5f83c4e552bfa84045c54ce00b91371bfb5dc5d7e3dd5e8da1f89b36064c50997e254b9764b575149f71ad2184e89fdd7d5
7
+ data.tar.gz: 9021e8af22ff8af4b43aeb2d54a2429ac6cd803cb88d775cc8bce3f3cabacacec906b6d3b34f5077d4922a0b3b466bd7c6aaca4c50d3224932d53d391e95b117
@@ -67,9 +67,9 @@ module Raas::Client::Rails
67
67
  if type.nil?
68
68
  type = "application/pdf"
69
69
  end
70
- #by default empty Hash if nothing is assigned
70
+ #by default no query parameter if nothing is assigned
71
71
  if parameters.nil?
72
- payload = Hash.new
72
+ payload = nil
73
73
  else
74
74
  payload = parameters
75
75
  end
@@ -80,14 +80,16 @@ module Raas::Client::Rails
80
80
 
81
81
  # How you return the value? This can be changed by passing mimeType through parameter
82
82
  def handleMime(mimeType, fileName,type, response)
83
+ #上流のHTTPステータス(403/404等)をそのままクライアントへ返す
84
+ status = response.code.to_i
83
85
  case mimeType
84
86
  when MIME_TYPE_HTML
85
87
  #sanitize response automatically
86
- render html: response.body
88
+ render html: response.body, status: status
87
89
  when MIME_TYPE_JSON
88
- render json: response.body
90
+ render json: response.body, status: status
89
91
  when MIME_TYPE_FILE
90
- send_data(response, filename: fileName, type: type)
92
+ send_data(response.body, filename: fileName, type: type, status: status)
91
93
  end
92
94
  # p "#{fileName} #{type} #{mimeType}"
93
95
  end
@@ -103,7 +105,8 @@ module Raas::Client::Rails
103
105
  payload = JSON.parse(parameters)
104
106
  end
105
107
  Rails.logger.warn("delete path=#{path} parameters=#{parameters}");
106
- return @restClient.delete(path,payload)
108
+ response = @restClient.delete(path,payload)
109
+ render json: response.body, status: response.code.to_i
107
110
  end
108
111
 
109
112
  #/raas/post
@@ -118,7 +121,7 @@ module Raas::Client::Rails
118
121
  end
119
122
  Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
120
123
  response = @restClient.post(path,payload)
121
- return response.body;
124
+ render json: response.body, status: response.code.to_i
122
125
  end
123
126
 
124
127
  #/raas/put
@@ -133,7 +136,7 @@ module Raas::Client::Rails
133
136
  end
134
137
  Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
135
138
  response = @restClient.put(path,payload)
136
- return response.body;
139
+ render json: response.body, status: response.code.to_i
137
140
  end
138
141
 
139
142
  end
@@ -29,7 +29,6 @@ module Raas::Client::Rails
29
29
  body["backUrl"] = backUrl
30
30
  body["subUrl"] = subUrl
31
31
  body["subDomain"] = subDomain || @sub_domain || ""
32
- body["scope"] = @scope if @scope
33
32
  return proxy(body,POST,"/#{msa}/external/session",nil,@token)
34
33
  end
35
34
 
@@ -41,8 +40,9 @@ module Raas::Client::Rails
41
40
  body["tenantAlias"] = @tenant_alias
42
41
  end
43
42
  if @sub_alias
44
- body["subAlias"] = @sub_alias
43
+ body["subAlias"] = @sub_alias
45
44
  end
45
+ body["scope"] = @scope if @scope
46
46
  return body
47
47
  end
48
48
 
@@ -51,16 +51,24 @@ module Raas::Client::Rails
51
51
  Rails.logger.debug("[TRACE] getUserToken is started");
52
52
  #Use Rails default cache system, this simply use cache otherwise fetch and store
53
53
  Rails.logger.debug("Attempt to recycle token");
54
- cacheName = "#{@tenant}+++#{@sub}"
54
+ # scope 付きトークンは scope 単位でキャッシュし、切り替え時に再取得する
55
+ if @scope
56
+ cacheName = "#{@tenant}+++#{@sub}+++#{@scope}"
57
+ else
58
+ cacheName = "#{@tenant}+++#{@sub}"
59
+ end
55
60
  Rails.logger.debug("Cache name is #{cacheName}")
56
61
  # p cacheName
57
- return token = Rails.cache.fetch(cacheName) do
58
- Rails.logger.debug("No cache found, fetch it by api");
59
- Rails.logger.debug("tenant #=> #{@tenant} / sub #=> #{@sub}")
60
- response = getUserTokenImpl("report");
61
- Rails.logger.debug(response.body)
62
- return JSON.parse(response.body);
63
- end
62
+ cached = Rails.cache.read(cacheName)
63
+ return cached if cached
64
+ Rails.logger.debug("No cache found, fetch it by api");
65
+ Rails.logger.debug("tenant #=> #{@tenant} / sub #=> #{@sub}")
66
+ response = getUserTokenImpl("report");
67
+ Rails.logger.debug(response.body)
68
+ json = JSON.parse(response.body);
69
+ # エラー応答 (invalid_scope の 400 等) を永続キャッシュしないよう成功時のみ保存する
70
+ Rails.cache.write(cacheName, json) if response.is_a?(Net::HTTPSuccess)
71
+ return json
64
72
  end
65
73
 
66
74
  # fetch token from RaaS because no cache
@@ -100,7 +108,8 @@ module Raas::Client::Rails
100
108
  url = URI.parse(uri)
101
109
  unless params.nil?
102
110
  #should I do like this!?
103
- parameters_hash = params.to_unsafe_h
111
+ # ActionController::Parameters 以外 (素の Hash) で渡されることもある
112
+ parameters_hash = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params
104
113
  url.query = URI.encode_www_form(parameters_hash) unless params.nil?
105
114
  end
106
115
  # replacing context path form urI to match actual gateway URI
@@ -1,7 +1,7 @@
1
1
  module Raas
2
2
  module Client
3
3
  module Rails
4
- VERSION = "0.1.14"
4
+ VERSION = "0.1.16"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raas-client-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunao Suzuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-24 00:00:00.000000000 Z
11
+ date: 2026-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails