aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/security/json_token.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-02-02 09:23:22 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-02-02 09:23:22 -0800
commit841c72614073223b83a361976d39a66e16ee1fee (patch)
treed2627de953f9963b199fbaa4cf883a43550e0c6b /src/core/security/json_token.c
parentf1b0849bb024fcd0794b2b0eca8af8a949f9fc70 (diff)
parent0727180da8891485168fbe39b4c9ebb859b6b390 (diff)
Merge github.com:grpc/grpc into sceq
Diffstat (limited to 'src/core/security/json_token.c')
-rw-r--r--src/core/security/json_token.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/security/json_token.c b/src/core/security/json_token.c
index 4d4bc4baad..762f02989a 100644
--- a/src/core/security/json_token.c
+++ b/src/core/security/json_token.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,13 @@
/* --- Constants. --- */
/* 1 hour max. */
-const gpr_timespec grpc_max_auth_token_lifetime = {3600, 0, GPR_TIMESPAN};
+gpr_timespec grpc_max_auth_token_lifetime() {
+ gpr_timespec out;
+ out.tv_sec = 3600;
+ out.tv_nsec = 0;
+ out.clock_type = GPR_TIMESPAN;
+ return out;
+}
#define GRPC_JWT_RSA_SHA256_ALGORITHM "RS256"
#define GRPC_JWT_TYPE "JWT"
@@ -211,9 +217,9 @@ static char *encoded_jwt_claim(const grpc_auth_json_key *json_key,
gpr_timespec expiration = gpr_time_add(now, token_lifetime);
char now_str[GPR_LTOA_MIN_BUFSIZE];
char expiration_str[GPR_LTOA_MIN_BUFSIZE];
- if (gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime) > 0) {
+ if (gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()) > 0) {
gpr_log(GPR_INFO, "Cropping token lifetime to maximum allowed value.");
- expiration = gpr_time_add(now, grpc_max_auth_token_lifetime);
+ expiration = gpr_time_add(now, grpc_max_auth_token_lifetime());
}
int64_ttoa(now.tv_sec, now_str);
int64_ttoa(expiration.tv_sec, expiration_str);