Skip to content

Commit 4a843ae

Browse files
(PUP-11973) WIP
1 parent ee3eee9 commit 4a843ae

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/clj/puppetlabs/puppetserver/ringutils.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@
7575
(handler req)
7676
{:status 403 :body "Forbidden."})))
7777

78+
(defn wrap-with-certname-as-compiler
79+
"Function that returns middleware that add X-Puppet-Compiler-Name to the response"
80+
[handler name]
81+
(fn [request]
82+
(ring/header (handler request) "X-Puppet-Compiler-Name" name)))
83+
7884
(defn wrap-with-puppet-version-header
7985
"Function that returns a middleware that adds an
8086
X-Puppet-Version header to the response."

src/clj/puppetlabs/services/master/master_core.clj

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,14 +1313,16 @@
13131313
wrap-middleware :- IFn
13141314
[handler :- IFn
13151315
authorization-fn :- IFn
1316-
puppet-version :- schema/Str]
1316+
puppet-version :- schema/Str
1317+
certname :- schema/Str]
13171318
(-> handler
13181319
authorization-fn
13191320
(middleware/wrap-uncaught-errors :plain)
13201321
middleware/wrap-request-logging
13211322
i18n/locale-negotiator
13221323
middleware/wrap-response-logging
1323-
(ringutils/wrap-with-puppet-version-header puppet-version)))
1324+
(ringutils/wrap-with-puppet-version-header puppet-version)
1325+
(ringutils/wrap-with-certname-as-compiler certname)))
13241326

13251327
(schema/defn ^:always-validate get-master-route-config
13261328
"Get the webserver route configuration for the master service"
@@ -1366,15 +1368,18 @@
13661368
environment-class-cache-enabled :- schema/Bool
13671369
boltlib-path :- (schema/maybe [schema/Str])
13681370
bolt-builtin-content-dir :- (schema/maybe [schema/Str])
1369-
bolt-projects-dir :- (schema/maybe schema/Str)]
1371+
bolt-projects-dir :- (schema/maybe schema/Str)
1372+
certname :- schema/Str]
13701373
(let [ruby-request-handler (wrap-middleware handle-request
13711374
wrap-with-authorization-check
1372-
puppet-version)
1375+
puppet-version
1376+
certname)
13731377
clojure-request-wrapper (fn [handler]
13741378
(wrap-middleware
13751379
(ring/wrap-params handler)
13761380
wrap-with-authorization-check
1377-
puppet-version))]
1381+
puppet-version
1382+
certname))]
13781383
(root-routes ruby-request-handler
13791384
clojure-request-wrapper
13801385
jruby-service

src/clj/puppetlabs/services/master/master_service.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@
149149
environment-class-cache-enabled
150150
boltlib-path
151151
bolt-builtin-content-dir
152-
bolt-projects-dir))
152+
bolt-projects-dir
153+
certname))
153154
routes (comidi/context path ring-app)
154155
route-metadata (comidi/route-metadata routes)
155156
comidi-handler (comidi/routes->handler routes)

0 commit comments

Comments
 (0)