smart_proxy_container_gateway 3.3.0 → 3.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85cb8971300559f91cbae183a96bfa821c0bd90151c2b7c765561d9e1f84adc
|
4
|
+
data.tar.gz: 988f40bafe8e1aaf13042faf2bd5505bfc416e7e4160f94419ba7b271878bdfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c249cf8162619a123d179234182ff19b7f724393600738c421acd2b0627b0b370fb01f38cd0b57304c3d50765015df40170eae42617e5c29d56c457a25ec531
|
7
|
+
data.tar.gz: ff795672ab091823d36af4085ca328775ec8ce2f1f5d954d0760c7ba4540b4842ab0dfcdf9d741d53ec534a7603711f5da78ac65e7b8a423a5b5f44c54d2980c
|
@@ -119,7 +119,7 @@ module Proxy
|
|
119
119
|
get '/v2/_catalog/?' do
|
120
120
|
catalog = []
|
121
121
|
if auth_header.present?
|
122
|
-
if auth_header.unauthorized_token?
|
122
|
+
if auth_header.unauthenticated_token? || auth_header.unauthorized_token?
|
123
123
|
catalog = container_gateway_main.catalog.select_map(::Sequel[:repositories][:name])
|
124
124
|
elsif auth_header.valid_user_token?
|
125
125
|
catalog = container_gateway_main.catalog(auth_header.user).select_map(::Sequel[:repositories][:name])
|
@@ -150,42 +150,33 @@ module Proxy
|
|
150
150
|
request.params['account'] ||= username if username.present?
|
151
151
|
end
|
152
152
|
|
153
|
-
unless auth_header.present? && auth_header.basic_auth?
|
154
|
-
return { token: AuthorizationHeader::UNAUTHORIZED_TOKEN, issued_at: Time.now.rfc3339,
|
155
|
-
expires_in: 1.year.seconds.to_i }.to_json
|
156
|
-
end
|
157
|
-
|
158
153
|
token_response = ForemanApi.new.fetch_token(auth_header.raw_header, request.params)
|
159
|
-
|
160
|
-
halt token_response.code.to_i, token_response.body
|
161
|
-
else
|
162
|
-
# This returned token should follow OAuth2 spec. We need some minor conversion
|
163
|
-
# to store the token with the expires_at time (using rfc3339).
|
164
|
-
token_response_body = JSON.parse(token_response.body)
|
154
|
+
halt token_response.code.to_i, token_response.body unless token_response.code.to_i == 200
|
165
155
|
|
166
|
-
|
167
|
-
|
168
|
-
|
156
|
+
token_response_body = JSON.parse(token_response.body)
|
157
|
+
halt 502, "Recieved malformed token response" if token_response_body['token'].nil?
|
158
|
+
|
159
|
+
# Check for unauthorized tokens and respond with 401
|
160
|
+
halt 401, "unauthorized" if token_response_body['token'] == AuthorizationHeader::UNAUTHORIZED_TOKEN
|
161
|
+
|
162
|
+
# Skip storing the token if it is unauthenticated
|
163
|
+
unless token_response_body['token'] == AuthorizationHeader::UNAUTHENTICATED_TOKEN
|
169
164
|
|
170
165
|
# "issued_at" is an optional field. Per OAuth2 we assume time of token response as
|
171
166
|
# the issue time if the field is ommitted.
|
172
167
|
token_issue_time = (token_response_body["issued_at"] || token_response["Date"])&.to_time
|
173
|
-
if token_issue_time.nil?
|
174
|
-
halt 502, "Recieved malformed token response"
|
175
|
-
end
|
168
|
+
halt 502, "Recieved malformed token response" if token_issue_time.nil?
|
176
169
|
|
170
|
+
# This returned token should follow OAuth2 spec. We need some minor conversion
|
171
|
+
# to store the token with the expires_at time (using rfc3339).
|
177
172
|
# 'expires_in' is an optional field. If not provided, assume 60 seconds per OAuth2 spec
|
178
173
|
expires_in = token_response_body.fetch("expires_in", 60)
|
179
174
|
expires_at = token_issue_time + expires_in.seconds
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
)
|
186
|
-
else
|
187
|
-
halt 401, "unauthorized"
|
188
|
-
end
|
175
|
+
container_gateway_main.insert_token(
|
176
|
+
request.params['account'],
|
177
|
+
token_response_body['token'],
|
178
|
+
expires_at.rfc3339
|
179
|
+
)
|
189
180
|
|
190
181
|
repo_response = ForemanApi.new.fetch_user_repositories(auth_header.raw_header, request.params)
|
191
182
|
if repo_response.code.to_i != 200
|
@@ -194,10 +185,10 @@ module Proxy
|
|
194
185
|
container_gateway_main.update_user_repositories(request.params['account'],
|
195
186
|
JSON.parse(repo_response.body)['repositories'])
|
196
187
|
end
|
197
|
-
|
198
|
-
# Return the original token response from Katello
|
199
|
-
return token_response.body
|
200
188
|
end
|
189
|
+
|
190
|
+
# Return the original token response from Katello
|
191
|
+
return token_response.body
|
201
192
|
end
|
202
193
|
|
203
194
|
get '/users/?' do
|
@@ -320,6 +311,7 @@ module Proxy
|
|
320
311
|
inject_attr :database_impl, :database
|
321
312
|
inject_attr :container_gateway_main_impl, :container_gateway_main
|
322
313
|
UNAUTHORIZED_TOKEN = 'unauthorized'.freeze
|
314
|
+
UNAUTHENTICATED_TOKEN = 'unauthenticated'.freeze
|
323
315
|
|
324
316
|
def initialize(value)
|
325
317
|
@value = value || ''
|
@@ -345,6 +337,10 @@ module Proxy
|
|
345
337
|
@value.split(' ')[1] == UNAUTHORIZED_TOKEN
|
346
338
|
end
|
347
339
|
|
340
|
+
def unauthenticated_token?
|
341
|
+
@value.split(' ')[1] == UNAUTHENTICATED_TOKEN
|
342
|
+
end
|
343
|
+
|
348
344
|
def token_auth?
|
349
345
|
@value.split(' ')[0] == 'Bearer'
|
350
346
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_container_gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Ballou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.5.22
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Pulp 3 container registry support for Foreman/Katello Smart-Proxy
|