Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert ". (#14)" #17

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions cds-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ class EventBroker extends cds.MessagingService {

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

console.log('cds.env.requires:', cds.env.requires)

// determine auth.kind
if (this.options.x509) {
if (!this.options.x509.cert && !this.options.x509.certPath)
Expand All @@ -157,8 +155,6 @@ class EventBroker extends cds.MessagingService {
} else this.auth.kind = 'cert'
}

console.log('this.auth:', this.auth)

if (!this.auth.kind || (this.auth.kind === 'ias' && !this.auth.ias))
throw new Error(`${this.name}: Event Broker requires your app to be bound to an IAS instance.`)

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

// for cds.context.http
msg._ = {}
msg._.req = req
msg._.res = res

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


await this.tx(context, tx => {
if (cds.context.http?.req?.headers?.authorization) delete cds.context.http.req.headers.authorization // potential destination lookup fails if IAS token is used
return tx.emit(msg)
})

await this.tx(context, tx => tx.emit(msg))
this.LOG.debug('Event processed successfully.')
return res.status(200).json({ message: 'OK' })
} catch (e) {
Expand Down
Loading