Skip to content

Commit 28fa61b

Browse files
. (#14)
Co-authored-by: Johannes Vogel <[email protected]>
1 parent 5092827 commit 28fa61b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cds-plugin.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class EventBroker extends cds.MessagingService {
135135

136136
this.auth = {} // { kind: 'cert', validationCert?, privateKey? } or { kind: 'ias', ias }
137137

138+
console.log('cds.env.requires:', cds.env.requires)
139+
138140
// determine auth.kind
139141
if (this.options.x509) {
140142
if (!this.options.x509.cert && !this.options.x509.certPath)
@@ -155,6 +157,8 @@ class EventBroker extends cds.MessagingService {
155157
} else this.auth.kind = 'cert'
156158
}
157159

160+
console.log('this.auth:', this.auth)
161+
158162
if (!this.auth.kind || (this.auth.kind === 'ias' && !this.auth.ias))
159163
throw new Error(`${this.name}: Event Broker requires your app to be bound to an IAS instance.`)
160164

@@ -331,15 +335,19 @@ class EventBroker extends cds.MessagingService {
331335
Object.assign(msg.headers, headers)
332336
if (this.isMultitenancy) msg.tenant = tenant
333337

334-
// for cds.context.http
335338
msg._ = {}
336339
msg._.req = req
337340
msg._.res = res
338341

339342
const context = { user: cds.User.privileged, _: msg._ }
340343
if (msg.tenant) context.tenant = msg.tenant
341344

342-
await this.tx(context, tx => tx.emit(msg))
345+
346+
await this.tx(context, tx => {
347+
if (cds.context.http?.req?.headers?.authorization) delete cds.context.http.req.headers.authorization // potential destination lookup fails if IAS token is used
348+
return tx.emit(msg)
349+
})
350+
343351
this.LOG.debug('Event processed successfully.')
344352
return res.status(200).json({ message: 'OK' })
345353
} catch (e) {

0 commit comments

Comments
 (0)