MCPcopy Create free account
hub / github.com/apache/impala / JWTTokenAuth

Function JWTTokenAuth

be/src/rpc/authentication.cc:792–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792bool JWTTokenAuth(ThriftServer::ConnectionContext* connection_context,
793 const AuthenticationHash& hash, const string& token) {
794 JWTHelper::UniqueJWTDecodedToken decoded_token;
795 Status status = JWTHelper::Decode(token, decoded_token);
796 if (!status.ok()) {
797 LOG(ERROR) << "Error decoding JWT token received from: "
798 << TNetworkAddressToString(connection_context->network_address)
799 << " Error: " << status;
800 return false;
801 }
802 if (FLAGS_jwt_validate_signature) {
803 status = ExecEnv::GetInstance()->GetJWTHelperInstance()->Verify(decoded_token.get());
804 if (!status.ok()) {
805 LOG(ERROR) << "Error verifying JWT token received from: "
806 << TNetworkAddressToString(connection_context->network_address)
807 << " Error: " << status;
808 connection_context->return_headers.push_back(
809 Substitute("WWW-Authenticate: Bearer error=\"invalid_token\",\
810error_description=\"$0 \"", status.GetDetail()));
811 return false;
812 }
813 }
814
815 DCHECK(!FLAGS_jwt_custom_claim_username.empty());
816 string username;
817 status = JWTHelper::GetCustomClaimUsername(
818 decoded_token.get(), FLAGS_jwt_custom_claim_username, username);
819 if (!status.ok()) {
820 LOG(ERROR) << "Error extracting username from JWT token received from: "
821 << TNetworkAddressToString(connection_context->network_address)
822 << " Error: " << status;
823 return false;
824 }
825 connection_context->username = username;
826
827 // Create a cookie to return.
828 connection_context->return_headers.push_back(
829 Substitute("Set-Cookie: $0", GenerateCookie(username, hash, HTTP_AUTH_MECH_JWT)));
830 return true;
831}
832
833bool OAuthTokenAuth(ThriftServer::ConnectionContext* connection_context,
834 const AuthenticationHash& hash, const string& token) {

Callers 1

BeginRequestCallbackMethod · 0.85

Calls 10

TNetworkAddressToStringFunction · 0.85
SubstituteFunction · 0.85
GenerateCookieFunction · 0.85
GetJWTHelperInstanceMethod · 0.80
push_backMethod · 0.80
GetDetailMethod · 0.80
getMethod · 0.65
okMethod · 0.45
VerifyMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected