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

Set custom error message inside connection close method for unauthorised client #64

Merged
merged 1 commit into from
Nov 26, 2021

Conversation

Chinmay1412
Copy link
Contributor

Proxy can also be configured to use external http service to authenticate clients. But currently, if the external auth service fail to authenticate client, proxy will close the client connection with default message "ERROR: Not authorized by amqpprox proxy". It will be difficult for that client to debug the actual problem in that case. So this PR will propagate the reason, which proxy got from the external http service to the client. And client will immediately be able to know the actual reason in such cases.

inline void
Connector::synthesizeMessage(TMethod &replyMethod,
bool sendToIngressSide,
uint64_t code /* = Reply::Codes::reply_success */,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we always use code and text and remove the templated argument TReply here? I don't see the benefit of it

void Connector::synthesizeCloseAuthError(bool sendToIngressSide)
void Connector::synthesizeCustomCloseError(bool sendToIngressSide,
uint16_t code,
const std::string_view &text)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const std::string_view &text)
std::string_view text)

I believe it's normal to pass string_view by value since copying them is very cheap.

@Chinmay1412 Chinmay1412 merged commit 290e4c9 into main Nov 26, 2021
@Chinmay1412 Chinmay1412 deleted the custom-error branch November 26, 2021 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants