aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Julien Boeuf <jboeuf@google.com>2016-08-23 10:04:03 -0700
committerGravatar Julien Boeuf <jboeuf@google.com>2016-08-23 10:04:03 -0700
commit6b93d46bb841200f100cb0dd7f8c6b62af445078 (patch)
tree4cdca03650880f22f52178a0046937cf04f4032a
parent56d7044ed808e08af8b7a812a140bd751622f15c (diff)
Adding extension points for security context.
-rw-r--r--include/grpc++/impl/codegen/client_context.h6
-rw-r--r--include/grpc++/impl/codegen/server_context.h6
-rw-r--r--src/core/lib/security/context/security_context.c6
-rw-r--r--src/core/lib/security/context/security_context.h7
4 files changed, 25 insertions, 0 deletions
diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h
index 012bcc2bbe..156bdb82f7 100644
--- a/include/grpc++/impl/codegen/client_context.h
+++ b/include/grpc++/impl/codegen/client_context.h
@@ -307,6 +307,12 @@ 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() const {
+ 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..82cb5a32ea 100644
--- a/include/grpc++/impl/codegen/server_context.h
+++ b/include/grpc++/impl/codegen/server_context.h
@@ -166,6 +166,12 @@ 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() const {
+ 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..b2ffd4efc2 100644
--- a/src/core/lib/security/context/security_context.h
+++ b/src/core/lib/security/context/security_context.h
@@ -84,6 +84,11 @@ void grpc_auth_context_unref(grpc_auth_context *policy);
void grpc_auth_property_reset(grpc_auth_property *property);
+typedef struct {
+ void *instance;
+ void (*destroy)(void *);
+} grpc_security_context_extension;
+
/* --- grpc_client_security_context ---
Internal client-side security context. */
@@ -91,6 +96,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 +108,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);