aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/security/context
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@gmail.com>2018-06-14 11:43:18 -0400
committerGravatar GitHub <noreply@github.com>2018-06-14 11:43:18 -0400
commit7ea8a60ed0ba4faeeb912e9b76ae1d0a222b3ddf (patch)
tree7a709e76d25faf1532df83c73dcefc571bd5685c /src/core/lib/security/context
parent9a2c0a8641d1837185a60436adf9419209f89fbe (diff)
Revert "Add Type Checking On Channel Args"
Diffstat (limited to 'src/core/lib/security/context')
-rw-r--r--src/core/lib/security/context/security_context.cc21
-rw-r--r--src/core/lib/security/context/security_context.h1
2 files changed, 19 insertions, 3 deletions
diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc
index 1f93416b23..14051a3f00 100644
--- a/src/core/lib/security/context/security_context.cc
+++ b/src/core/lib/security/context/security_context.cc
@@ -326,8 +326,23 @@ grpc_arg grpc_auth_context_to_arg(grpc_auth_context* p) {
&auth_context_pointer_vtable);
}
+grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg) {
+ if (strcmp(arg->key, GRPC_AUTH_CONTEXT_ARG) != 0) return nullptr;
+ if (arg->type != GRPC_ARG_POINTER) {
+ gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
+ GRPC_AUTH_CONTEXT_ARG);
+ return nullptr;
+ }
+ return static_cast<grpc_auth_context*>(arg->value.pointer.p);
+}
+
grpc_auth_context* grpc_find_auth_context_in_args(
- const grpc_channel_args* channel_args) {
- return grpc_channel_args_get_pointer<grpc_auth_context>(
- channel_args, GRPC_AUTH_CONTEXT_ARG);
+ const grpc_channel_args* args) {
+ size_t i;
+ if (args == nullptr) return nullptr;
+ for (i = 0; i < args->num_args; i++) {
+ grpc_auth_context* p = grpc_auth_context_from_arg(&args->args[i]);
+ if (p != nullptr) return p;
+ }
+ return nullptr;
}
diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h
index 2f73a5482c..e782e4f28f 100644
--- a/src/core/lib/security/context/security_context.h
+++ b/src/core/lib/security/context/security_context.h
@@ -108,6 +108,7 @@ void grpc_server_security_context_destroy(void* ctx);
#define GRPC_AUTH_CONTEXT_ARG "grpc.auth_context"
grpc_arg grpc_auth_context_to_arg(grpc_auth_context* c);
+grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg);
grpc_auth_context* grpc_find_auth_context_in_args(
const grpc_channel_args* args);