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

jwt_authn: make from_cookies JWT removal behaviour similar to from_params #17985

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ message JwtProvider {

// If false, the JWT is removed in the request after a success verification. If true, the JWT is
// not removed in the request. Default value is false.
// caveat: only works for from_header & has no effect for JWTs extracted through from_params & from_cookies.
bool forward = 5;

// Two fields below define where to extract the JWT from an HTTP request.
Expand Down
1 change: 0 additions & 1 deletion source/extensions/filters/http/jwt_authn/extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class JwtCookieLocation : public JwtLocationBase {

void removeJwt(Http::HeaderMap&) const override {
// TODO(theshubhamp): remove JWT from cookies.
NOT_IMPLEMENTED_GCOVR_EXCL_LINE;
}
};

Expand Down
3 changes: 3 additions & 0 deletions test/extensions/filters/http/jwt_authn/extractor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,19 @@ TEST_F(ExtractorTest, TestCookieToken) {
EXPECT_EQ(tokens[0]->token(), "token-cookie-value");
EXPECT_TRUE(tokens[0]->isIssuerAllowed("issuer9"));
EXPECT_FALSE(tokens[0]->isIssuerAllowed("issuer10"));
tokens[0]->removeJwt(headers);

// only issuer9 has specified "token-cookie-2" cookie location.
EXPECT_EQ(tokens[1]->token(), "token-cookie-value-2");
EXPECT_TRUE(tokens[1]->isIssuerAllowed("issuer9"));
EXPECT_FALSE(tokens[1]->isIssuerAllowed("issuer10"));
tokens[1]->removeJwt(headers);

// only issuer10 has specified "token-cookie-3" cookie location.
EXPECT_EQ(tokens[2]->token(), "token-cookie-value-3");
EXPECT_TRUE(tokens[2]->isIssuerAllowed("issuer10"));
EXPECT_FALSE(tokens[2]->isIssuerAllowed("issuer9"));
tokens[2]->removeJwt(headers);
}

// Test extracting multiple tokens.
Expand Down