diff options
author | Julien Boeuf <jboeuf@google.com> | 2017-04-24 13:55:46 -0700 |
---|---|---|
committer | Julien Boeuf <jboeuf@google.com> | 2017-07-13 21:58:01 -0700 |
commit | da8eca56e20fcd18fb1e138bc575d07cc49d8f2c (patch) | |
tree | 5b6e8cc2822cb17ad81498efac4008782606aac8 /include/grpc++/security | |
parent | e48bff9ba03bfa76eba5f1e63949f89a60f32a77 (diff) |
Better handling of token lifetime.
- In C++, we need a constant for the max lifetime.
- In C, make sure that we crop the lifetime in the credentials object
itself and not just later during the creation of the token. This will
allow the refresh to occur based on the actual token lifetime as opposed
to the one from the user (which may be cropped).
Diffstat (limited to 'include/grpc++/security')
-rw-r--r-- | include/grpc++/security/credentials.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/grpc++/security/credentials.h b/include/grpc++/security/credentials.h index 1ec9b9728b..92330d42c6 100644 --- a/include/grpc++/security/credentials.h +++ b/include/grpc++/security/credentials.h @@ -132,13 +132,17 @@ std::shared_ptr<ChannelCredentials> SslCredentials( /// services. std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials(); +/// Constant for maximum auth token lifetime. +constexpr long kMaxAuthTokenLifetimeSecs = 3600; + /// Builds Service Account JWT Access credentials. /// json_key is the JSON key string containing the client's private key. /// token_lifetime_seconds is the lifetime in seconds of each Json Web Token /// (JWT) created with this credentials. It should not exceed -/// \a grpc_max_auth_token_lifetime or will be cropped to this value. +/// \a kMaxAuthTokenLifetimeSecs or will be cropped to this value. std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials( - const grpc::string& json_key, long token_lifetime_seconds); + const grpc::string& json_key, + long token_lifetime_seconds = kMaxAuthTokenLifetimeSecs); /// Builds refresh token credentials. /// json_refresh_token is the JSON string containing the refresh token along |