-
Notifications
You must be signed in to change notification settings - Fork 476
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
Add connection-update-secret #756
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,10 @@ class CallbackModel extends EventEmitter { | |
this.connection.close(cb); | ||
} | ||
|
||
updateSecret(newSecret, reason, cb) { | ||
this.connection._updateSecret(newSecret, reason, cb); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was in two minds whether to default reason, but decided against it as I wasn't sure what a sensible default value would be. Happy to reconsider. |
||
createChannel (cb) { | ||
var ch = new Channel(this.connection); | ||
ch.open(function (err, ok) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -361,6 +361,14 @@ class Connection extends EventEmitter { | |
this.emit('close', maybeErr); | ||
} | ||
|
||
_updateSecret(newSecret, reason, cb) { | ||
this.sendMethod(0, defs.ConnectionUpdateSecret, { | ||
newSecret, | ||
reason | ||
}); | ||
this.on('update-secret-ok', cb); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll change to this.once There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used the event handler because I couldn't see another way of getting a callback into the channel0 accept function |
||
} | ||
|
||
// === | ||
startHeartbeater () { | ||
if (this.heartbeat === 0) | ||
|
@@ -611,6 +619,9 @@ function channel0(connection) { | |
else if (f.id === defs.ConnectionUnblocked) { | ||
connection.emit('unblocked'); | ||
} | ||
else if (f.id === defs.ConnectionUpdateSecretOk) { | ||
connection.emit('update-secret-ok'); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where channel 0 accepts the update-secret ok confirmation frame. I decided not to report an error a confirmation is received without the update-secret operation ever having been sent. As previously mentioned I used event emitters because I couldn't see how else to invoke the updateSecret callback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may already have been administered, but the new "secret" can be either a password or JWT to my knowledge. I am guessing the AMQP 0-9-1 protocol already takes care of everything once the frame is sent over? If JWT, this would pipe into updating whatever authentication mechanism exists that decodes and verifies the new JWT. I imagine that somewhere in the libs that a new exp (expiration) value is set which is responsible for many of the 403 access denied errors when trying to publish to a connection that has expired. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RabbitMQ docs are pretty light, but the spec only has two arguments... {
"id": 70,
"arguments": [
{
"type": "longstr",
"name": "new-secret"
},
{
"type": "shortstr",
"name": "reason"
}
],
"name": "update-secret",
"synchronous": true
} So I assume it's also handled transparently. |
||
else { | ||
connection.closeWithError( | ||
fmt("Unexpected frame on channel 0"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated to the latest spec, from the RabbitMQ monorepo.
Also closes #613
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There really isn’t a standard convention here that I know of for the ‘reason’