aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/grpc++/impl/codegen/client_context.h4
-rw-r--r--include/grpc++/impl/codegen/server_context.h4
-rw-r--r--src/core/lib/security/context/security_context.c6
-rw-r--r--src/core/lib/security/context/security_context.h12
4 files changed, 26 insertions, 0 deletions
diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h
index fb10a3be1a..d77ca4c396 100644
--- a/include/grpc++/impl/codegen/client_context.h
+++ b/include/grpc++/impl/codegen/client_context.h
@@ -307,6 +307,10 @@ class ClientContext {
};
static void SetGlobalCallbacks(GlobalCallbacks* callbacks);
+ // Should be used for framework-level extensions only.
+ // Applications never need to call this method.
+ grpc_call* c_call() { return call_; }
+
private:
// Disallow copy and assign.
ClientContext(const ClientContext&);
diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h
index 08212af861..c9d1f4d69e 100644
--- a/include/grpc++/impl/codegen/server_context.h
+++ b/include/grpc++/impl/codegen/server_context.h
@@ -166,6 +166,10 @@ class ServerContext {
async_notify_when_done_tag_ = tag;
}
+ // Should be used for framework-level extensions only.
+ // Applications never need to call this method.
+ grpc_call* c_call() { return call_; }
+
private:
friend class ::grpc::testing::InteropServerContextInspector;
friend class ::grpc::ServerInterface;
diff --git a/src/core/lib/security/context/security_context.c b/src/core/lib/security/context/security_context.c
index 127b13ee50..2204fadf54 100644
--- a/src/core/lib/security/context/security_context.c
+++ b/src/core/lib/security/context/security_context.c
@@ -99,6 +99,9 @@ void grpc_client_security_context_destroy(void *ctx) {
grpc_client_security_context *c = (grpc_client_security_context *)ctx;
grpc_call_credentials_unref(c->creds);
GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "client_security_context");
+ if (c->extension.instance != NULL && c->extension.destroy != NULL) {
+ c->extension.destroy(c->extension.instance);
+ }
gpr_free(ctx);
}
@@ -114,6 +117,9 @@ grpc_server_security_context *grpc_server_security_context_create(void) {
void grpc_server_security_context_destroy(void *ctx) {
grpc_server_security_context *c = (grpc_server_security_context *)ctx;
GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "server_security_context");
+ if (c->extension.instance != NULL && c->extension.destroy != NULL) {
+ c->extension.destroy(c->extension.instance);
+ }
gpr_free(ctx);
}
diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h
index 4e7666dfe3..1e131a0c23 100644
--- a/src/core/lib/security/context/security_context.h
+++ b/src/core/lib/security/context/security_context.h
@@ -84,6 +84,16 @@ void grpc_auth_context_unref(grpc_auth_context *policy);
void grpc_auth_property_reset(grpc_auth_property *property);
+/* --- grpc_security_context_extension ---
+
+ Extension to the security context that may be set in a filter and accessed
+ later by a higher level method on a grpc_call object. */
+
+typedef struct {
+ void *instance;
+ void (*destroy)(void *);
+} grpc_security_context_extension;
+
/* --- grpc_client_security_context ---
Internal client-side security context. */
@@ -91,6 +101,7 @@ void grpc_auth_property_reset(grpc_auth_property *property);
typedef struct {
grpc_call_credentials *creds;
grpc_auth_context *auth_context;
+ grpc_security_context_extension extension;
} grpc_client_security_context;
grpc_client_security_context *grpc_client_security_context_create(void);
@@ -102,6 +113,7 @@ void grpc_client_security_context_destroy(void *ctx);
typedef struct {
grpc_auth_context *auth_context;
+ grpc_security_context_extension extension;
} grpc_server_security_context;
grpc_server_security_context *grpc_server_security_context_create(void);