Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
a8edeae6
Commit
a8edeae6
authored
10 years ago
by
jboeuf
Browse files
Options
Downloads
Plain Diff
Merge pull request #1072 from yang-g/refreshtoken
wrap refresh token credentials in c++
parents
cb8985d1
5ebd6c76
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpc++/credentials.h
+8
-2
8 additions, 2 deletions
include/grpc++/credentials.h
src/cpp/client/secure_credentials.cc
+10
-2
10 additions, 2 deletions
src/cpp/client/secure_credentials.cc
with
18 additions
and
4 deletions
include/grpc++/credentials.h
+
8
−
2
View file @
a8edeae6
...
@@ -50,8 +50,8 @@ class Credentials {
...
@@ -50,8 +50,8 @@ class Credentials {
protected:
protected:
friend
std
::
unique_ptr
<
Credentials
>
CompositeCredentials
(
friend
std
::
unique_ptr
<
Credentials
>
CompositeCredentials
(
const
std
::
unique_ptr
<
Credentials
>&
creds1
,
const
std
::
unique_ptr
<
Credentials
>&
creds1
,
const
std
::
unique_ptr
<
Credentials
>&
creds2
);
const
std
::
unique_ptr
<
Credentials
>&
creds2
);
virtual
SecureCredentials
*
AsSecureCredentials
()
=
0
;
virtual
SecureCredentials
*
AsSecureCredentials
()
=
0
;
...
@@ -113,6 +113,12 @@ std::unique_ptr<Credentials> ServiceAccountCredentials(
...
@@ -113,6 +113,12 @@ std::unique_ptr<Credentials> ServiceAccountCredentials(
std
::
unique_ptr
<
Credentials
>
JWTCredentials
(
std
::
unique_ptr
<
Credentials
>
JWTCredentials
(
const
grpc
::
string
&
json_key
,
std
::
chrono
::
seconds
token_lifetime
);
const
grpc
::
string
&
json_key
,
std
::
chrono
::
seconds
token_lifetime
);
// Builds refresh token credentials.
// json_refresh_token is the JSON string containing the refresh token along
// with a client_id and client_secret.
std
::
unique_ptr
<
Credentials
>
RefreshTokenCredentials
(
const
grpc
::
string
&
json_refresh_token
);
// Builds IAM credentials.
// Builds IAM credentials.
std
::
unique_ptr
<
Credentials
>
IAMCredentials
(
std
::
unique_ptr
<
Credentials
>
IAMCredentials
(
const
grpc
::
string
&
authorization_token
,
const
grpc
::
string
&
authorization_token
,
...
...
This diff is collapsed.
Click to expand it.
src/cpp/client/secure_credentials.cc
+
10
−
2
View file @
a8edeae6
...
@@ -55,7 +55,8 @@ class SecureCredentials GRPC_FINAL : public Credentials {
...
@@ -55,7 +55,8 @@ class SecureCredentials GRPC_FINAL : public Credentials {
args
.
SetChannelArgs
(
&
channel_args
);
args
.
SetChannelArgs
(
&
channel_args
);
return
std
::
shared_ptr
<
ChannelInterface
>
(
new
Channel
(
return
std
::
shared_ptr
<
ChannelInterface
>
(
new
Channel
(
args
.
GetSslTargetNameOverride
().
empty
()
args
.
GetSslTargetNameOverride
().
empty
()
?
target
:
args
.
GetSslTargetNameOverride
(),
?
target
:
args
.
GetSslTargetNameOverride
(),
grpc_secure_channel_create
(
c_creds_
,
target
.
c_str
(),
&
channel_args
)));
grpc_secure_channel_create
(
c_creds_
,
target
.
c_str
(),
&
channel_args
)));
}
}
...
@@ -111,7 +112,7 @@ std::unique_ptr<Credentials> ServiceAccountCredentials(
...
@@ -111,7 +112,7 @@ std::unique_ptr<Credentials> ServiceAccountCredentials(
// Builds JWT credentials.
// Builds JWT credentials.
std
::
unique_ptr
<
Credentials
>
JWTCredentials
(
std
::
unique_ptr
<
Credentials
>
JWTCredentials
(
const
grpc
::
string
&
json_key
,
std
::
chrono
::
seconds
token_lifetime
)
{
const
grpc
::
string
&
json_key
,
std
::
chrono
::
seconds
token_lifetime
)
{
if
(
token_lifetime
.
count
()
<=
0
)
{
if
(
token_lifetime
.
count
()
<=
0
)
{
gpr_log
(
GPR_ERROR
,
gpr_log
(
GPR_ERROR
,
"Trying to create JWTCredentials with non-positive lifetime"
);
"Trying to create JWTCredentials with non-positive lifetime"
);
...
@@ -122,6 +123,13 @@ std::unique_ptr<Credentials> JWTCredentials(
...
@@ -122,6 +123,13 @@ std::unique_ptr<Credentials> JWTCredentials(
grpc_jwt_credentials_create
(
json_key
.
c_str
(),
lifetime
));
grpc_jwt_credentials_create
(
json_key
.
c_str
(),
lifetime
));
}
}
// Builds refresh token credentials.
std
::
unique_ptr
<
Credentials
>
RefreshTokenCredentials
(
const
grpc
::
string
&
json_refresh_token
)
{
return
WrapCredentials
(
grpc_refresh_token_credentials_create
(
json_refresh_token
.
c_str
()));
}
// Builds IAM credentials.
// Builds IAM credentials.
std
::
unique_ptr
<
Credentials
>
IAMCredentials
(
std
::
unique_ptr
<
Credentials
>
IAMCredentials
(
const
grpc
::
string
&
authorization_token
,
const
grpc
::
string
&
authorization_token
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment