Getting started on metadata processor set on server creds.

pull/2777/head
Julien Boeuf 10 years ago
parent a87d6c2af6
commit 6bdc9b47bc
  1. 10
      include/grpc/grpc_security.h
  2. 6
      src/core/security/credentials.c
  3. 1
      src/core/security/credentials.h
  4. 5
      src/core/security/security_context.h
  5. 3
      src/core/security/server_secure_chttp2.c

@ -300,14 +300,8 @@ typedef struct {
void *state; void *state;
} grpc_auth_metadata_processor; } grpc_auth_metadata_processor;
/* XXXX: this is a temporarty interface. Please do NOT use. void grpc_server_credentials_set_auth_metadata_processor(
This function will be moved to the server_credentials in a subsequent grpc_server_credentials *creds, grpc_auth_metadata_processor processor);
pull request. XXXX
Registration function for metadata processing.
Should be called before the server is started. */
void grpc_server_register_auth_metadata_processor(
grpc_auth_metadata_processor processor);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -149,6 +149,12 @@ grpc_security_status grpc_server_credentials_create_security_connector(
return creds->vtable->create_security_connector(creds, sc); return creds->vtable->create_security_connector(creds, sc);
} }
void grpc_server_credentials_set_auth_metadata_processor(
grpc_server_credentials *creds, grpc_auth_metadata_processor processor) {
if (creds == NULL) return;
creds->processor = processor;
}
/* -- Ssl credentials. -- */ /* -- Ssl credentials. -- */
static void ssl_destroy(grpc_credentials *creds) { static void ssl_destroy(grpc_credentials *creds) {

@ -208,6 +208,7 @@ typedef struct {
struct grpc_server_credentials { struct grpc_server_credentials {
const grpc_server_credentials_vtable *vtable; const grpc_server_credentials_vtable *vtable;
const char *type; const char *type;
grpc_auth_metadata_processor processor;
}; };
grpc_security_status grpc_server_credentials_create_security_connector( grpc_security_status grpc_server_credentials_create_security_connector(

@ -105,8 +105,11 @@ grpc_server_security_context *grpc_server_security_context_create(void);
void grpc_server_security_context_destroy(void *ctx); void grpc_server_security_context_destroy(void *ctx);
/* --- Auth metadata processing. --- */ /* --- Auth metadata processing. --- */
#define GRPC_AUTH_METADATA_PROCESSOR_ARG "grpc.auth_metadata_processor"
grpc_auth_metadata_processor grpc_server_get_auth_metadata_processor(void); grpc_arg grpc_auth_metadata_processor_to_arg(grpc_auth_metadata_processor *p);
grpc_auth_metadata_processor grpc_auth_metadata_processor_from_arg(
const grpc_arg *arg);
#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */ #endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */

@ -60,6 +60,7 @@ typedef struct grpc_server_secure_state {
grpc_server *server; grpc_server *server;
grpc_tcp_server *tcp; grpc_tcp_server *tcp;
grpc_security_connector *sc; grpc_security_connector *sc;
grpc_auth_metadata_processor processor;
tcp_endpoint_list *handshaking_tcp_endpoints; tcp_endpoint_list *handshaking_tcp_endpoints;
int is_shutdown; int is_shutdown;
gpr_mu mu; gpr_mu mu;
@ -252,9 +253,11 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
grpc_resolved_addresses_destroy(resolved); grpc_resolved_addresses_destroy(resolved);
state = gpr_malloc(sizeof(*state)); state = gpr_malloc(sizeof(*state));
memset(state, 0, sizeof(*state));
state->server = server; state->server = server;
state->tcp = tcp; state->tcp = tcp;
state->sc = sc; state->sc = sc;
state->processor = creds->processor;
state->handshaking_tcp_endpoints = NULL; state->handshaking_tcp_endpoints = NULL;
state->is_shutdown = 0; state->is_shutdown = 0;
gpr_mu_init(&state->mu); gpr_mu_init(&state->mu);

Loading…
Cancel
Save