Skip to content

OAuth2 Filter: Adding response_code_details for 401 cases #37933

@denniskniep

Description

@denniskniep

Description:
There are a lot scenarios where OAuth2 Filter returns 401 status code. But in AccessLog there is no further detail why it was a 401. That makes troubleshooting hard. You have to switch to debug logging if you want more insights.

Example:
"response_code":"401","response_flags":"-","response_code_details":""

We should enrich it with a short explainer:

void OAuth2Filter::sendUnauthorizedResponse() {
config_->stats().oauth_failure_.inc();
decoder_callbacks_->sendLocalReply(Http::Code::Unauthorized, UnauthorizedBodyMessage, nullptr,
absl::nullopt, EMPTY_STRING);

Like this:

decoder_callbacks_->encodeHeaders(std::move(response_headers), true, REDIRECT_LOGGED_IN);

results in "response_code":"302","response_flags":"-","response_code_details":"oauth.logged_in"

cc: @zhaohuabing

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions