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
8cde3d7c
Commit
8cde3d7c
authored
9 years ago
by
murgatroid99
Browse files
Options
Downloads
Patches
Plain Diff
Implemented credentials plugin interface
parent
8d4aec37
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/node/ext/call.h
+3
-0
3 additions, 0 deletions
src/node/ext/call.h
src/node/ext/credentials.cc
+34
-0
34 additions, 0 deletions
src/node/ext/credentials.cc
src/node/ext/credentials.h
+5
-1
5 additions, 1 deletion
src/node/ext/credentials.h
with
42 additions
and
1 deletion
src/node/ext/call.h
+
3
−
0
View file @
8cde3d7c
...
@@ -66,6 +66,9 @@ inline v8::Local<v8::Value> nanErrorWithCode(const char *msg,
...
@@ -66,6 +66,9 @@ inline v8::Local<v8::Value> nanErrorWithCode(const char *msg,
return
scope
.
Escape
(
err
);
return
scope
.
Escape
(
err
);
}
}
bool
CreateMetadataArray
(
Local
<
Object
>
metadata
,
grpc_metadata_array
*
array
,
shared_ptr
<
Resources
>
resources
);
v8
::
Local
<
v8
::
Value
>
ParseMetadata
(
const
grpc_metadata_array
*
metadata_array
);
v8
::
Local
<
v8
::
Value
>
ParseMetadata
(
const
grpc_metadata_array
*
metadata_array
);
struct
Resources
{
struct
Resources
{
...
...
This diff is collapsed.
Click to expand it.
src/node/ext/credentials.cc
+
34
−
0
View file @
8cde3d7c
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include
"grpc/grpc_security.h"
#include
"grpc/grpc_security.h"
#include
"grpc/support/log.h"
#include
"grpc/support/log.h"
#include
"credentials.h"
#include
"credentials.h"
#include
"call.h"
namespace
grpc
{
namespace
grpc
{
namespace
node
{
namespace
node
{
...
@@ -262,6 +263,39 @@ NAN_METHOD(Credentials::CreateFromPlugin) {
...
@@ -262,6 +263,39 @@ NAN_METHOD(Credentials::CreateFromPlugin) {
}
}
}
}
NAN_METHOD
(
PluginCallback
)
{
// Arguments: status code, error details, metadata
if
(
!
info
[
0
]
->
IsUint32
())
{
return
Nan
::
ThrowTypeError
(
"The callback's first argument must be a status code"
);
}
if
(
!
info
[
1
]
->
IsString
())
{
return
Nan
::
ThrowTypeError
(
"The callback's second argument must be a string"
);
}
if
(
!
info
[
2
]
->
IsObject
())
{
return
Nan
::
ThrowTypeError
(
"The callback's third argument must be an object"
);
}
grpc_status_code
code
=
static_cast
<
grpc_status_code
>
(
Nan
::
To
<
uint32_t
>
(
info
[
0
]).
FromJust
());
char
*
details
=
*
Nan
::
Utf8String
(
info
[
1
]);
grpc_metadata_array
array
;
if
(
!
CreateMetadataArray
(
Nan
::
To
<
Object
>
(
info
[
2
]).
ToLocalChecked
(),
&
array
,
shared_ptr
<
Resources
>
(
new
Resources
))){
return
Nan
::
ThrowError
(
"Failed to parse metadata"
);
}
grpc_credentials_plugin_metadata_cb
cb
=
reinterpret_cast
<
grpc_credentials_plugin_metadata_cb
>
(
Nan
::
To
<
External
>
(
Nan
::
Get
(
info
.
Callee
,
"cb"
).
ToLocalChecked
()
).
ToLocalChecked
()
->
Value
());
void
*
user_data
=
Nan
::
To
<
External
>
(
Nan
::
Get
(
info
.
Callee
,
"user_data"
).
ToLocalChecked
()
).
ToLocalChecked
()
->
Value
();
cb
(
user_data
,
array
.
metadata
,
array
.
count
,
code
,
details
);
}
void
plugin_get_metadata
(
void
*
state
,
const
char
*
service_url
,
void
plugin_get_metadata
(
void
*
state
,
const
char
*
service_url
,
grpc_credentials_plugin_metadata_cb
cb
,
grpc_credentials_plugin_metadata_cb
cb
,
void
*
user_data
)
{
void
*
user_data
)
{
...
...
This diff is collapsed.
Click to expand it.
src/node/ext/credentials.h
+
5
−
1
View file @
8cde3d7c
...
@@ -102,9 +102,13 @@ NAN_INLINE NAUV_WORK_CB(SendPluginCallback) {
...
@@ -102,9 +102,13 @@ NAN_INLINE NAUV_WORK_CB(SendPluginCallback) {
Nan
::
HandleScope
scope
;
Nan
::
HandleScope
scope
;
plugin_callback_data
*
data
=
reinterpret_cast
<
plugin_callback_data
>
(
plugin_callback_data
*
data
=
reinterpret_cast
<
plugin_callback_data
>
(
async
->
data
);
async
->
data
);
// Attach cb and user_data to plugin_callback so that it can access them later
v8
::
Local
<
v8
::
Function
>
plugin_callback
=
Nan
::
GetFunction
(
v8
::
Local
<
v8
::
Function
>
plugin_callback
=
Nan
::
GetFunction
(
Nan
::
New
<
v8
::
FunctionTemplate
>
(
PluginCallback
).
ToLocalChecked
());
Nan
::
New
<
v8
::
FunctionTemplate
>
(
PluginCallback
).
ToLocalChecked
());
// Attach cb and user_data to plugin_callback so that it can access them later
Nan
::
Set
(
plugin_callback
,
Nan
::
New
(
"cb"
).
ToLocalChecked
(),
Nan
::
New
<
v8
::
External
>
(
reinterpret_cast
<
void
*>
(
data
->
cb
)));
Nan
::
Set
(
plugin_callback
,
Nan
::
New
(
"user_data"
).
ToLocalChecked
(),
Nan
::
New
<
v8
::
External
>
(
data
->
user_data
));
const
int
argc
=
2
;
const
int
argc
=
2
;
v8
::
Local
<
v8
::
Value
>
argv
=
{
Nan
::
New
(
data
->
service_url
).
ToLocalChecked
(),
v8
::
Local
<
v8
::
Value
>
argv
=
{
Nan
::
New
(
data
->
service_url
).
ToLocalChecked
(),
plugin_callback
};
plugin_callback
};
...
...
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