1 /* 2 * 3 * Copyright 2016 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H 20 #define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include "src/core/lib/security/credentials/credentials.h" 25 #include "src/core/lib/security/credentials/jwt/json_token.h" 26 27 typedef struct { 28 grpc_call_credentials base; 29 30 // Have a simple cache for now with just 1 entry. We could have a map based on 31 // the service_url for a more sophisticated one. 32 gpr_mu cache_mu; 33 struct { 34 grpc_mdelem jwt_md; 35 char* service_url; 36 gpr_timespec jwt_expiration; 37 } cached; 38 39 grpc_auth_json_key key; 40 gpr_timespec jwt_lifetime; 41 } grpc_service_account_jwt_access_credentials; 42 43 // Private constructor for jwt credentials from an already parsed json key. 44 // Takes ownership of the key. 45 grpc_call_credentials* 46 grpc_service_account_jwt_access_credentials_create_from_auth_json_key( 47 grpc_auth_json_key key, gpr_timespec token_lifetime); 48 49 #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ 50